Commit Graph
1 Commits
Author SHA1 Message Date
yetone c8f103fac0 gateway: a conversation too long for the model reaches the agent at once, not retried as a rate limit (#1944, ASD-max)
The ChatGPT backend answers an overflowing Codex request with a 200
stream whose error event and response.failed say
context_length_exceeded. streamStatus read that through quotaWords,
whose "exceeded" matched, so it counted as a 429: the group's patience
asked the same member again 7-8 times and the account was rested,
while the agent never got the error that makes it compact.

quotaSaid(msg) is quotaWords minus anything tooLong(400, msg) already
calls an overflow. streamStatus checks tooLong first (-> 400), and its
429 case and claude_subscription.go's two quotaWords guesses use
quotaSaid. A real rate limit, an overload and a spent quota read as
before.

Tests (overflow_stream_test.go, from the real backend stream, its
safety_identifier redacted):
- TestStreamOverflowNotRateLimit: the overflow events are 400; rate
  limit 429, overload 529, usage limit 429 unchanged.
- TestCodexOverflowInGroupNotAskedAgain: the agent gets
  context_length_exceeded, the member is asked once, no rest.
Both fail on the old code. Ran: go test -tags nogui ./internal/gateway/
(full package, ok), go vet on darwin/linux/windows, gofmt -l.
2026-10-13 16:17:05 +08:00