ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a3ebed202e |
gateway: Codex's compaction back on its own model goes without another vendor's reasoning text, so the turn after DeepSeek isn't refused over input[n].content (jue on Discord)
jue (Codex app, GPT-6.1 Sol) set a DeepSeek model for Codex on the Agents page, went back to GPT, and the next turn sometimes failed with "[ArrayParam] [input[8].content] [array_above_max_length] Invalid 'input[8].content': array too long. Expected an array with maximum length 0, but got an array with length 1 instead." Cause: when the model changes (or the thread passes its auto-compact limit) Codex compacts the thread before the turn, and shows a failed compaction as the turn's error. Codex's /responses/compact for one of its own models went to the ChatGPT backend (Codex's sign-in, its sk- key, or a magpie Codex account through compactOn) with its input as sent. A reasoning item from DeepSeek's Responses API carries its reasoning_text in content, which OpenAI accepts only empty, so the whole compaction was refused. A turn on the same routes already went through codexInput(body, false), which drops such items; the compaction didn't. "Sometimes" is when Codex compacts first. Fix: codexBackend's own-model branch runs codexInput(body, false) on /responses/compact too, before any of the three routes. OpenAI's own sealed reasoning (encrypted_content, no text) stays; a summary magpie made goes as its text, as from a turn. DeepSeek still gets its reasoning text (withReasoningText). Siblings read: the translated Responses path sends back only sealed reasoning (sealedReasoning); passthrough strips reasoning text for openai.com, Azure and Codex accounts and retries on the refusal elsewhere (#1411). Not covered: a full restore that drops openai_base_url leaves magpie off Codex's path. Codex's base_instructions and prompts are untouched. Test: TestForeignReasoningNeverReachesOpenAI sends the reported thread (input[8] a DeepSeek reasoning item with one reasoning_text, input[3] OpenAI's sealed reasoning) on seven routes: turn and compaction on Codex's sign-in, its API key and a magpie account, and /v1/responses with codex/gpt-6.1-sol. The fake OpenAI refuses a reasoning item with text with the reported 400 byte for byte. On the old code the three compaction routes are red with that 400 and the four turns green; with the fix all seven are green. Broken by hand a second way (codexInput(body, true) on the compact branch): the same three red. Run at |
||
|
|
ecc94dbf41 |
gateway: a routing group's DeepSeek reasoning, its text in it, no longer sticks a Codex conversation on OpenAI destinations (#1411, cth123456: "Invalid 'input[n].content': array too long")
A group turn served on DeepSeek hands Codex a reasoning item with both content (reasoning_text) and encrypted_content. Codex sends it back on every later turn, and the /backend-api/codex handler keeps reasoning for a group (codexInput(body, true)). Routed next to a Codex account or a relay in front of OpenAI, the request was turned away with 400 "Invalid 'input[n].content': array too long. Expected an array with maximum length 0 ...", which neither the foreign-seal retry nor #1044's bare-reasoning retry matched, so every later turn failed the same way. In passthrough, for an upstream that isn't sent reasoning text back (not replaysReasoning, so DeepSeek still gets it): - a Codex account, openai.com or Azure is never sent a reasoning item with content parts (withoutReasoningText), as codexInput already leaves it out for Codex's own models; its seal is the other vendor's, so the item goes; - any other upstream that answers 400 naming input[n].content "array too long", where item n is reasoning with content, is asked once more without such items, and the provider's model is marked unfit for them (reasoningTextRefused), so later turns go without them the first time, as #1044 does for bare reasoning. The destination's own sealed reasoning, messages and tool calls stay. Verified: - TestReasoningTextLeftOutWhereRefused (group to a strict relay, the issue's literal item) and TestReasoningTextNotSentToCodexAccount (group to a Codex account) fail without the change with 400 "AgentRouter:/Codex: Invalid 'input[1].content': array too long ..."; the relay is asked twice then once, the account once. TestReasoningTextKeptWhereTaken keeps the item for an upstream that takes it. - Real ChatGPT backend (the owner's Pro account, gpt-5.5, store false): the issue's item answers 400 "Invalid 'input[1].content': array too long. Expected an array with maximum length 0, but got an array with length 1 instead." param input[1].content, code array_above_max_length; the test fixture uses those bytes. The same request without the item completes. Not tried against AgentRouter itself. - gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway, go test -tags nogui -count=1 ./internal/gateway under a temp HOME: all pass. |