From 8c652a83f738af214bb0c99ff76ba6384eaede95 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 3 Oct 2026 18:39:29 +0800 Subject: [PATCH] =?UTF-8?q?antigravity:=20its=20429=20to=20Claude=20Code's?= =?UTF-8?q?=20system=20prompt=20says=20it=20isn't=20a=20quota=20(#666:=20C?= =?UTF-8?q?laude=20Desktop=20=E8=B0=83=E7=94=A8=20antigravity=20=E6=81=92?= =?UTF-8?q?=E5=AE=9A=E6=8A=A5=20429)=20=E2=80=94=20Antigravity=20answers?= =?UTF-8?q?=20"Resource=20has=20been=20exhausted=20(e.g.=20check=20quota)"?= =?UTF-8?q?=20to=20any=20request=20whose=20systemInstruction=20holds=20Cla?= =?UTF-8?q?ude=20Code's=20billing=20line=20(x-anthropic-billing-header:=20?= =?UTF-8?q?=E2=80=A6)=20or=20the=20Agent=20SDK's=20identity=20line=20(You?= =?UTF-8?q?=20are=20a=20Claude=20agent,=20built=20on=20Anthropic's=20Claud?= =?UTF-8?q?e=20Agent=20SDK.),=20on=20every=20model=20(gemini-3.8/3.7=20fla?= =?UTF-8?q?sh,=203.5=20flash=20lite,=202.5=20flash,=20claude-sonnet-4-6,?= =?UTF-8?q?=20gpt-oss),=20whatever=20the=20quota=20left,=20while=20the=20s?= =?UTF-8?q?ame=20words=20in=20a=20message=20go=20through.=20Claude=20Deskt?= =?UTF-8?q?op's=20chats=20run=20the=20Agent=20SDK=20and=20carry=20both,=20?= =?UTF-8?q?so=20they=20always=20failed,=20while=20its=20title=20requests?= =?UTF-8?q?=20(no=20system=20prompt)=20and=20Codex=20on=20the=20same=20acc?= =?UTF-8?q?ount=20answered.=20Not=20the=20session=20id=20(magpie=20already?= =?UTF-8?q?=20sends=20request.sessionId=20as=20-),=20thinking=20si?= =?UTF-8?q?gnatures=20(never=20sent=20back)=20or=20the=20User-Agent.=20mag?= =?UTF-8?q?pie=20doesn't=20hide=20the=20lines=20from=20Google;=20the=20gat?= =?UTF-8?q?eway=20now=20adds=20to=20such=20a=20429=20that=20it=20is=20no?= =?UTF-8?q?=20quota=20and=20that=20Antigravity=20turns=20away=20Claude=20C?= =?UTF-8?q?ode's=20and=20the=20Agent=20SDK's=20system=20prompt,=20so=20no?= =?UTF-8?q?=20one=20chases=20a=20quota.=20Reproduced=20on=20the=20owner's?= =?UTF-8?q?=20real=20Antigravity=20account=20with=20Claude=20Code=202.1.28?= =?UTF-8?q?8=20through=20a=20sandbox=20gateway=20(11/11=20429;=20system=20?= =?UTF-8?q?field=20removed=20200;=20either=20line=20alone=20429).=20TestAn?= =?UTF-8?q?tigravityTurnsAwayClaudeCodesSystemPrompt.=20go=20vet,=20builds?= =?UTF-8?q?=20(darwin,=20GOOS=3Dlinux,=20GOOS=3Dwindows)=20and=20go=20test?= =?UTF-8?q?=20-tags=20nogui=20-count=3D1=20./...=20under=20a=20temp=20HOME?= =?UTF-8?q?=20pass.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/antigravity_turned_away_test.go | 32 +++++++++++++++++++ internal/gateway/codeassist.go | 14 ++++++++ internal/gateway/gateway.go | 3 ++ 3 files changed, 49 insertions(+) create mode 100644 internal/gateway/antigravity_turned_away_test.go diff --git a/internal/gateway/antigravity_turned_away_test.go b/internal/gateway/antigravity_turned_away_test.go new file mode 100644 index 000000000..b9d2a16a5 --- /dev/null +++ b/internal/gateway/antigravity_turned_away_test.go @@ -0,0 +1,32 @@ +package gateway + +import "testing" + +// Antigravity answers a 429 "Resource has been exhausted (e.g. check +// quota)" to Claude Code's and the Agent SDK's system prompt whatever the +// quota left (#666: Claude Desktop's chats always 429, its titles and +// Codex on the same account fine); magpie says so rather than leave a user +// chasing a quota. Both lines are as Claude Code 2.1.288 sends them. +func TestAntigravityTurnsAwayClaudeCodesSystemPrompt(t *testing.T) { + for _, system := range []string{ + "x-anthropic-billing-header: cc_version=2.1.288.e3f; cc_entrypoint=sdk-cli;\nYou are Claude Code, Anthropic's official CLI for Claude.", + "You are a Claude agent, built on Anthropic's Claude Agent SDK.\n\nYou are an interactive agent …", + "Some instructions first.\nYou are a Claude agent, built on Anthropic's Claude Agent SDK.", + } { + if !antigravityTurnsAway(system) { + t.Errorf("%q isn't taken for what Antigravity turns away", system) + } + } + // what it lets through: other agents', Claude Code's own name alone, + // and no system prompt at all (Claude Desktop's title requests) + for _, system := range []string{ + "", + "You are a helpful assistant.", + "You are Claude Code, Anthropic's official CLI for Claude.", + "You are Codex, based on GPT-5.", + } { + if antigravityTurnsAway(system) { + t.Errorf("%q is taken for what Antigravity turns away; it answers it", system) + } + } +} diff --git a/internal/gateway/codeassist.go b/internal/gateway/codeassist.go index 5fc43ef57..1270504db 100644 --- a/internal/gateway/codeassist.go +++ b/internal/gateway/codeassist.go @@ -38,6 +38,20 @@ func accountAgent(p provider.Provider) string { return p.Account.Agent } +// antigravityTurnsAway: a system prompt Antigravity answers with a 429 +// "Resource has been exhausted (e.g. check quota)" whatever the quota left, +// the one Claude Code and its Agent SDK (Claude Desktop's chats) send: its +// billing line or the SDK's identity line anywhere in the system +// instruction turns the request away, on every model, while the same words +// in a message go through (#666). magpie doesn't hide them from Google; it +// says why, so no one chases a quota that isn't spent. +func antigravityTurnsAway(system string) bool { + return strings.Contains(system, "x-anthropic-billing-header:") || + strings.Contains(system, "built on Anthropic's Claude Agent SDK") +} + +const antigravityTurnedAwayHint = "not a quota: Antigravity turns away Claude Code's and the Claude Agent SDK's system prompt (Claude Code, Claude Desktop's chats) with this 429; use another provider for them" + // codeAssistID is the id a request on the account's app goes out under: on // Antigravity the variant the effort picks for a model that is a family of // levels, and elsewhere the model magpie knows. It is keyed by the account diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go index 9db66c42e..e0ae65ead 100644 --- a/internal/gateway/gateway.go +++ b/internal/gateway/gateway.go @@ -2865,6 +2865,9 @@ func (s *Server) translate(w http.ResponseWriter, r *http.Request, p provider.Pr if res.StatusCode >= 400 { b, _ := io.ReadAll(io.LimitReader(res.Body, 1<<20)) msg := p.Explain(p.Name+": "+provider.APIError(b, res.Status), res.StatusCode, b) + if res.StatusCode == http.StatusTooManyRequests && accountAgent(p) == "antigravity" && antigravityTurnsAway(request.System) { + msg += " — " + antigravityTurnedAwayHint + } if p.Preset == "openrouter" && openRouterSharedPool(b) { markOpenRouterSharedPool(w) }