antigravity: Codex's GPT-5 line goes reworded in a user's turn too

@daoche_wuzui (X, v0.1.4131, Antigravity Cloak 0.1.7) still got 429s on
Antigravity. Since 11-14, Google answers a bare 429 "Resource has been
exhausted (e.g. check quota)" when either of Codex's identity lines
("You are Codex, an agent based on GPT-5" / "You are Codex, a coding
agent based on GPT-5") is in a user turn. The plugin, the cloak
middleware and the gateway reworded system/developer text only. A
mid-thread developer item becomes a user "<system-reminder>" message in
responses.go, and a pasted AGENTS.md does the same, so the line reached
Google in a user turn as written.

Real account, gemini-3.8-flash, plugin fetch directly:
- each Codex line in a user turn: 429 3/3; reworded "built on GPT-5": 200 3/3
- billing header, Agent SDK, Claude Code, Hermes and RFC lines in a
  user turn: 200 3/3 each, so only Codex's two lines are reworded there
- Codex line in the model turn or a functionResponse: 200, left as is
- "You are Codex." alone, "based on GPT-5" alone: 200
So the refusal is about the content, not the account or the model.

Through a sandbox magpie (sandbox HOME, port 3476), plugin 0.1.12 +
cloak 0.1.7, /v1/messages with the line in a user turn: 429 3/3
"Antigravity: Resource has been exhausted". With 0.1.13 + 0.1.8 in place
and the plugin host restarted: 200 3/3. A real Claude Code and a real
Codex request capture still 200 2/2.

- gateway: codeAssistBody rewords Codex's two lines in non-model turns
  for an Antigravity account (antigravityCloakMessages), on a copy; Gemini
  CLI accounts and prompt=as-written go untouched.
- mover min 0.1.12 -> 0.1.13 (plugins fb7bbebd: plugin 0.1.13, cloak
  0.1.8; both in the dist branch's index.json, checked after publish run
  43566168677; its npm job is red on middleware-system-prompt only,
  plugins#887).

Run on mica at e0f856ec0 (this change on origin/main 0caa09b3d):
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/provider/: ok (gateway 1103s, provider 142s)
- GOOS=linux and GOOS=windows go vet of both packages: ok
- gofmt -l: clean
At the pushed head, rebased onto 13cb07fde (codexcat compaction windows,
internal/gui): go vet of gateway, provider and codexcat; go test -run
'Antigravity|Cloak|CodeAssist|TurnedAway|Mover|Migrat' of gateway and
provider, and codexcat whole: ok.
Plugins at fb7bbebd's tree (before its rebase onto 09c05dfa, a
trae-only change): root bun test with a temp HOME, 8781 pass 0 fail.

Broken by hand: with antigravityCloakMessages's call removed,
TestAntigravityCloaksTheLineInAUsersTurn goes red. In the plugins,
without the user-turn cloak the shape test (1) and cloak cases (5) go red.

Not tried: the reporter's own agent and prompt (they didn't say which);
a real Codex CLI session driving Antigravity end to end; the GUI
(untouched). Not changed: antigravityTurnedAway/Foreseen still judge
the uncloaked system prompt, which can call a real quota 429 "turned
away" and skips the account for 6h (#6613).
This commit is contained in:
yetone
2026-11-14 14:57:33 +08:00
parent 13cb07fde7
commit 3e38e4ba21
3 changed files with 110 additions and 4 deletions
@@ -425,3 +425,45 @@ func TestAntigravityCloakLineWrappedOrWidened(t *testing.T) {
}
}
}
// Codex's GPT-5 line in a user's turn, where a pasted AGENTS.md or a
// developer message told after a reply puts it, goes to an Antigravity
// account reworded: since 11-14 Google answers it there with the same bare
// 429 (3 of 3 on a real account). The model's own turns, the caller's
// request and every other account keep it as written.
func TestAntigravityCloaksTheLineInAUsersTurn(t *testing.T) {
said := "You were told: " + codexGPT5System
// the lines Google let through in a user's turn go as written there
others := "x-anthropic-billing-header: cc_version=2.1.316.2e4;\nYou are a Claude agent, built on Anthropic's Claude Agent SDK.\n" + hermesOldSystem + "\nRFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."
r := &Request{Messages: []Message{
{Role: "user", Parts: []Part{{Kind: Text, Text: others}}},
{Role: "user", Parts: []Part{{Kind: Text, Text: "hi"}, {Kind: Text, Text: "<system-reminder>\n" + said + "\n</system-reminder>"}}},
{Role: "assistant", Parts: []Part{{Kind: Text, Text: said}}},
{Role: "user", Parts: []Part{{Kind: Text, Text: said}}},
}}
ag := provider.Provider{ID: "antigravity", Account: &provider.Account{Agent: "antigravity"}}
b := string(codeAssistBody(ag, r, "gemini-3-flash", nil))
if n := strings.Count(b, "based on GPT-5"); n != 1 {
t.Fatalf("Antigravity's account was sent the line %d times, want once (the model's turn): %s", n, b)
}
if n := strings.Count(b, "built on GPT-5"); n != 2 {
t.Fatalf("the user's turns went reworded %d times, want 2: %s", n, b)
}
if !strings.Contains(b, `"text":`+string(mustJSON(others))) {
t.Fatalf("lines Google lets through in a user's turn were changed: %s", b)
}
for i, m := range r.Messages[1:] {
if !strings.Contains(m.Parts[len(m.Parts)-1].Text, "based on GPT-5") {
t.Fatalf("the caller's message %d was changed: %+v", i, m)
}
}
gemini := provider.Provider{ID: "gemini-cli", Account: &provider.Account{Agent: "gemini"}}
if b := string(codeAssistBody(gemini, r, "gemini-3-flash", nil)); strings.Count(b, "based on GPT-5") != 3 {
t.Fatalf("Gemini CLI's account was sent %s", b)
}
asWritten := ag
asWritten.PromptAsWritten = true
if b := string(codeAssistBody(asWritten, r, "gemini-3-flash", nil)); strings.Count(b, "based on GPT-5") != 3 {
t.Fatalf("prompt=as-written was sent %s", b)
}
}
+67 -3
View File
@@ -52,9 +52,9 @@ func accountAgent(p provider.Provider) string {
// antigravityTurnsAway: a system prompt Antigravity answers with a 429
// "Resource has been exhausted (e.g. check quota)" whatever the quota left:
// one that carries a line of agTurnedAway anywhere in the system
// instruction, in any case, is turned away on every model, while the same
// words in a message go through (#666). magpie rewords those lines before
// they go (antigravityCloak); this still tells the refusal for what it is
// instruction, in any case, is turned away on every model (#666), and since
// 11-14 Codex's GPT-5 line in a user's turn too. magpie rewords those lines
// before they go (antigravityCloak, antigravityCloakMessages); this still tells the refusal for what it is
// when the user has the prompt sent as written, or Google turns away a copy
// someone broke up with invisible characters, so no one chases a quota that
// isn't spent.
@@ -249,12 +249,36 @@ func antigravityCloak(system string) string {
if !antigravityTurnsAway(system) {
return system
}
return agCloakLines(system, nil)
}
// agUserTurnedAway are the lines of agTurnedAway Antigravity also turns
// away in a user's turn: since 11-14 Codex's GPT-5 lines there got a bare
// 429 "Resource has been exhausted" 3 of 3 on a real account, where a
// pasted AGENTS.md or a developer message told after a reply
// (<system-reminder>) puts them, and went through reworded. The others went
// through as written there, 3 of 3 each, and so did all of them in the
// model's turns and in tool results.
var agUserTurnedAway = func() []bool {
only := make([]bool, len(agTurnedAway))
for i, line := range agTurnedAway {
only[i] = strings.HasPrefix(line, "you are codex, ")
}
return only
}()
// agCloakLines is antigravityCloak over the lines of agTurnedAway only says
// to reword, or over all of them when only is nil.
func agCloakLines(system string, only []bool) string {
type match struct {
from, to int
as func(string) string
}
var at []match
for i, re := range agTurnedAwayRes {
if only != nil && !only[i] {
continue
}
for _, m := range re.Regexp().FindAllStringIndex(system, -1) {
at = append(at, match{m[0], m[1], agSaidAs[i]})
}
@@ -275,6 +299,41 @@ func antigravityCloak(system string) string {
return b.String()
}
// antigravityCloakMessages is msgs with each line of agUserTurnedAway in
// the text of a user's turn said as agSaidAs says, and whether any was. The
// model's own turns, tool results and every other line are left as they
// are, and msgs itself is never changed.
func antigravityCloakMessages(msgs []Message) ([]Message, bool) {
var out []Message
for i, m := range msgs {
if m.Role == "assistant" {
continue
}
var parts []Part
for j, pt := range m.Parts {
if pt.Kind != Text {
continue
}
t := agCloakLines(pt.Text, agUserTurnedAway)
if t == pt.Text {
continue
}
if parts == nil {
parts = slices.Clone(m.Parts)
}
parts[j].Text = t
}
if parts == nil {
continue
}
if out == nil {
out = slices.Clone(msgs)
}
out[i].Parts = parts
}
return out, out != nil
}
// antigravityRefuses is what Antigravity says when it turns such a request
// away, on either shape the refusal arrives in: a 429's body, or the reply's
// own error event, where the Code Assist decoder keeps the message and leaves
@@ -408,6 +467,11 @@ func codeAssistBody(p provider.Provider, r *Request, model string, wires map[str
rc.System = cloaked
r = &rc
}
if msgs, ok := antigravityCloakMessages(r.Messages); ok {
rc := *r
rc.Messages = msgs
r = &rc
}
}
body := buildCodeAssistSent(r, sent, p.Account.Agent)
if wire := provider.UpstreamNameAsIn(wires, p.ID, model, sent); wire != sent {
+1 -1
View File
@@ -16,7 +16,7 @@ import (
func init() {
movers["antigravity"] = &mover{
pkg: "@magpie-community/opencode-antigravity-auth",
min: "0.1.12", // every turned-away line goes reworded, not broken up: Google reads past zero-width since 11-14 (0.1.11 omp's "key words", 0.1.0 ported the built-in)
min: "0.1.13", // Codex's GPT-5 line goes reworded in a user's turn too, turned away there since 11-14 (0.1.12 rewords instead of zero-width, 0.1.11 omp's "key words", 0.1.0 ported the built-in)
agents: []string{"antigravity"},
out: func() ([]Moving, error) {
var out []Moving