fix(context): detect Anthropic 'prompt is too long' as context length error#821
fix(context): detect Anthropic 'prompt is too long' as context length error#821Bartok9 wants to merge 1 commit into
Conversation
… error (NousResearch#813) Anthropic's native API returns context overflow errors in a unique format: "prompt is too long: 233153 tokens > 200000 maximum" This wasn't matched by the existing is_context_length_error phrases, causing the agent to abort immediately instead of triggering context compression. Added 'prompt is too long' to the detection list so these errors correctly trigger compression and retry like other context length errors. Closes NousResearch#813
|
Note: The CI failure is unrelated to this PR. The test |
|
Fixed in commit a54405e with a more comprehensive approach:
Thanks for the clear issue report and clean PR @Bartok9! |
Summary
Fixes #813 — Anthropic's native API returns context overflow errors in a unique format that wasn't being detected:
This format wasn't matched by the existing
is_context_length_errorphrases, causing the agent to abort immediately as a "non-retryable client error" instead of triggering context compression.Changes
'prompt is too long'to the context length error detection phrasesTesting
test_413_compression.pypassImpact
Users on Anthropic models (direct API or via OpenRouter) will now get proper context compression when hitting the 200k token limit, instead of an immediate failure.