The signatureThe body says
Input token exceed the limit, but the normalized error code is INVALID_REQUEST.Classification decides whether recovery runs.
CONTEXT_WINDOW_EXCEEDEDprune → compact → retryThe compaction listener receives its exact machine code.
INVALID_REQUESTfail → manual recoveryThe same physical overflow bypasses the listener.
Read the body, not only the provider code.
{
"message": "Input token exceed the limit",
"type": "api_error",
"code": "quota_limit_reached"
}Do not widen blindly.
quota_limit_reached can also describe account or monthly usage limits. Match the context wording narrowly and retain the raw response beside the normalized error.
Budget the next request before sending it.
history tokens+tool and system tokens+requested output<model context window
Recover in a bounded order.
- 01Capture
Save the raw body, normalized code, model, adapter, and request ID.
- 02Lower output
Reduce
maxTokensonly if the history still leaves usable headroom. - 03Compact once
Try
/compactonce. Stop if its summarizer also exceeds context. - 04Continue cleanly
Open a new Session with a concise handoff and links to retained evidence.
Regression needs a positive and a negative.
Input token exceed the limitCONTEXT_WINDOW_EXCEEDEDMonthly usage quota exceededusage or account limitAcceptance gates.
- Raw provider body is retained.
- Normalized code is observable.
- Real overflow reaches the listener.
- Usage quota stays a separate class.
- Compaction retries are bounded.
- A clean continuation preserves evidence.
Primary evidence.
Keep the complete runbook.
The canonical guide includes capture fields, decision branches, source boundaries, and a minimal incident report.
Read and star on GitHub