Files
magpie/docs
ggbdpq 5032d3ade7 gateway: a reasoning item magpie hands Codex with its text in it becomes one of its own, a summary and nothing sealed (#2855)
What changed

A Responses reasoning item that carries the model's reasoning as content
parts (reasoning_text) — another vendor's shape; OpenAI's own items carry
summaries — no longer reaches a client of magpie's as the upstream wrote
it. It is made over into the item magpie makes of any other upstream's
reasoning: its text (and its summaries) as one summary, an rs_ id, no
content and no seal — in a reply translated for the client
(magpieMadeReasoningRaw at the encoder's sealed item and the whole reply's
renderer) and in one relayed as it came (reasoningTidy, a passthrough
filter on Responses streams and whole replies, the item in
output_item.added/done and in response.completed's output). The
subsystems doc's rule is amended to say so.

Why

A Codex conversation that used OpenAI, went through magpie to DeepSeek,
then had magpie disconnected again, was stuck: every later turn, the
remote compact too, answered 400 "Invalid 'input[43].content': array too
long. Expected an array with maximum length 0, but got an array with
length 1 instead." The reporter's rollout forensics narrow it: the
DeepSeek phase had left 25 reasoning items, each with its text in content
parts and a 38-character encrypted_content of the vendor's own (not the
gAAAA the thread's own GPT-phase items carry, which have no content),
which Codex stores and replays to OpenAI. OpenAI takes a reasoning item
sent back only with its content empty (#1411) and cannot open another
vendor's seal, so such an item poisons the thread for OpenAI wherever it
was planted — and once Codex holds it, no retry of magpie's can strip it:
client keeps, and #2855 came with magpie out of the path entirely. A
Chat-API upstream's turn has always translated to an item of magpie's own
(an rs_ id and a summary, TestTranslatedChatReasoningCarriesNoContent
pins it); the items the reporter held are a Responses wire's own, which
both the translated and the relayed reply handed over as they came. What
magpie hands a client must be re-sendable to a strict Responses upstream:
the text is kept in the summary, so an upstream that wants its reasoning
back still gets it (withReasoningText), and magpie's own OpenAI
destinations keep the item out as they did (#1008, #1044, #1411).

Run

- TestForeignSealedReasoningGivenCodexCarriesNoContent (translated) and
  TestForeignSealedReasoningRelayedCarriesNoContent (relayed) fail on
  upstream/main with the issue's item handed over whole — content, empty
  summary and the vendor's seal in both output_item.done and
  response.completed — and pass with the change;
  TestTranslatedChatReasoningCarriesNoContent (a Chat upstream's
  reasoning, translated) is green without and with the change.
- Restoring the three product files alone to upstream/main (tests kept)
  fails the two again; restoring them back passes.
- Attaching content to the made item fails both again ("carries its
  text"), and dropping the made summary fails both ("carries no
  summary").
- go test -tags nogui -count=1 ./internal/gateway: ok 312.4s;
  -run 'TestTranslated|TestReasoning|TestSealed': ok 7.9s;
  go test -race -tags nogui -count=1 -run 'TestTranslated|TestReasoning':
  ok 9.4s. gofmt -l internal/gateway empty. go vet -tags nogui and
  go build -tags nogui -o /dev/null . on darwin, GOOS=linux and
  GOOS=windows: pass (a pre-existing cgo -Wenum-conversion warning in
  internal/gui/trayimage_darwin.go on darwin, untouched).

Not tried against real OpenAI or DeepSeek accounts; the reporter's
rollout reading is taken from the issue, not re-derived from a live
thread.

Reviewed and landed as one batch of 12 commits (gua's #4593, #3269,
sibling, and four review follow-ups). Run for the batch, whose last
commit's tree is 5d58a75f3:
- Full suite before the rebase (base d307aa648, wsl-run magpie-desktop,
  go test -tags nogui -count=1 -timeout 45m ./...): 81 packages ok. Reds,
  all with issues and none in code this batch touches: internal/agent
  TestInstalledVersion, TestGrokInstalled, TestOmpDetectedWithPiDir
  (#4033, #3548, #3141); gateway TestUnroutedHeldReportSaved (#4300);
  gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestColdTurnsTaken (#4510); provider
  TestClaudeAccountServesModelsListedSinceItsFetch (#3174). Run alone at
  origin/main 573b21f4b, TestGrokInstalled, TestOmpDetectedWithPiDir
  and TestSettingsSaveKeepsWhatItDoesNotSend are red there too. The
  other four pass there alone.
- After the rebase onto origin/main 573b21f4b, at this tree:
  internal/usage, update, gateway and provider ok. In internal/agent,
  the #4033/#3141 install-detection reds plus TestCopilotFolderFrom-
  AnIDEPluginIsNotTheCLI and TestZedAppPath. Those two are flaky the
  same way at origin/main (-count=10 alone: 4 and 5 of 10 red) and are
  already listed in #4033. The #3269 tests (TestCopilotLauncher*) pass
  5 of 5.
- Rebased onto origin/main ef63ef4a2. The #2855 commit met 0b9727ec9
  (#2974) in responses.go: the streamed item's done now takes both, the
  upstream's own id (thinkUp) and the made-over item; and in
  gateway-routing.md main's paragraph is kept with #2855's clause. That
  matches gua's latest head (range-diff: context only). At tree d7c76c6fa:
  internal/gateway, provider, usage, redact and update ok; vet
  GOOS=linux -tags nogui ./internal/..., darwin and GOOS=windows for
  gateway and provider.
- Rebased last onto origin/main d8f7d089f (5 commits: internal/agent
  and GUI files only). At tree 0d4bfd8c8, the pushed one: internal/agent's
  TestCopilotLauncher*, TestClaude*, TestOwn* and TestVSCode* ok, -count=3;
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI red once there, as it is at
  main (#4033). Vet of internal/agent: darwin, linux and windows.
- gofmt -l clean. On mote: go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- Broken by hand, each turning its guard red: the lift gate
  (TestReadingKeepsARefusalsRest, TestAutoVisionKeepsOffARefusedAccount);
  the named-time condition (TestNamedQuotaTimeReplacesAGuess); the
  filter-chain hop (WholeReply/glm-5.3-flash); Edward's aAt
  (TestKeyAllowanceElapsedResetStartsAgain); and the old
  magpieMadeReasoning, which panics in TestMadeReasoningSaysItsTextOnce/
  no_summary. Every new test of gua's is red at base d307aa648.
Not tried: real OpenAI, DeepSeek, GLM or ChatGPT accounts; a real VS Code
1.144 install on Windows; a GUI run (no GUI files are touched).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 07:06:19 +08:00
..