Claude Code's deferred tools put tool_addition / tool_removal /
tool_reference blocks in a message. OpenCode Go's DeepSeek route answers
one defining a tool with a bare 422 "Upstream request failed: Endpoint is
unavailable.", which names nothing deferredRefused can learn from, so
every turn went out the same way and failed the same way. The reporter
checked it straight against opencode.ai/zen/go/v1/messages on 2026-10-15
(3/3 422 inline, 3/3 200 plain and with the definition in tools).
forwardOnce now drops the blocks for a Messages request to an OpenCode
host (p.IsOpenCode) whose model names deepseek, as it already did for Kimi
(#2042). Other OpenCode models and every other provider are sent the
blocks as Claude Code wrote them; no retry or fallback is added.
withoutDeferredTools assumed every tool was also in the top-level tools.
A tool defined only in a tool_addition's definition was dropped, so the
model could no longer call it; that held for Kimi too. Such a definition
now joins tools once, by name, a top-level definition of the same name
winning; ToolSearch's tool_reference inside a tool_result stays. A later
tool_removal is not applied to tools (out of scope, as before).
Run (go1.26 darwin/arm64, sandbox HOME, -p 1 -tags nogui):
go test ./internal/gateway -run 'TestOpenCodeDeepSeekInlineTools|
TestDeferredInlineDefinitionPreserved|TestKimiIsSentNoDeferredToolBlocks|
TestDeferredToolBlocksRefusedOnceLeftOut|TestOpenCodeGoModelsGoOnTheirOwnAPI|
TestRefsOnly|TestRefsSaid|Deferred' -count=1 -> ok, 14 pass
Broken by hand:
- forwardOnce's condition put back to isKimi alone:
TestOpenCodeDeepSeekInlineTools/go/deepseek-v4.1-flash fails with the
reporter's 422.
- withoutDeferredTools not writing tools back: both new tests fail
("inline definition was not preserved", "tools lost or duplicated").
gofmt -l clean. GOOS=windows and GOOS=linux go vet -tags nogui
./internal/gateway clean. Not run: other packages, the GUI suite (disk
had under 1 GB free); not tried against the real OpenCode Go endpoint through
magpie (the reporter's direct requests are the evidence).
Full suite: SUITE_LINE
Co-authored-by: cyh <2293985047@qq.com>