Repository navigation
Bug: DeepSeek "Input token exceed the limit" (400 quota_limit_reached) not classified as context overflow - auto recovery never triggers #3399
Replies: 3 comments
|
Thanks for the independent confirmation — this matches what I found exactly, and it's good to have the evidence chain written down. On the regression matrix: the fix I prepared already covers both sides you listed.
The change is one additional pattern in Agreed on the operational flow, with one nuance worth adding: automatic recovery can only help before the history is already over the window. Once the summarizer itself cannot read the history, a new session with a concise handoff is the only way out — exactly as you wrote. |
|
Same function, one more wording it misses: The raw 400 from the gateway: {"message":"The input is longer than the model's context length trace_id: ...","type":"invalid_request_error"}
Repro: cd packages/llm/llm
node --import tsx/esm -e "
const { isContextWindowExceededError } = await import('./src/error.ts')
console.log(isContextWindowExceededError(\"The input is longer than the model's context length\"))
"
# falseA 161-turn session on this machine: There is no compaction event between turn 35 and turn 37; the session has 8 compactions in total, at turns 44, 62, 97 and 141. Turn 38 recovered, and the log does not show why. One verb fixes it: - + String.raw`\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than)\b.{0,40}`
+ + String.raw`\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than|is\s+longer\s+than)\b.{0,40}`No generic verb such as Tested: 93 classifier cases pass, and 897 cases pass across #3399 and this comment both miss a wording; #7632 is the |
Uh oh!
There was an error while loading. Please reload this page.
Bug: DeepSeek
Input token exceed the limit(HTTP 400, codequota_limit_reached) is not classified as context overflow, so automatic compaction recovery never triggers现象 / Symptom
When a conversation exceeds the model context window, the DeepSeek API rejects the request with:
{"message":"Input token exceed the limit (request id: ...)","type":"api_error","param":"","code":"quota_limit_reached"}The harness classifies this as
INVALID_REQUEST(the 400 fallback), the turn fails, and a manual/compactafterwards fails with "Compaction could not produce a useful summary", because the history is already too long for the summarizer to read. I hit this against the official API through an OpenAI-compatible proxy (pi-ai provider).根因 / Root cause
isContextWindowExceededErrorinpackages/llm/llm/src/error.tsrecognizes wording likecontext length exceeded,maximum context length, andtoo large for the model context, but not DeepSeek's terse production messageInput token exceed the limit(thequota_limit_reachedcode name is reused for this failure). So both thellm-deepseekandllm-pi-aiadapters normalize it toINVALID_REQUEST.The consequence is more than cosmetic: compaction-basic's automatic overflow recovery (
agent/request-errorlistener) keys onCONTEXT_WINDOW_EXCEEDED, so the prune → compact → retry path never runs and the turn just dies with 400.建议修复 / Suggested fix (already prepared)
Add an
INPUT_TOKEN_EXCEED_LIMITpattern to the classifier:Requiring
the limitto followexceedimmediately keeps usage-limit phrasings such asinput tokens exceed the monthly usage limitout of the branch. The fix is implemented and verified locally (classifier unit tests +llm-deepseekmock-server test with the real 400 body +llm-pi-aistream test;error.tsstays at 100% coverage). It is available for reference on a fork branch:fantasywinter207/deepseek-harnessbranchfix/classify-deepseek-input-token-exceed-limit(commit6efce3a26e), in case the team wants to pick it up.Happy to adjust anything if the team prefers a different wording/approach.
All reactions