diff --git a/internal/gateway/antigravity_cloak_test.go b/internal/gateway/antigravity_cloak_test.go
index 1e8d7c4ab..c778494f7 100644
--- a/internal/gateway/antigravity_cloak_test.go
+++ b/internal/gateway/antigravity_cloak_test.go
@@ -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: "\n" + said + "\n"}}},
+ {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)
+ }
+}
diff --git a/internal/gateway/codeassist.go b/internal/gateway/codeassist.go
index a76fd9e10..de6ebce49 100644
--- a/internal/gateway/codeassist.go
+++ b/internal/gateway/codeassist.go
@@ -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
+// () 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 {
diff --git a/internal/provider/migrate_antigravity.go b/internal/provider/migrate_antigravity.go
index e2d77b592..c17d4f466 100644
--- a/internal/provider/migrate_antigravity.go
+++ b/internal/provider/migrate_antigravity.go
@@ -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