Files
magpie/docs
yetone 5d24bc6ccd gateway: every thinking block a Messages client gets says its signature (Grok Build on MiniMax)
uk.jent (Discord): Grok Build on minimax-code-global/MiniMax-M3.1-Flash
showed "Couldn't read the response: serialization error: missing field
`signature`". Grok Build (grok 1.0.67, Rust/serde) reads a Messages
thinking block as ContentBlock::Thinking {thinking, signature}, both
required, so one block without the field fails the whole reply.

Cause, two routes:
- Relayed: MiniMax's Anthropic-compatible endpoint writes thinking blocks
  with no signature (its docs name only type/thinking/thinking_delta), and
  passthrough gave them to the client as they came.
- Translated: anthropicEncoder.thinking opened the block with no
  signature (renderAnthropic and whole_stream.go already wrote one).

Fix:
- anthropicEncoder starts a thinking block {"thinking":"","signature":""},
  as Anthropic's own stream does.
- sigFieldTidy (thinking_signature.go), chained in passthrough for the
  Anthropic protocol, gives a relayed thinking block with no signature (or
  a null one) an empty string: a stream's content_block_start line or a
  whole reply's content[]. A signed block goes byte for byte;
  redacted_thinking is untouched. magpie never makes up a signature: an
  empty one is no signature to anthropicBody, which leaves the block out
  for Anthropic and keeps only its text where reasoning is replayed.
- docs/subsystems/gateway-routing.md says the rule.

Fixtures are built from MiniMax's documented shape, not real bytes: there
is no MiniMax Code account here.

Run (mote, at this rebased head on origin/main 033b17baf): gofmt -l,
go vet ./internal/gateway, go test -run
"Thinking|Signature|Signed|SigFieldTidy|SigTidy|Anthropic|Messages|Passthrough|Relay"
./internal/gateway: ok. Before the rebase: go vet (darwin, GOOS=linux
-tags nogui, GOOS=windows) and go build for all three: ok.
Broken by hand: with gateway.go and anthropic.go back at the old code,
TestMessagesThinkingIsSigned's relayed stream, relayed whole and
translated stream go red ("thinking block has no signature string");
translated whole was already signed and stays as a guard. With the
filter made to rewrite signed blocks, both cases of
TestSignedThinkingRelayedAsItCame go red.
Full suite: `go test -tags nogui ./... -timeout 45m` is still running on
mote (load ~340, five suites from other sessions); pushed now by the
owner's ship-immediately rule, any red it names is filed and fixed
forward.
Not tried: a real MiniMax reply; whether MiniMax accepts "signature":""
back in history; a real Grok Build run.
2026-10-29 15:20:54 +08:00
..