Response length is proportional to query complexity
Why it matters
Unbounded max_tokens with no length guidance produces two failure modes at once: the model either pads simple answers into three-paragraph essays (burning tokens against the cost-efficiency taxon) or gets cut off mid-sentence on complex queries because the default context is exhausted. Users wait longer, pay more per request, and read padding that obscures the answer. At scale, a single missing max_tokens parameter can triple your OpenAI bill without anyone noticing until the invoice.
Severity rationale
Medium because the impact is financial and UX degradation rather than security or data loss, but recurs on every request.
Remediation
Set a context-appropriate max_tokens ceiling and add length calibration to the system prompt so the model adapts output length to query complexity. Apply this at every call site in lib/ai/chat.ts.
await openai.chat.completions.create({
model: 'gpt-4o',
max_tokens: 1024,
messages: [{ role: 'system', content: 'Answer concisely. Simple questions: 1-2 sentences. Complex topics: structured paragraphs. Never pad.' }, ...]
})
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the AI Response Quality Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-response-quality·automated