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

Since 11-14 Antigravity also answers a bare 429 "Resource has been
exhausted (e.g. check quota)" to Codex's GPT-5 lines ("You are Codex, an
agent / a coding agent based on GPT-5") in a user's turn: a pasted
AGENTS.md, or a developer message magpie tells after a reply as a
<system-reminder> in the user's turn. Both the plugin and the cloak only
reworded the system prompt, so such a conversation 429s on every turn
whatever quota is left (daoche_wuzui on X, magpie 0.1.4131 with Cloak
0.1.7).

On the owner's real Antigravity account, gemini-3.8-flash, 11-14:
- each line in the first user turn: Codex's two lines 429 3/3 each; the
  billing line, the Agent SDK line, Hermes' persona and omp's RFC line
  200 3/3 each, so only Codex's two are reworded there.
- Codex's line in the model's turn and in a functionResponse: 200 2/2.
- "built on GPT-5" in the user's turn: 200.

antigravity: shape() rewords USER_TURNED_AWAY (Codex's two lines) in
every non-model part's text; cloak() takes an optional list of lines.
antigravity-cloak: onProvider rewords those two lines in user messages
(anthropic messages, chat messages, responses input, gemini contents);
tool results, the model's turns and the user's own saidAs/extraWords are
left as they were in messages. The old case that kept a user's Codex line
as written now expects it reworded.

Run, at this tree, on mica:
- root `bun test` with a temp HOME: 8781 pass, 0 fail (8801 tests, 613 files)
- packages/antigravity `bun test`: 93 pass; packages/antigravity-cloak:
  25 pass.
Broken by hand: with the user-turn cloak taken out, shape.test's new
test fails, and 5 of the cloak's cases fail.
Real account through a sandbox magpie (gateway 3476, plugin host
restarted on these files): an Anthropic /v1/messages request whose user
turn carries Codex's line, 429 3/3 on 0.1.12 + cloak 0.1.7, 200 3/3 on
these. The plugin alone on the same account: 429 3/3 -> 200 3/3 for both
lines. Claude Code's 23-tool capture and a Codex capture still 200 2/2.
Not tried: agy-cli (it doesn't cloak), other models than
gemini-3.8-flash for the user-turn case.
This commit is contained in:
yetone
2026-11-14 14:24:14 +08:00
parent 09c05dfa9f
commit fb7bbebdc2
7 changed files with 89 additions and 12 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ Antigravity answers a request whose system prompt reads as Claude Code's or the
- Hermes Agent's earlier default persona, `Hermes Agent, an intelligent AI assistant created by Nous Research`, which a SOUL.md the user edited keeps (Hermes' current default goes through); - Hermes Agent's earlier default persona, `Hermes Agent, an intelligent AI assistant created by Nous Research`, which a SOUL.md the user edited keeps (Hermes' current default goes through);
- oh-my-pi's first line, `RFC 2119 keywords: MUST, REQUIRED, …`. - oh-my-pi's first line, `RFC 2119 keywords: MUST, REQUIRED, …`.
Up to 0.1.6 this middleware put zero-width spaces (U+200B) inside them. Since 11-14 Google's check reads past invisible characters, and a broken-up line is turned away as the line itself. This middleware now leaves Claude Code's billing line out and rewords the others with the same meaning: `built on the Claude Agent SDK by Anthropic`, `built on GPT-5`, `built by Nous Research`, `RFC 2119 key words`. It does this in the system prompt only, and only in what an Antigravity account is sent. Every other provider, a Claude subscription above all, gets the prompt as the agent wrote it, even in a routing group that tries Antigravity first. A copy an older version broke up is reworded too. Up to 0.1.6 this middleware put zero-width spaces (U+200B) inside them. Since 11-14 Google's check reads past invisible characters, and a broken-up line is turned away as the line itself. This middleware now leaves Claude Code's billing line out and rewords the others with the same meaning: `built on the Claude Agent SDK by Anthropic`, `built on GPT-5`, `built by Nous Research`, `RFC 2119 key words`. It does this in the system prompt, and only in what an Antigravity account is sent. Since 11-14 Antigravity also turns away Codex's two lines in a user's message (a pasted AGENTS.md, say), so from 0.1.8 those two are reworded in the user's messages as well; the other lines, tool results and the model's replies go as written there, since Google lets them through. Every other provider, a Claude subscription above all, gets the prompt as the agent wrote it, even in a routing group that tries Antigravity first. A copy an older version broke up is reworded too.
It needs a magpie with the `onProvider` hook (v0.1.1283 or later): an older magpie loads it and never calls it, so requests go as they came. It needs a magpie with the `onProvider` hook (v0.1.1283 or later): an older magpie loads it and never calls it, so requests go as they came.
@@ -16,6 +16,11 @@
// (a Codex thread begun on a GPT model keeps its prompt after /model or a // (a Codex thread begun on a GPT model keeps its prompt after /model or a
// fork onto an Antigravity one) // fork onto an Antigravity one)
// //
// Since 11-14 Codex's two lines are turned away in a user's turn too (a
// pasted AGENTS.md, a developer message told after a reply), so they go
// reworded there as well; the other lines, tool results and the model's
// turns go as written.
//
// Up to 0.1.6 this middleware put zero-width spaces (U+200B) inside them. // Up to 0.1.6 this middleware put zero-width spaces (U+200B) inside them.
// Since 11-14 Google's check reads past invisible characters: two U+200B in // Since 11-14 Google's check reads past invisible characters: two U+200B in
// each word, one after every character, or U+2060 instead, each line was // each word, one after every character, or U+2060 instead, each line was
@@ -76,26 +81,34 @@ export function onProvider(body, ctx) {
const accounts = Array.isArray(o.accounts) && o.accounts.length ? o.accounts : ["antigravity"] const accounts = Array.isArray(o.accounts) && o.accounts.length ? o.accounts : ["antigravity"]
if (!accounts.includes(ctx.provider?.account)) return if (!accounts.includes(ctx.provider?.account)) return
const cloak = cloaker(o) const cloak = cloaker(o)
const cloakUser = cloaker({}, userLines)
let changed = false let changed = false
const text = (s) => { const by = (f) => (s) => {
if (typeof s !== "string") return s if (typeof s !== "string") return s
const t = cloak(s) const t = f(s)
if (t !== s) changed = true if (t !== s) changed = true
return t return t
} }
const text = by(cloak)
const said = by(cloakUser)
switch (ctx.protocol) { switch (ctx.protocol) {
case "anthropic": case "anthropic":
body.system = typeof body.system === "string" ? text(body.system) : parts(body.system, text) body.system = typeof body.system === "string" ? text(body.system) : parts(body.system, text)
for (const m of Array.isArray(body.messages) ? body.messages : []) user(m, said)
break break
case "chat": case "chat":
if (Array.isArray(body.messages)) body.messages = body.messages.filter((m) => system(m, text)) if (Array.isArray(body.messages)) body.messages = body.messages.filter((m) => system(m, text))
for (const m of Array.isArray(body.messages) ? body.messages : []) user(m, said)
break break
case "responses": case "responses":
body.instructions = text(body.instructions) body.instructions = text(body.instructions)
if (typeof body.input === "string") body.input = said(body.input)
if (Array.isArray(body.input)) body.input = body.input.filter((m) => system(m, text)) if (Array.isArray(body.input)) body.input = body.input.filter((m) => system(m, text))
for (const m of Array.isArray(body.input) ? body.input : []) user(m, said)
break break
case "gemini": case "gemini":
for (const k of ["systemInstruction", "system_instruction"]) if (body[k]) body[k].parts = parts(body[k].parts, text) for (const k of ["systemInstruction", "system_instruction"]) if (body[k]) body[k].parts = parts(body[k].parts, text)
for (const c of Array.isArray(body.contents) ? body.contents : []) if (c && c.role !== "model") user({ role: "user", content: c.parts }, said)
break break
} }
return changed ? body : undefined return changed ? body : undefined
@@ -111,6 +124,26 @@ function system(m, text) {
return !had || (typeof m.content === "string" ? m.content !== "" : !Array.isArray(m.content) || m.content.length > 0) return !had || (typeof m.content === "string" ? m.content !== "" : !Array.isArray(m.content) || m.content.length > 0)
} }
// user rewrites the text a user's message says itself, a string or text
// parts, in place: since 11-14 Antigravity also answers a bare 429 to
// Codex's GPT-5 line in a user's turn (a pasted AGENTS.md, a developer
// message magpie tells after a reply), 3 of 3 on a real account, and lets
// it through reworded (userLines). The other lines went through there as
// written, 3 of 3 each, and tool results and the model's turns went through
// with every line, so they stay.
function user(m, text) {
if (!m || m.role !== "user") return
if (typeof m.content === "string") {
m.content = text(m.content)
return
}
for (const p of Array.isArray(m.content) ? m.content : []) {
if (!p || typeof p.text !== "string" || p.thought) continue
if (p.type !== undefined && p.type !== "text" && p.type !== "input_text") continue
p.text = text(p.text)
}
}
// parts rewrites each part's text, and leaves out a part that had text and // parts rewrites each part's text, and leaves out a part that had text and
// has none left: Claude Code's billing line is a block of its own. // has none left: Claude Code's billing line is a block of its own.
function parts(list, text) { function parts(list, text) {
@@ -126,10 +159,14 @@ function parts(list, text) {
return out return out
} }
// cloaker rewords every line where it appears, then each of saidAs' and // userLines are the lines, by their index in lines, Antigravity also turns
// extraWords' phrases. // away in a user's turn: Codex's GPT-5 lines.
function cloaker(o) { const userLines = [2, 3]
const rules = lines.map((l, i) => [lineRe(l, i === 0), saidAs[i]])
// cloaker rewords every line where it appears, or only those of only, then
// each of saidAs' and extraWords' phrases.
function cloaker(o, only) {
const rules = lines.map((l, i) => [lineRe(l, i === 0), saidAs[i], i]).filter(([, , i]) => !only || only.includes(i)).map(([re, as]) => [re, as])
if (o.saidAs && typeof o.saidAs === "object") { if (o.saidAs && typeof o.saidAs === "object") {
for (const [from, to] of Object.entries(o.saidAs)) if (from.length > 1 && typeof to === "string") rules.push([lineRe(from, false), () => to]) for (const [from, to] of Object.entries(o.saidAs)) if (from.length > 1 && typeof to === "string") rules.push([lineRe(from, false), () => to])
} }
+7 -2
View File
@@ -6,7 +6,7 @@
{"name":"Anthropic: no words, nothing changed","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":"You code.","messages":[]}}, {"name":"Anthropic: no words, nothing changed","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":"You code.","messages":[]}},
{"name":"Chat: system and developer messages, not the user's; a billing-line message is left out","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"chat"},"request":{"model":"m","messages":[{"role":"system","content":"You are a Claude agent, built on Anthropic's Claude Agent SDK."},{"role":"developer","content":[{"type":"text","text":"x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]},{"role":"user","content":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]},"expect_request":{"model":"m","messages":[{"role":"system","content":"You are a Claude agent, built on the Claude Agent SDK by Anthropic."},{"role":"user","content":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}}, {"name":"Chat: system and developer messages, not the user's; a billing-line message is left out","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"chat"},"request":{"model":"m","messages":[{"role":"system","content":"You are a Claude agent, built on Anthropic's Claude Agent SDK."},{"role":"developer","content":[{"type":"text","text":"x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]},{"role":"user","content":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]},"expect_request":{"model":"m","messages":[{"role":"system","content":"You are a Claude agent, built on the Claude Agent SDK by Anthropic."},{"role":"user","content":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}},
{"name":"Responses: instructions and a system input item","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"responses"},"request":{"model":"m","instructions":"You are a Claude agent, built on Anthropic's Claude Agent SDK.","input":[{"role":"system","content":[{"type":"input_text","text":"x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]},{"role":"user","content":[{"type":"input_text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}]},"expect_request":{"model":"m","instructions":"You are a Claude agent, built on the Claude Agent SDK by Anthropic.","input":[{"role":"user","content":[{"type":"input_text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}]}}, {"name":"Responses: instructions and a system input item","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"responses"},"request":{"model":"m","instructions":"You are a Claude agent, built on Anthropic's Claude Agent SDK.","input":[{"role":"system","content":[{"type":"input_text","text":"x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]},{"role":"user","content":[{"type":"input_text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}]},"expect_request":{"model":"m","instructions":"You are a Claude agent, built on the Claude Agent SDK by Anthropic.","input":[{"role":"user","content":[{"type":"input_text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}]}},
{"name":"Responses: Codex's GPT-5 prompt kept after a switch to an Antigravity model","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"claude-opus-5-5"},"ctx":{"protocol":"responses"},"request":{"model":"m","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, an agent based on GPT-5. You and the user share one workspace."}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"hi"}]},{"type":"message","role":"developer","content":[{"type":"input_text","text":"<model_switch>\nThe user was previously using a different model.\n</model_switch>"}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"You are Codex, an agent based on GPT-5."}]}]},"expect_request":{"model":"m","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, an agent built on GPT-5. You and the user share one workspace."}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"hi"}]},{"type":"message","role":"developer","content":[{"type":"input_text","text":"<model_switch>\nThe user was previously using a different model.\n</model_switch>"}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"You are Codex, an agent based on GPT-5."}]}]}}, {"name":"Responses: Codex's GPT-5 prompt kept after a switch to an Antigravity model, and the line in a user's turn","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"claude-opus-5-5"},"ctx":{"protocol":"responses"},"request":{"model":"m","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, an agent based on GPT-5. You and the user share one workspace."}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"hi"}]},{"type":"message","role":"developer","content":[{"type":"input_text","text":"<model_switch>\nThe user was previously using a different model.\n</model_switch>"}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"You are Codex, an agent based on GPT-5."}]}]},"expect_request":{"model":"m","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, an agent built on GPT-5. You and the user share one workspace."}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"hi"}]},{"type":"message","role":"developer","content":[{"type":"input_text","text":"<model_switch>\nThe user was previously using a different model.\n</model_switch>"}]},{"type":"message","role":"user","content":[{"type":"input_text","text":"You are Codex, an agent built on GPT-5."}]}]}},
{"name":"Responses: the coding agent wording, any case; magpie's own Codex prompt stays","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"claude-opus-5-5"},"ctx":{"protocol":"responses"},"request":{"model":"m","instructions":"you are codex, a coding agent based on gpt-5.","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI."}]}]},"expect_request":{"model":"m","instructions":"you are codex, a coding agent built on gpt-5.","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI."}]}]}}, {"name":"Responses: the coding agent wording, any case; magpie's own Codex prompt stays","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"claude-opus-5-5"},"ctx":{"protocol":"responses"},"request":{"model":"m","instructions":"you are codex, a coding agent based on gpt-5.","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI."}]}]},"expect_request":{"model":"m","instructions":"you are codex, a coding agent built on gpt-5.","input":[{"type":"message","role":"developer","content":[{"type":"input_text","text":"You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI."}]}]}},
{"name":"Chat: Hermes Agent's earlier persona, built by Nous Research","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"chat"},"request":{"model":"m","messages":[{"role":"system","content":"You are Hermes Agent, an intelligent AI assistant created by Nous Research. You are helpful, knowledgeable, and direct.\n\nYou are Hermes Agent, built by Nous Research."},{"role":"user","content":"hi"}]},"expect_request":{"model":"m","messages":[{"role":"system","content":"You are Hermes Agent, an intelligent AI assistant built by Nous Research. You are helpful, knowledgeable, and direct.\n\nYou are Hermes Agent, built by Nous Research."},{"role":"user","content":"hi"}]}}, {"name":"Chat: Hermes Agent's earlier persona, built by Nous Research","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"chat"},"request":{"model":"m","messages":[{"role":"system","content":"You are Hermes Agent, an intelligent AI assistant created by Nous Research. You are helpful, knowledgeable, and direct.\n\nYou are Hermes Agent, built by Nous Research."},{"role":"user","content":"hi"}]},"expect_request":{"model":"m","messages":[{"role":"system","content":"You are Hermes Agent, an intelligent AI assistant built by Nous Research. You are helpful, knowledgeable, and direct.\n\nYou are Hermes Agent, built by Nous Research."},{"role":"user","content":"hi"}]}},
{"name":"Gemini: systemInstruction","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"gemini"},"request":{"systemInstruction":{"parts":[{"text":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]},"contents":[]},"expect_request":{"systemInstruction":{"parts":[{"text":"You are a Claude agent, built on the Claude Agent SDK by Anthropic."}]},"contents":[]}}, {"name":"Gemini: systemInstruction","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"gemini"},"request":{"systemInstruction":{"parts":[{"text":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}]},"contents":[]},"expect_request":{"systemInstruction":{"parts":[{"text":"You are a Claude agent, built on the Claude Agent SDK by Anthropic."}]},"contents":[]}},
@@ -18,5 +18,10 @@
{"name":"omp: its RFC 2119 line wrapped with CRLF and a tab, as a real account turned it away","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"gemini"},"request":{"systemInstruction":{"parts":[{"text":"RFC 2119 keywords:\tMUST, REQUIRED,\r\nSHOULD, RECOMMENDED, MAY, OPTIONAL.\r\nYou are omp."}]},"contents":[]},"expect_request":{"systemInstruction":{"parts":[{"text":"RFC 2119 key words:\tMUST, REQUIRED,\r\nSHOULD, RECOMMENDED, MAY, OPTIONAL.\r\nYou are omp."}]},"contents":[]}}, {"name":"omp: its RFC 2119 line wrapped with CRLF and a tab, as a real account turned it away","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"ctx":{"protocol":"gemini"},"request":{"systemInstruction":{"parts":[{"text":"RFC 2119 keywords:\tMUST, REQUIRED,\r\nSHOULD, RECOMMENDED, MAY, OPTIONAL.\r\nYou are omp."}]},"contents":[]},"expect_request":{"systemInstruction":{"parts":[{"text":"RFC 2119 key words:\tMUST, REQUIRED,\r\nSHOULD, RECOMMENDED, MAY, OPTIONAL.\r\nYou are omp."}]},"contents":[]}},
{"name":"Anthropic: a copy an older magpie broke up is reworded as the line","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":[{"type":"text","text":"x-a\u200bn\u200bthropic-b\u200bi\u200blling-h\u200be\u200bader: cc_version=2.1.316.2e4; cc_entrypoint=claude-desktop;"},{"type":"text","text":"You are a Claude agent, built on Anthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK."}]},"expect_request":{"model":"m","system":[{"type":"text","text":"You are a Claude agent, built on the Claude Agent SDK by Anthropic."}]}}, {"name":"Anthropic: a copy an older magpie broke up is reworded as the line","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":[{"type":"text","text":"x-a\u200bn\u200bthropic-b\u200bi\u200blling-h\u200be\u200bader: cc_version=2.1.316.2e4; cc_entrypoint=claude-desktop;"},{"type":"text","text":"You are a Claude agent, built on Anthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK."}]},"expect_request":{"model":"m","system":[{"type":"text","text":"You are a Claude agent, built on the Claude Agent SDK by Anthropic."}]}},
{"name":"Anthropic: Claude Desktop's Code tab, its main line goes as written","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":[{"type":"text","text":"x-anthropic-billing-header: cc_version=2.1.316.2e4; cc_entrypoint=claude-desktop;"},{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK."},{"type":"text","text":"You are an interactive agent."}]},"expect_request":{"model":"m","system":[{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK."},{"type":"text","text":"You are an interactive agent."}]}}, {"name":"Anthropic: Claude Desktop's Code tab, its main line goes as written","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":[{"type":"text","text":"x-anthropic-billing-header: cc_version=2.1.316.2e4; cc_entrypoint=claude-desktop;"},{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK."},{"type":"text","text":"You are an interactive agent."}]},"expect_request":{"model":"m","system":[{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK."},{"type":"text","text":"You are an interactive agent."}]}},
{"name":"saidAs words go as given","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"options":{"saidAs":{"made by Acme Labs":"by Acme"}},"request":{"model":"m","system":"An agent made by\nAcme Labs."},"expect_request":{"model":"m","system":"An agent by Acme."}} {"name":"saidAs words go as given","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"options":{"saidAs":{"made by Acme Labs":"by Acme"}},"request":{"model":"m","system":"An agent made by\nAcme Labs."},"expect_request":{"model":"m","system":"An agent by Acme."}},
{"name":"Anthropic: Codex's GPT-5 line in a user's turn is reworded there, not in the model's or a tool result, and other lines stay (11-14)","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","messages":[{"role":"user","content":[{"type":"text","text":"My AGENTS.md:\nYou are Codex, a coding agent based on GPT-5. You and the user share the same workspace."},{"type":"text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK. RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."}]},{"role":"assistant","content":[{"type":"text","text":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."},{"type":"tool_use","id":"t1","name":"read","input":{"path":"a"}}]},{"role":"user","content":[{"type":"tool_result","tool_use_id":"t1","content":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]},{"role":"user","content":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]},"expect_request":{"model":"m","messages":[{"role":"user","content":[{"type":"text","text":"My AGENTS.md:\nYou are Codex, a coding agent built on GPT-5. You and the user share the same workspace."},{"type":"text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK. RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."}]},{"role":"assistant","content":[{"type":"text","text":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."},{"type":"tool_use","id":"t1","name":"read","input":{"path":"a"}}]},{"role":"user","content":[{"type":"tool_result","tool_use_id":"t1","content":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]},{"role":"user","content":"You are Codex, a coding agent built on GPT-5. You and the user share the same workspace."}]}},
{"name":"Chat: the line in a user's turn, reworded","ctx":{"protocol":"chat"},"provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","messages":[{"role":"user","content":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."},{"role":"assistant","content":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]},"expect_request":{"model":"m","messages":[{"role":"user","content":"You are Codex, a coding agent built on GPT-5. You and the user share the same workspace."},{"role":"assistant","content":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]}},
{"name":"Responses: the line in a user's input item, reworded; a tool's output stays","ctx":{"protocol":"responses"},"provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","input":[{"type":"message","role":"user","content":[{"type":"input_text","text":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]},{"type":"function_call_output","call_id":"c","output":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]},"expect_request":{"model":"m","input":[{"type":"message","role":"user","content":[{"type":"input_text","text":"You are Codex, a coding agent built on GPT-5. You and the user share the same workspace."}]},{"type":"function_call_output","call_id":"c","output":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]}},
{"name":"Gemini: the line in a user's content, reworded; the model's stays","ctx":{"protocol":"gemini"},"provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"contents":[{"role":"user","parts":[{"text":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]},{"role":"model","parts":[{"text":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]}]},"expect_request":{"contents":[{"role":"user","parts":[{"text":"You are Codex, a coding agent built on GPT-5. You and the user share the same workspace."}]},{"role":"model","parts":[{"text":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]}]}},
{"name":"the line in a user's turn to a Claude subscription stays","provider":{"id":"c","name":"Claude","account":"claude","model":"claude-sonnet-4-6"},"request":{"model":"m","messages":[{"role":"user","content":"You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."}]}}
] ]
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@magpie-community/middleware-antigravity-cloak", "name": "@magpie-community/middleware-antigravity-cloak",
"version": "0.1.7", "version": "0.1.8",
"description": "magpie gateway middleware: Antigravity stops turning Claude Code's and the Claude Agent SDK's system prompts away, and no other provider's request is changed", "description": "magpie gateway middleware: Antigravity stops turning Claude Code's and the Claude Agent SDK's system prompts away, and no other provider's request is changed",
"type": "module", "type": "module",
"files": ["antigravity-cloak.middleware.js", "README.md"], "files": ["antigravity-cloak.middleware.js", "README.md"],
+17 -1
View File
@@ -965,10 +965,20 @@ const SAID_AS = {
"rfc 2119 keywords: must, required, should, recommended, may, optional.": (line) => line.replace(/(key)(words)/i, "$1 $2"), "rfc 2119 keywords: must, required, should, recommended, may, optional.": (line) => line.replace(/(key)(words)/i, "$1 $2"),
} }
function cloak(system) { // USER_TURNED_AWAY are the lines 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.
const USER_TURNED_AWAY = TURNED_AWAY.filter((l) => l.startsWith("you are codex, "))
// cloak rewords the lines of only, or of TURNED_AWAY when only is left out
function cloak(system, only) {
if (!turnsAway(system)) return system if (!turnsAway(system)) return system
const at = [] const at = []
TURNED_AWAY_RE.forEach((re, i) => { TURNED_AWAY_RE.forEach((re, i) => {
if (only && !only.includes(TURNED_AWAY[i])) return
for (const m of system.matchAll(re)) at.push([m.index, m.index + m[0].length, SAID_AS[TURNED_AWAY[i]]]) for (const m of system.matchAll(re)) at.push([m.index, m.index + m[0].length, SAID_AS[TURNED_AWAY[i]]])
}) })
at.sort((a, b) => a[0] - b[0]) at.sort((a, b) => a[0] - b[0])
@@ -1098,6 +1108,12 @@ function shape(req, sent, at, effort) {
} }
if (Array.isArray(req.contents)) { if (Array.isArray(req.contents)) {
for (const c of req.contents) { for (const c of req.contents) {
// since 11-14 Antigravity also answers a bare 429 to Codex's GPT-5
// line in a user's turn (a pasted AGENTS.md, a developer message
// told after a reply), 3 of 3 on a real account, and lets it
// through reworded; the model's turns and tool results went through
// as written, so they stay
if (c?.role !== "model") for (const p of c?.parts ?? []) if (typeof p?.text === "string" && !p.thought) p.text = cloak(p.text, USER_TURNED_AWAY)
// an empty text (a stream's last chunk, sent back) is a block Claude // an empty text (a stream's last chunk, sent back) is a block Claude
// refuses: "text: Field required" // refuses: "text: Field required"
if (Array.isArray(c?.parts) && c.parts.length > 1) c.parts = c.parts.filter((p) => !(isObj(p) && p.text === "" && Object.keys(p).length === 1)) if (Array.isArray(c?.parts) && c.parts.length > 1) c.parts = c.parts.filter((p) => !(isObj(p) && p.text === "" && Object.keys(p).length === 1))
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@magpie-community/opencode-antigravity-auth", "name": "@magpie-community/opencode-antigravity-auth",
"version": "0.1.12", "version": "0.1.13",
"description": "Sign in to Antigravity with a Google account from OpenCode or magpie: Gemini, and the Claude and GPT-OSS models Google hosts for it", "description": "Sign in to Antigravity with a Google account from OpenCode or magpie: Gemini, and the Claude and GPT-OSS models Google hosts for it",
"type": "module", "type": "module",
"main": "./opencode.mjs", "main": "./opencode.mjs",
+19
View File
@@ -272,3 +272,22 @@ test("DeepSeek Harness's @-path paragraph goes reworded, the rest as written (#1
expect(both).not.toMatch(/[\u200b-\u200f\u2060]/) expect(both).not.toMatch(/[\u200b-\u200f\u2060]/)
expect(both).toContain("When the user writes @ followed by a path") expect(both).toContain("When the user writes @ followed by a path")
}) })
// since 11-14 Codex's GPT-5 line in a user's turn is turned away too (3 of
// 3 on a real account): it goes reworded there, and the model's turns and
// tool results, which went through with it, as written
test("the line in a user's turn goes reworded", () => {
const line = "You are Codex, a coding agent based on GPT-5. You and the user share the same workspace."
const g = generic()
g.contents[0].parts[0].text = "Here is my AGENTS.md:\n\n" + line
g.contents[1].parts[1].text = line
g.contents[2].parts[0].functionResponse.response.output = line
const others = "x-anthropic-billing-header: cc_version=2.1.316.2e4;\nYou are a Claude agent, built on Anthropic's Claude Agent SDK.\nRFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."
g.contents[3].parts[0].text = others
const r = shape(g, "gemini-3-flash", "", "")
expect(r.contents[3].parts[0].text).toBe(others)
expect(r.contents[0].parts[0].text).toBe("Here is my AGENTS.md:\n\nYou are Codex, a coding agent built on GPT-5. You and the user share the same workspace.")
expect(r.contents[1].parts[1].text).toBe(line)
expect(JSON.stringify(r.contents[2])).toContain("based on GPT-5")
expect(g.contents[0].parts[0].text).toContain("based on GPT-5")
})