ac4af582301a4e8a29245dbba767eba31334ddf9
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
11df525f06 |
gateway: only the vendors seen to hide an overflow have a bare failure told as too long (#5486)
NEKO-CwC asked, after v0.1.3141, why a custom API-key Responses relay's 400/413/422 is still turned into context_length_exceeded when the relay never said so. It shouldn't be. tooLongUnsaid read any provider's 400/413/422 that said nothing of length, for a request 1.2 times past the model's window, as "prompt is too long". That rule came from three vendors' refusals in |
||
|
|
978284dd69 |
gateway: a transport failure or a plain 502 is not told as too long
Filed as #5486. ne9ko9 runs Codex through magpie to a custom OpenAI Responses relay (gpt-6-astra, effort max). Three failures reached Codex as HTTP 400 "prompt is too long: about 385K/404K tokens, more than gpt-6-astra's context window of 272000": a plain 502 "Upstream service temporarily unavailable", a TCP connect timeout (dial tcp … connectex) and a TCP read timeout. Codex took them as context_window_exceeded and ended the turn instead of asking again, although the same session had just been answered at 454K and 474K, and Codex's own window was 828,400. tooLongUnsaid now: - reads a 5xx as an overflow only for Devin (busyOverflows: p.ID or its plugin's host), the vendor |
||
|
|
97f264c7fb |
gateway: a 413 on the OpenAI routes says request_too_large, so pi compacts (@wilsonxuuuu on X)
@wilsonxuuuu's pi, on gpt-6.1 through magpie, stopped on
"magpie API error (413): {...,"type":"api_error"}" at 114k of a 1M
window and never auto-compacted. The vendor's 413 was a body byte cap.
pi's overflow table (pi-ai utils/overflow.ts) knows a byte cap only as
request_too_large, Anthropic's type, which magpie already gave on the
Anthropic route but not on chat/responses. writeErrorSaid now types
every 413 request_too_large (Gemini keeps its own status shape). The
status stays 413 and the byte-limit hint stays; it is not turned into
context_length_exceeded, so Codex and Claude Code read it as before
(Codex reads code, not type). pi compacts once and retries once
(_overflowRecoveryAttempted), so a body that is still too big after
compacting stops instead of looping.
Run:
- pi 1.1.0's own isContextOverflow on the reporter's body: api_error
false, request_too_large true.
- TestPayloadTooLargeSaysRequestTooLargeToPi (an nginx 413 page from a
chat upstream) and the new Chat/Responses rows of
TestBodyRejectionErrorShapes fail with the gateway.go change reverted
by hand, pass with it.
- go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME:
every package ok. gofmt clean; GOOS=linux and windows go vet of
internal/gateway clean.
Not tried: a real pi session hitting a real vendor 413.
|
||
|
|
0f398c4895 |
gateway: a group member whose window can't hold the request isn't asked it (dgqyushen on Discord)
dgqyushen on Discord: OpenCode Zen's free DeepSeek V4.1 Flash (200K) first in a group and a 1M DeepSeek subscription second, so that the first 200K go free and past that go to the subscription. The gateway fell over only on a refusal it reads as too long (#700, withRoom/failOverflow, tooLongUnsaid past 1.2x the window). A vendor that refuses a request just past its window without saying why (between 1.0x and 1.2x) reached the agent as that error while the next member had room, and every doomed request spent one against the free tier's limits. roomy (fallback.go), in serve after rules, affinity, the image filter and pinTo and before probeOne, estimates the request as the overflow path does (estimate) and leaves out the candidates whose known window (windowOf: Contexts, the catalog, ContextOf) is no larger, and their order rows with them. It is a check before sending, not a retry. Kept: a window not known, a body that doesn't parse, a single model, and a request no candidate holds (the first is asked, its overflow told to the agent to compact). A conversation stuck to the small member by affinity moves once it outgrows it. count_tokens (a count on the first member) and System One's decision models don't go through serve's candidate path and are left alone; every generation route (middleware, classify, search, vision, codex titles/backend, auto groups) goes through serve. No UI change: a member left out is absent from the route's order. TestPayloadTooLargeOverWindowTriesMemberWithRoom now expects the members too small not to be asked at all (c only, one try). Run: - go test -tags nogui -p 1 ./internal/gateway -run 'TestMemberTooSmallIsNotAsked|TestConversationOutgrowingItsMemberMoves| TestRoomyLeavesWhatItCantJudge|TestPayloadTooLarge': ok - the overflow tests (TestPayloadTooLarge, TestOverflow, TestContextOverflow, TestEveryVendorsOverflow, TestCodexOverflowInGroup, TestStreamOverflow, TestRateLimitNotContextOverflow) with the new ones: ok - gofmt -l clean; go vet ./internal/gateway (darwin); GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean; go build darwin, linux, windows: ok. Broken by hand: the roomy call in serve commented out: TestMemberTooSmallIsNotAsked red (400 "FREE: Invalid request parameters"), TestConversationOutgrowingItsMemberMoves red (free 2, paid 0), TestPayloadTooLargeOverWindowTriesMemberWithRoom red (a 1, c 1, 2 tries); restored, all green. Not run: the whole internal/gateway package (the run failed to build, "no space left on device", the disk at 0 GB free) and the full suite (left to the batch's run). Not tried against the real OpenCode Zen. Known: the estimate is bytes/4, so mostly-CJK text counts high and a member may be passed over a little early. Full suite: SUITE_LINE |
||
|
|
b69d9089e6 |
fix(gateway):保留413跨成员回退并说明请求体限制 (#711)
将 request_too_large 与明确的上下文超限分别处理。成员返回普通或结构化 413 时尝试其他成员,跳过同成员的额外账号,不将该成员休眠。仅在最终向客户端返回 413 时加入减少图片、大型工具结果或带摘要开启新会话的建议。 保留 tooLongUnsaid 对文本估算超过已知窗口 1.2 倍的判断,以及已有的上下文溢出窗口过滤和压缩提示。 补充 Anthropic 与 Codex 两条协议路径、成功及耗尽回退、同成员账号跳过、高文本估算和迁移 Factory 插件的合成回归测试。 |