ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6f041c292c |
gateway: a Codex compaction relayed to a vendor that isn't OpenAI's asks as system, not developer (#2955)
forVendor, the fitting a relayed Responses request gets before it goes to a provider that isn't OpenAI's, now turns the developer messages of a summary ask magpie made itself (codexCompact) into system ones, where they stand (developerItemsAsSystem). Codex's own turns keep the role the client sent, which a relay may be checking them by (#350, #1758), and OpenAI's own API and the ChatGPT backend, which take developer as Codex sends it, get the compaction as it came too. Why: on a provider whose Responses endpoint fronts a chat-only vendor (a relay of one; DeepSeek's preset names one base for chat and responses alike), every Codex compaction failed there with 400 "developer is not one of ['system', 'assistant', 'user', 'tool', 'function']", retried five times, while the turns around it passed: the summary request is relayed as Codex sent it (tools: [], #378), and the compaction carries a developer message its turns don't. The translated route already lifts such messages into the system prompt; the summary ask now says them as system on the relayed route too, in place, so a thread's cached prefix keeps its shape (#502) — what Zed's cloud is already given (ZedBody) and what a Chat Completions upstream is given (developerAsSystem). Run: TestCodexCompactDeveloperAsSystemOnAVendorRelay (red before, green after; ablated and mutated), the compaction families (TestCodexCompact*, TestLocalCompaction*, TestNativeCompaction*, TestVendorRelay*, TestAdditionalTools*, TestCodexOpenAIFields*), the full gateway package, -race over the families, go vet and go build of the package on darwin, linux and windows. Refs #2955 Landing record (yetone): Run at the pushed batch head (tree a6b084d0b, on origin/main |
||
|
|
51d5b8d0b2 |
gateway: a Codex compaction's summary cut short or 429'd halfway fails over and rests the account, and one that keeps failing is held, not asked every 18s (#2274, huangzuomin)
Codex on antigravity/gemini-3.8-flash with context_management's
experimental mode asked magpie for 1169 summaries in 6 hours (8.44M
billed tokens), ending in 502 "compaction: the model wrote no summary".
Cause, in three parts:
- serve's holdWriter let the summary's stream through at its first
words, so Antigravity cutting it short ("the reply ended before it was
complete"), or a 429 "Individual quota reached" after some of it,
reached codexCompact as a 200 with an error: no failover, no rest.
- codexCompact took a summary that ended `incomplete`, or a body with
no response at all, as one.
- Codex's async compaction (codex-rs async_compaction) starts a
background compaction at every step while the conversation is over its
threshold and drops a failed one silently, so the history never
shrank and each step paid for the whole conversation again.
Fix:
- codexCompact marks its request askWhole; serve then holds the summary
stream to its end (holdWriter.wantWhole). A cut, an error event or
`response.incomplete` anywhere in it fails over to the next candidate
like a failure before content and rests the account as that would; a
model that reached its output limit rests nobody.
- With nobody left, the cut/incomplete summary is a 502 saying so, never
the words before the cut.
- compactFails (codex_compact_guard.go): after 3 failed summaries in a
row of one conversation (prompt_cache_key) on one model, each within
5 minutes, the next is answered 400 at once (Codex doesn't retry a
400) naming the last failure, until 5 minutes pass. A summary clears
it; 401/403 aren't counted. Decision: a 400 is the only answer Codex's
remote compaction stops on, and a per-conversation hold costs a user
whose model recovers at most 5 minutes, while the loop cost tokens.
- docs/subsystems/gateway-routing.md says so.
Run (worktree at origin/main
|