thinkingOffUnlessAsked turns thinking off on a Messages request for a
non-Claude model that doesn't mention it. Kimi Code (China)'s K3.1
(k3.1-pro, k3.1-pro-highspeed) refuses that with 400, "K3.1 Pro does not
support disabled thinking mode. Please enable thinking and try again, or
choose another model.", in a wording neither alwaysThinks,
mandatoryReasoning nor thinkingOffRefused matched, so the 400 went back
to the client on every request that carried no thinking — ZCode's, which
asks for a level as output_config.effort and sends no thinking — and the
session could not start. withoutThinkingOff would have handled it; only
the match missed, as in #1141.
alwaysThinks now matches Kimi's literal sentence. Both retry sites use
it: the relayed Messages path (withoutThinkingOff, gateway.go) and the
translated Chat/Responses path (thinkingBackOn).
Tests: TestAnthropicPassthroughKimiThinkingOffRefused (the reporter's
error body: omitted thinking succeeds after one retry without thinking;
adaptive goes once, as sent; Kimi's own max_tokens 400 and a near wording
"tool use is not supported by this model" are not retried), and
TestTranslatedThinkingOffRefused now runs Kimi's wording. With the regex
change reverted both fail (400 handed back).
Review and run record (landed by the maintainer's agent; gua2100 brought
both fixes from Discord, rebased onto main):
- External code, read line by line: no network, dependency, workflow or
credential change; Codex base_instructions/identity untouched.
- Base origin/main d99e213f5. Full checks on mote (macOS, Go 1.26.8,
sandbox HOME) at 31f025634, whose tree is the one pushed (only messages reworded since): gofmt, go vet darwin, linux,
windows, builds for all three: rc=0. go test -tags nogui -count=1
-timeout 45m ./...: 79 packages ok, internal/gateway ok (855s); two reds
in untouched packages, both filed before: internal/plugin
TestGatewayHookMixedPiPackage (#2865, "starting plugins: context deadline
exceeded") and internal/update TestRelaunchOpenTriedAgain (#3881). Run
alone at the same tree both pass (plugin 97s; update -count=3).
- Broken by hand: the #3739 regex reverted, so both Kimi tests fail (400
handed back). The #2532 product files reverted (six files), so all three
tests fail. The mergeTurns role guard removed fails (5 input messages,
want 7).
- Real binary on mote, sandbox HOME, a fake upstream that records requests:
at d99e213f5, wrke1990's literal #2532 body sends Plan in instructions
and Default as a user <system-reminder>; at HEAD both developer items
keep their role and place. #3739's curl body (and zfsdream96's ZCode
shape, output_config effort max, no thinking) is a 400 at d99e213f5; at
HEAD it is a 200 after one retry without thinking, and the next
request goes without disabled.
- Rebased onto fa427216a (responses.go stream deltas, landed meanwhile;
no conflict). At the rebased pushed tree: gofmt, go vet and
go test -count=1 ./internal/gateway ok (580s) on mote. The full suite
was not rerun after that rebase.
- Not covered: the search reroute's re-parse when a fallback changes
whether the target is Responses (breaking it leaves the tests green;
no route found that reaches it). Not tried: the real Kimi Code
endpoint and its kimi-code-cn preset (a custom Anthropic provider with
Kimi's literal 400 was used), a real Codex session against a paid
upstream, Windows/Linux runtime. #3739's second symptom (k3 losing
thinking when output_config.effort is asked) is not addressed.
Generated-by: GLM-5.3-Flash (ZCode)