Files
magpie/docs
yetone 4af0f05cff gateway: a tool_reference an Anthropic-compatible endpoint refuses goes as text (emilochen on X)
Claude Code through magpie to DeepSeek V4.1 on an Anthropic-compatible URL
got 400 "DeepSeek V4.1 supports text and image content only; got
'tool_reference'": ToolSearch's answer is a tool_result holding
tool_reference blocks, which magpie relayed as written to every Messages
upstream (only a references-only result got a text block beside them,
#2124; DeepSeek's own API and Kimi lose only the top-level deferred blocks).

A 400/422 that refuses tool_reference in words (refsRefused: a refusal word
in the same clause, no brace between, so an echoed request doesn't count,
and DeepSeek's "expected `tool_reference`" doesn't either) while the request
as sent holds one in a tool_result marks shapeRefs. That request is asked
again at once, and every later one to that provider goes, with each
reference as "Tool <name> is loaded and can be called now." (the words
stringOrText already gives Chat, Responses and Gemini upstreams) and the
named tools without defer_loading; other deferred tools stay deferred, and
the tool_use/tool_result pairing stays (withRefsAsText). It sits in forward's
shape loop, so /v1/messages, count_tokens and group members all get it.
deferredOutUpFront names forwardOnce's existing up-front strip (Kimi,
DeepSeek's own API, OpenCode DeepSeek) so refuseShapes judges the body as
sent. Translated routes already carried the references as text
(TestToolSearchReferenceIsTold), so only the Messages passthrough changed.

Run (mote, -tags nogui, at origin/main 11ab58c58 + this): gofmt -l clean;
go vet gateway+catalog for darwin, linux, windows; go test catalog; go test
gateway -run ToolReference|RefsAsText|RefsOnly|RefsSaid|Deferred|DeepSeek|
ToolResultDefinition|NestedToolResult|ToolSearch|LoadedTools|Kimi|Shape|
Display|TurnEffort|Safeguards: ok.
Broken by hand: with mark(shapeRefs) taken out, TestToolReferenceRefusedGoesAsText
is red.
Not tried: the reporter's real endpoint (the refusal body is built from the
words in the tweet; its JSON shape is a guess, the match is on the words).
2026-11-13 14:55:15 +08:00
..