Files
magpie/internal
yetoneandggbdpq fbbdf6e056 claude: a turn Anthropic refuses as a third-party app's says why, and isn't asked again (#4503)
Anthropic answers some Claude subscription turns with "API Error: 400
Third-party apps now draw from your extra usage, not your plan limits.
Add more at claude.ai/settings/usage and keep going." isjiajia01's
controlled tests show when: Claude Code's interactive mode (the cli
entrypoint) carrying a client agent's own system prompt, such as Pi's,
gets the 400, and claude -p is served the same prompt. sounfury saw the
same thing on 0.1.2586 (Pi refused, Eta served, same Pro account). Until
now the client got that bare 400, which says "keep going" and doesn't
say why, and the log said only "exit status 1".

The client still gets the 400, followed now by magpie's explanation:
Anthropic counted the turn as a third-party app's and answered nothing.
It ran in the interactive mode with the agent's own system prompt.
Asking again the same way may draw from the Claude account's extra
usage, so magpie doesn't ask again on its own. claude -p is served such
prompts: turn off "Claude Code's interactive mode" in Settings › Models
› Replies or in the provider's editor. The plan counts a -p request at
about twice the interactive mode's. A claude -p run that gets the same
refusal says so, without the advice to turn the mode off. The log names
the refusal and its mode, and every run's start and end lines now say
"interactive mode" or "claude -p".

The owner decided this on #4503. ggbdpq's patch redid such a turn once
as claude -p, at about twice the plan's count, without asking. This
commit keeps the patch's detection (thirdPartyWords) and its fake
interactive Claude Code harness, and drops the automatic redo. The
explanation stays clear of quotaWords, so the refusal remains a 400
about the request: no account rests for it, and the next account isn't
asked.

Run on mote at a3768cdd1 plus this change:
- go test ./internal/gateway -run 'TestClaudeTUI|TestClaude.*Refus|TestBridgeFailed|TestClaudeTooLong' -count=1: ok
- the new tests and TestClaudeTUIRefusalIsNoAccountsFault, -race -count=3: ok
- gofmt -l internal/: clean
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok

New tests: TestClaudeTUIThirdPartyRefusalSaysWhy (whole and stream: a
400 with the explanation in both msg and body, the helper started once,
one run only so no -p redo, not retryable, failure() not
credit/quota/rate/auth) and TestClaudeThirdPartyRefusalOfPrint.

Broken by hand: with thirdPartyRefused returning msg unchanged, both new
tests went red. With req.interactive never set,
TestClaudeTUIThirdPartyRefusalSaysWhy went red.

Not tried: a real Claude Pro account getting the refusal. The refusal
line is the reporters' wording, played back by a fake Claude Code; the
exact stream-json shape of a real one wasn't captured. The full
./internal/gateway suite and ./... weren't run here.

Reported-by: isjiajia01, sounfury
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-03 05:08:39 +08:00
..
…
…
…
…
…
…