What: joinToolRuns (responses.go), which mends a relayed Responses
request's tool runs in attempt before every destination, now moves an
assistant message the model wrote between its own calls, before the run's
first result, to just ahead of the run's first call, together with the
reasoning items right before it (so a reasoning item keeps the item that
followed it). The reporter's Codex rollout was
[text, call_A, text, call_B, out_A, out_B]; it reaches the upstream as
[text, text, call_A, call_B, out_A, out_B]. Reasoning alone between calls,
hosted calls and anything carrying a call_id stay where they were (#1752's
review note), and V2 (text after out_A, between whole exchanges) and V3
(calls together) go byte for byte.
Why: magpie relays deepseek-v4.1-flash at OpenCode Go to its /responses
(models.dev names no SDK for it, so every API may be tried, and #1822's
turn shows Go's DeepSeek answering there). Go builds a chat form in which
an assistant message after a call opens a new assistant message, so the
first one's tool_calls were followed by no tool message: 400 "No tool
output found for tool call call_aaaa1111" - the same text joinToolRuns'
comment already lists for Go. The translation to a Chat upstream was
already right on main (joinSplitCalls + mergeTurns join the step into one
assistant message); TestTextBetweenABatchsCallsStaysInItsStep now guards
it with the reporter's shape. Native ChatGPT sign-ins don't go through
joinToolRuns. Moved plugins get the relayed body after attempt, so they
get the change too; no plugin translator was touched.
Run:
- TestRelayedTextBetweenABatchsCallsIsAnswered (V1-V4, fake upstream that
checks the exchange as Go does) and the new TestJoinToolRunsOnlyMoves...
cases fail on origin/main 2fbbd1694 with the fix stashed: V1 and V4
"status 400: Fake: No tool output found for tool call call_aaaa1111",
and got [function_call:a function_call:b message: ...] want
[message: function_call:a ...]; pass with it.
- gofmt -l clean; go vet ./internal/gateway (darwin), GOOS=linux -tags
nogui, GOOS=windows: clean.
- go test -tags nogui ./internal/gateway/... under a scratch HOME with
pinned caches: ok (2011s at load ~230; a first run with the default
10m -timeout was killed by the timeout under that load, not a failure).
Not tried: the real OpenCode Go. The key on this machine answers "This Go
model requires Global regions" / "An active OpenCode Go subscription is
required" for every Go model, and Zen's free tier refuses non-OpenCode
clients, so the fix rests on the reporter's V1-V4 table and the fake.