cybercaius on Discord (#help), v0.1.1862: Claude Desktop's connection
check failed with 'Gateway rejected model
"magpie-0958175816.anthropic.claude-haiku-5-5[1m]" (HTTP 400)', the body
'天翼云: {"error":{"message":"{\"code\":\"400\",\"message\":\"thinking.type
must be \\\"enabled\\\" …","type":"upstream_error",…}}'. 天翼云 is his own
provider, a relay whose message is its own upstream's whole body.
What was sent: Desktop's check ({"max_tokens":1,"messages":[{"role":
"user","content":"."}]}, raised to 16) asks for no thinking. Relayed to
a Messages provider, a vendor's model gets thinking {"type":"disabled"}
(thinkingOffUnlessAsked) and a Claude-named one none; translated to Chat
it gets no reasoning_effort. Nothing today changed that: no gateway
commit since yesterday touches what thinking is sent. What changed is
where the check goes: ee6f8866f sends it to Desktop's default (his
天翼云 group), and c30e2a645 (v0.1.1861) has it go by the group's order
instead of a classifier's pick, so the group's first member now gets
it. Why the refusal wasn't read: refusesThinkingOff knows a vendor
refusing thinking *off* (alwaysThinks, thinkingOffRefused, …), and its
retry only takes "disabled" out, which leaves thinking absent, still
not "enabled". Nothing knew an upstream that wants thinking enabled.
Now (thinking_needed.go): a 400 saying thinking.type must be enabled
(thinkingNeededRefusal, read off the reply, not the provider) is asked
again once thinking at Anthropic's least budget, 1024, max_tokens raised
past it by what was asked (16 -> 1040) and temperature/top_p/top_k
left out (withThinkingEnabled); markUnfit(thinkingNeeded) keeps the
model so until restart, so the next check or title goes thinking in
one call. Both routes: passthrough (relayed Messages), forwardTranslated
(Messages body once built; Chat/Responses at the lowest effort via
thinkingBackOn), and translate for a non-streaming client whose refusal
came in a 200 stream. forwardOnce doesn't turn such a model's enabled
into adaptive (a Claude 5.5 name would otherwise send adaptive and be
refused again). docs/subsystems/gateway-routing.md says so.
Test: TestClaudeDesktopProbeThinkingNeeded, Desktop's literal check on
the literal id through a 天翼云 group to a fake that answers the
reported body (wrapped as the relay wraps it) whenever thinking.type
isn't "enabled": a vendor model and a Claude name on Messages, Chat
with the refusal as a 400 and inside a 200 stream. Each: 200 in two
calls, the retry carrying enabled/1024 under max_tokens > 1024, then the
next check and a title in one call. TestWithThinkingEnabled.
Run (mote, at this tree): the tests above; go test -tags nogui
./internal/gateway/ (whole package): ok (537s); gofmt -l clean;
go vet ./internal/gateway/ for darwin, linux, windows: ok.
The package run was at d6df72a2b plus this change; rebased on
51247a55b (0b99b8fbe touched internal/gateway), the new tests with
-run 'Desktop|Thinking|ThinkOff|Translated|LoopGuard': ok.
Broken by hand (each red on mote):
- gateway.go as on origin/main: all four subtests 400 with the reported
message, byte for byte in its shape;
- adaptiveThinking not skipped: the Claude-name subtest red (sent
thinking adaptive);
- the in-stream retry in translate off: the stream subtest red;
- the memory off (upfront thinking in passthrough and
forwardTranslated): every subtest red ("after: 200 in 2 calls", or
400 once the retry's own fits check stops it).
Not tried: the reporter's real 天翼云 relay, or which API it is on
(Messages or Chat) — the reply shape fits both, both covered; a relay
that turns reasoning_effort into thinking (the Chat cases assume it);
a streaming client's refusal inside a 200 stream (only the
non-streaming one, Desktop's check, is asked again); a real Claude
Desktop. Not run: the full ./... suite.