Files
magpie/docs
yetone 6690caaaec gateway: auto mode's review isn't asked of another subscription's Claude model, and Claude Code's set model is judged where it goes
Claude Code 2.1.302 tells a session behind magpie "this session isn't
eligible because your requests go through 127.0.0.1:3425" and points the
gateway at code.claude.com/docs/en/auto-mode-classifier-billing. That
page asks a gateway to forward the dangerous-tool-use-2026-09-03 beta and
the top-level `safeguards` field, and to return `safeguard_results`
(message_delta.delta in a stream) with tool-use ids unchanged; one that
can't should have clients set CLAUDE_CODE_AUTO_MODE_SERVER=0. magpie
already does this on every route Anthropic answers (Claude subscription
bridge, api.anthropic.com, relays, Bedrock, Vertex) and writes the 0
when no reachable model is reviewed (24350a372). Only Anthropic can
produce safeguard_results, so for any other model the 0 is the remedy;
magpie never answers one on Anthropic's behalf.

Gap fixed here: AutoModeReviewed counted any claude-* name as reviewed,
so a Claude model on another vendor's subscription or a plugin (Copilot,
Kiro, Cursor…) was sent the beta and safeguards (Copilot 400s on them,
#1756) and counted as reviewed by the agent wiring, which then left
CLAUDE_CODE_AUTO_MODE_SERVER unset and the notice showing. Now an
account provider counts only when it is the Claude subscription or sits
on api.anthropic.com; providers with a key keep the name rule. And
claudeReviewed resolves the models Claude Code is set to (group,
provider, fallback) before judging them, as the gateway would, instead
of by name alone.

Tests: TestAutoModeReviewedRoutes (copilot/kiro/plugin cases),
TestAutoModeReviewLeftOffOtherSubscriptions,
TestClaudeReviewedJudgesTheSetModelWhereItGoes. Broken by hand: with
automode.go reverted, the first two go red (copilot/kiro/x-plugin true;
copilot beta+safeguards sent); with claude.go reverted, the third goes
red (v/gpt-x falling back to a/claude-sonnet-5 not reviewed).

Run at 2042123f4 + this change, sandbox HOME, load ~350:
- gofmt -l: clean. go vet ./... (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: clean.
- go test -timeout 45m ./...: 63 ok, 3 red, all filed and none in code
  this touches: internal/agent hit 45m (#2723, #2544); gateway's
  TestPluginStreamLargeReplies/JSON_fast hit its client timeout (#2551);
  gui's TestMainWindowCorners was killed at its deadline (#1936, #2645).
- Reruns alone: internal/agent -timeout 90m ok (2637s);
  TestPluginStreamLargeReplies ok; TestMainWindowCorners/macOS_26_SDK
  killed at 40s again at load ~200 (#1936).
After rebasing onto origin/main c4aeaec74 (6 commits, none in these
files): go vet of gateway and agent clean; TestAutoMode*,
TestSafeguards*, TestClaudeBridgeSafeguard* ok; the agent review tests
printed one bare FAIL whose output was cut off by tail, then passed
alone and -count=3 -v (all PASS); cause of that one FAIL not known.
Not run: a real Copilot/Kiro account through Claude Code (the agent test
covers the resolution with key providers; the account rule is covered
in the gateway unit tests), the GUI node suite (no GUI change).
2026-10-17 22:43:54 +08:00
..