Codex continuing on a DeepSeek channel's Responses API, after a reply
that had no reasoning, sent a step with nothing to replay. magpie leads
such a step with a reasoning item holding " " and no id (noReasoningItem,
reasonFirst), which DeepSeek's own /v1/responses wants: without it it
refuses the request with "The `reasoning_text` in the thinking mode must
be passed back to the API" (#1822, #1592, #1687, checked on
api.deepseek.com 2026-10-12). The reporter's channel turns that item
away with 422 "Input tag 'reasoning' found using 'type' does not match
any of the expected tags: 'message', 'tool_result'", pydantic's words
for a tagged-union member it has no type for. It takes a reasoning item
with an id (its own, which Codex sends back), so only the id-less ones,
the " " and a translated turn's reasoning text, are refused. The 422
wasn't retryable, so a group stopped at that member.
What changed:
- idless_reasoning.go: idlessReasoningRefusal matches that message;
withoutIDlessReasoning drops reasoning input items without an id.
- gateway.go, relayed Responses: on that refusal the request is asked
once more without them, and once taken the provider/model is marked
(idlessReasoningRefused) and not sent one again. Items with an id go.
- gateway.go, translated to Responses: the same, through the build
loop (mark, rebuild, drop).
- fallback.go: "does not match any of the expected tags" is a shape
refusal (shapeWords), the same kind as xAI's "unknown item type": a
group's next member (DeepSeek's own API takes the item) is asked, and
the member doesn't rest. This only matters when the retry without the
items is refused too, or the member can't drop any.
- The placeholder itself is unchanged: an upstream that never refused it
(DeepSeek's own API) still gets it, so #1822 stays fixed.
- docs/subsystems/gateway-routing.md: the Responses replay paragraph.
Fixtures are the reporter's message, word for word, in FastAPI's detail
envelope and in OpenAI's error object (the reporter gave the message,
not the envelope).
Run:
- New tests: TestIdlessReasoningRefusedByChannel (relayed, both
envelopes, second request taken at once),
TestTranslatedIdlessReasoningRefusedByChannel (a Chat client
translated), TestGroupFailsOverIdlessReasoningRefusal,
TestIdlessReasoningKeptForDeepSeek, TestWithoutIDlessReasoning.
- Broken by hand: with gateway.go and fallback.go at origin/main
(idless_reasoning.go kept so the tests compile), the three refusal
tests fail with the reporter's 422 reaching the client;
TestIdlessReasoningKeptForDeepSeek passes, as it guards #1822.
- mote: go test ./internal/gateway -run with the tests above plus
TestDeepSeekStepSaysBeforeItsCall, TestGroupFailsOverARequestShape,
TestTranslatedDeepSeek*, TestWithReasoningText*: ok.
- mica (mote had a full suite running, load 24): go test -count=1
-timeout 45m ./... at 29cb2262a (this change on origin/main 31dcfcc33):
103 packages ok, exit 0. GOOS=linux and GOOS=windows go vet -tags
nogui ./...: ok. gofmt -l: clean.
- Rebased onto a5b797d8d (main gained image caps in internal/gateway
and provider, and sessions timings): mica, go test -count=1 -timeout
45m ./internal/gateway ./internal/provider ./internal/sessions at the
pushed tree: ok, ok, ok. gofmt -l: clean. The full suite above ran
at the earlier base. be6f8b730 (Zen through Bun: internal/provider
zen_bun.go, internal/netproxy) landed after that run and touches no
file here; it was not run again with this change.
Not tried: the reporter's channel itself (its URL isn't known), so the
id rule rests on the reporter's reading and their error text. A built
magpie end to end.