Commit Graph
3 Commits
Author SHA1 Message Date
SadWood b69d9089e6 fix(gateway):保留413跨成员回退并说明请求体限制 (#711)
将 request_too_large 与明确的上下文超限分别处理。成员返回普通或结构化 413 时尝试其他成员,跳过同成员的额外账号,不将该成员休眠。仅在最终向客户端返回 413 时加入减少图片、大型工具结果或带摘要开启新会话的建议。

保留 tooLongUnsaid 对文本估算超过已知窗口 1.2 倍的判断,以及已有的上下文溢出窗口过滤和压缩提示。

补充 Anthropic 与 Codex 两条协议路径、成功及耗尽回退、同成员账号跳过、高文本估算和迁移 Factory 插件的合成回归测试。
2026-10-04 10:01:47 +08:00
yetone 11a09d418c gateway: every vendor's "too long" reaches the agent as context_length_exceeded and fails over to nobody, and a spent budget isn't asked again in place (owner: 继续做第 4 项,错误分类接入 failover) — pi's two tables (packages/ai/src/utils/overflow.ts, retry.ts) against magpie's classifier: 15 of pi's 25 overflow texts weren't known, so the agent got the vendor's words and didn't compact, and four were worse: Kimi's "exceeded model token limit" rested the account as out of quota, and z.ai's model_context_window_exceeded, Ollama's "prompt too long; exceeded max context length" and "token limit exceeded" went to every other account in turn (quotaWords' "exceeded"). tooLongRe takes pi's patterns (request_too_large, Gemini, xAI, Groq, OpenRouter, Together, llama.cpp, LM Studio, Copilot, MiniMax, Kimi, DS4, z.ai, Ollama, DashScope), and overflowed (a 400/413/422 saying so) is neither retryable nor a quota or credit failure, so nobody rests and it is answered at once. "out of budget" / "budget exceeded|exhausted" are a used-up plan: a 429 was a rate limit asked three times in place, a 400 was answered without trying the next account. TestEveryVendorsOverflow and TestOutOfBudgetIsntRetriedInPlace fail on the old code (26 failures). Real accounts, sandbox magpie, a 2.2M-token request: Qoder's "invalid params, context window exceeds limit" came back from the old build as 413 api_error with no code (Claude Code and Codex wouldn't compact) and is now 400 context_length_exceeded / Anthropic "prompt is too long: …"; WorkBuddy, WorkBuddy AI, Kiro and Grok (SuperGrok) answer context_length_exceeded too, and ordinary requests through each still answer. go vet, GOOS=linux/windows builds and go test -tags nogui -count=1 ./... under a temp HOME pass. Silent overflow (usage past the window on a 200) isn't detected: the reply is already the agent's by then. 2026-10-03 14:55:37 +08:00
yetone 40812f1d2b gateway: a vendor saying the conversation is too long is said the client's way, so the agent compacts and retries — Volcengine's "Input exceeds the context limit (1048568 tokens)" reached Claude Code and Codex as a plain error they stop on; a 4xx that says the input is past the model's context (context_length_exceeded, maximum context length, prompt is too long, exceeds the context limit, 超过上下文…) now answers 400 with Anthropic's "prompt is too long: …" on /v1/messages and code context_length_exceeded on chat and Responses; one about max_tokens is left alone 2026-09-26 01:38:37 +08:00