ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a6a99717e0 |
gateway: thinking with no signature never goes to Claude
citricdu (Discord, 0.1.3356): Claude Code auto-compacted a session on a
Smart group that had moved to Cursor's Grok 4.7, then the group went
back to Kiro's Claude Opus 5.5. The compacted history kept a thinking
block Grok made, which magpie hands a Messages client signed "", and
Kiro answered 13 times in a row with a bare invalid_request_error. The
same request without the block was answered.
withoutForeignThinking dropped only DeepSeek's UUID-signed blocks and
kept an empty signature on purpose ("a block with no signature Claude
takes"), and Kiro's refusal names nothing boundRefusal reads, so
refuseBoundThinking never mended it. Now every thinking block whose
signature is empty, blank or missing is left out for an upstream
serving Claude (api.anthropic.com, or a claude- model: relays, Bedrock
and Vertex ids, a plugin's fetch such as Kiro's), on every route
forwardOnce takes (relayed, translated, plugin, count_tokens), and
refuseBoundThinking runs it too. Text, tool_use and tool_result stay;
Claude's own signed thinking and redacted_thinking are untouched. A
model that learned thinkingBackNeeded (DeepSeek under another name)
keeps its unsigned blocks. Chat and Responses translated into Messages
already dropped unsigned thinking in anthropicBody.
Tests: TestUnsignedThinkingNotSentToClaude builds the reporter's shape
(the compaction summary, then two tool turns opening with Grok's
thinking signed "") against a fake Kiro that gives the same bare 400,
relayed and through the fake plugin's fetch (FAKE_KIRO model added).
TestGrokThinkingThenClaude runs the switch itself: a group answered by
a Chat Grok, then moved to Claude mid tool loop.
TestWithoutForeignThinking adds an unsigned block, Bedrock and Vertex
ids, a missing and a blank signature.
Run (mote, at this head rebased on
|
||
|
|
f3335dd1b4 |
gateway: DeepSeek's thinking is left out of a request to Claude (GgbondHi6930 on X)
GgbondHi6930 on X: a Smart group of DeepSeek and a Claude API key. A conversation ran on DeepSeek at max effort; with DeepSeek unticked its next turn went to Claude and failed "signature in thinking". A new conversation worked. Cause: DeepSeek's Anthropic endpoint signs each thinking block with its reply's id, a UUID (checked against api.deepseek.com/anthropic). The agent keeps those blocks and sends them back, so the first Claude turn carries them, and Claude refuses the request, 400 "messages.1.content.0: Invalid `signature` in `thinking` block" (real reply through OpenRouter's Anthropic route, req_011CgfP4zyRcUhPiTg5sLpoe). Until now magpie mended this only after the refusal, in forward's bound-thinking retry. That needs the refusal to reach forward as a 400/422 with Claude's wording, and it spends a request. With fakes that answer as Claude does, main recovers through it, on Messages (whole and streamed) and on Codex's Responses. So the reporter's failure is where that retry can't read the refusal. A relay's status or wording is the likely case; it is not reproduced exactly. Change: forwardOnce, which every route to an Anthropic upstream passes (relayed, translated Chat/Responses, group fallback and Smart routing, a plugin's fetch, count_tokens), now calls withoutForeignThinking. For an upstream serving Claude (api.anthropic.com, or a claude- model name) and not DeepSeek, it leaves out each thinking block whose signature is a UUID. Those blocks never reach Claude, and refuseBoundThinking reads a refusal's indices against that same body. These go byte for byte: - Claude's own signatures (base64; 3,000 of Claude Code's own were checked, all base64 and 800+ characters); - unsigned blocks (Claude took one in a real request); - redacted_thinking; - other vendors' signatures, which the retry still mends. DeepSeek's endpoint and every other upstream get the body unchanged. Tests (thinking_switch_test.go): - TestDeepSeekThinkingThenClaude: the reporter's case, whole and streamed. 3 DeepSeek tool turns, then DeepSeek unticked and 3 Claude turns. Claude refuses nothing and gets its own blocks back as signed. With DeepSeek ticked again and Claude unticked, DeepSeek is sent every block, its own and Claude's. - TestDeepSeekThinkingThenClaudeResponses: the same through Codex's /v1/responses. - TestWithoutForeignThinking: Claude, DeepSeek and Kimi upstreams. Run on mote (mote-run): - gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: clean, at cfa9a6987 (base |