ac4af582301a4e8a29245dbba767eba31334ddf9
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
36af588e2c |
gateway: "Context window is full" is a conversation too long for the model
ergou0954_54426 on Discord (#feedback, 11-01) routes by intent across several models, one a "kiro opus" of an API-key relay (not magpie's Kiro plugin). On long conversations the relay answered 400 "Context window is full. Reduce conversation history, system prompt, or tools. (request id: …)". That is the wording kiro.rs (src/anthropic/handlers.rs) and kiro2claude (error-mapper.ts) give Kiro's CONTENT_LENGTH_EXCEEDS_THRESHOLD, always as a 400 invalid_request_error, with new-api's request id after it. tooLongRe had no words for it, so the 400 was an ordinary request error: the group never asked the next member, and the agent got the relay's 400 as a plain error, with no context_length_exceeded to compact on. In a stream's error event it stood for a 502 (streamStatus), a passing vendor fault that rests the account and is asked again. tooLongRe now takes "context (window )?(is )?full", so overflowed, failure, retryable, streamStatus, lateRests and writeErrorSaid all read it the same way: on 400, 413 or 422, or in a stream's error event, the member is passed for one with room (failOverflow, no rest), and alone the agent is told context_length_exceeded. Not changed: a 5xx carrying the words is still the vendor's fault (tooLong is 4xx only, as TestContextOverflowSaidTheClientsWay holds for a 502), and tooLongUnsaid still covers a 5xx only where the window is known. Routing could not have skipped the member up front: a custom relay's model has a window only from its own /v1/models list, models.dev by id (catalog.ContextOf, with its spellings), or the user's Context setting. A relay id such as "kiro-opus" matches none, so the window is unknown (0), roomy keeps it and withRoom counts it as having room. A probe in a fresh HOME gave windowOf 0 for claude-opus-4-6, kiro-claude-opus-4.6 and kiro-opus on a custom provider. TestContextWindowFullIsAnOverflow and TestContextWindowFullGoesToAMemberWithRoom are built from the literal text, with and without the request id, Anthropic- and OpenAI-shaped, plus kiro.rs's sibling "Input is too long. Reduce the size of your messages."; ordinary 400s (invalid model, model not found, messages required) stay non-overflows. Found and filed, not fixed: the last candidate's stream error event that says too long reaches the agent as the vendor wrote it (#4675). Run on mote, on this change at base |