antigravity 0.1.12, agy-cli 0.1.41, antigravity-cloak 0.1.7: turned-away lines go reworded (#1118)

Since 11-14 Google's check reads past invisible characters: a system
prompt with Claude Code's billing line and Agent SDK line, broken up with
two U+200B in every word as the cloak sent them, was turned away 5 of 5
with the bare 429 "Resource has been exhausted". Claude Desktop's Code
tab through magpie to Antigravity failed every turn (hc295971796 and
daoche_wuzui on X, 11-14).

Each line Google turns away now goes reworded instead, as plain words:
- the x-anthropic-billing-header line is left out (to its line's end);
  a system part or message holding only it is dropped;
- "built on Anthropic's Claude Agent SDK" -> "built on the Claude Agent
  SDK by Anthropic";
- Codex's "based on GPT-5" -> "built on GPT-5";
- Hermes' "created by Nous Research" -> "built by Nous Research";
- omp's RFC "keywords" -> "key words" (as before).
A copy an older magpie or cloak broke up (U+200B, U+2060, soft hyphen,
in or between words) is matched and reworded as the line. The Code tab's
main line ("You are Claude Code, Anthropic's official CLI for Claude,
running within the Claude Agent SDK.") passes as written and is kept.
antigravity-cloak gains a saidAs {phrase: replacement} option; extraWords
still breaks words up and the README says it no longer gets past
Google.

Run:
- real Antigravity account, sandbox HOME, gemini-3.8-flash, 10
  sequential requests each through packages/antigravity at this head:
  Code tab main prompt as Claude Desktop sends it (billing + main line +
  rest) 10/10 200; Agent SDK subagent line 10/10; an old two-U+200B
  copy 10/10; Codex GPT-5 10/10; Hermes' earlier persona 10/10; omp's
  RFC line 10/10. Each rewording alone was first tried 5/5 against the
  zero-width break, which went 0/5.
- wsl-run, HOME=$(mktemp -d) bun test (whole repo) before the last test
  fixes: 8735 pass, 19 skip, 3 fail, all three in these packages' own
  tests still expecting zero-width; after fixing them,
  bun test packages/antigravity packages/agy-cli packages/antigravity-cloak:
  133 pass, 0 fail.
Broken by hand: the three packages' source files from origin/main with
these tests: 19 fail (shape, cloak parity, smoke, every cases.json case).
Not tried: agy-cli against the real agy binary (smoke runs a fake agy);
models other than gemini-3.8-flash.
This commit is contained in:
yetone
2026-11-14 11:04:28 +08:00
parent 07ba4eb88d
commit 5bb4194140
14 changed files with 309 additions and 168 deletions
+5 -4
View File
@@ -239,10 +239,11 @@ start of the first prompt.
Antigravity answers a 429 "Resource has been exhausted" to a few system
prompt lines whatever quota is left (Claude Code's billing line, the Claude
Agent SDK, Codex and Hermes Agent identities, oh-my-pi's RFC 2119 line). The
plugin breaks each of them up with zero-width spaces before agy sends it, and
sends oh-my-pi's line as "RFC 2119 key words: …" (a broken-up copy of it was
still turned away now and then), as the Antigravity provider does
(`cloak.mjs`). Should such a 429 still come
plugin leaves the billing line out and rewords the others with the same
meaning before agy sends them ("built on the Claude Agent SDK by Anthropic",
"built on GPT-5", "built by Nous Research", "RFC 2119 key words: …"), as the
Antigravity provider does (`cloak.mjs`). Zero-width spaces no longer help:
since 11-14 Google's check reads past them. Should such a 429 still come
back, it is reported as a 400 about the prompt, not as a quota.
DeepSeek Harness's paragraph on `@` paths ("Tokens prefixed with @ are
+1 -1
View File
@@ -181,7 +181,7 @@ magpie quota refresh agy-cli --json
Antigravity 对几行系统提示词(Claude Code 的计费行、Claude Agent SDK、Codex 和 Hermes Agent
的身份句、oh-my-pi 的 RFC 2119 行)不论余量多少都回 429 "Resource has been exhausted"。插件在
agy 发出之前用零宽空格把这几行拆开,oh-my-pi 那行改成 "RFC 2119 key words: …" 发出(拆开的那行仍会时不时被拒),和 Antigravity 提供商的做法一样(`cloak.mjs`)。如果仍然
agy 发出之前去掉计费那一行,其余几行换成同义的说法("built on the Claude Agent SDK by Anthropic"、"built on GPT-5"、"built by Nous Research"、"RFC 2119 key words: …"),和 Antigravity 提供商的做法一样(`cloak.mjs`)。零宽空格已经没用:11-14 起 Google 的检查会忽略它们。如果仍然
回了这样的 429,会报成针对提示词的 400,而不是额度用完。
DeepSeek Harness 的 `@` 路径说明段("Tokens prefixed with @ are paths…")也和 Antigravity 提供商一样
+54 -27
View File
@@ -1,19 +1,19 @@
// System prompt lines Antigravity turns away, and paragraphs it answers
// badly, the same lists and the same rewrites as
// packages/antigravity/index.mjs (TURNED_AWAY, breakUp, cloak, hint,
// packages/antigravity/index.mjs (TURNED_AWAY, SAID_AS, cloak, hint,
// REWORDED, reword, outgoing). Each package ships on its own, so the code is
// a copy; cloak.test.mjs fails when the two give a different answer.
//
// Antigravity answers a 429 "Resource has been exhausted" to a request whose
// system prompt has one of these lines, whatever quota is left, and lets the
// same prompt through with a zero-width space after the first and second
// character of each word. agy-cli hands the client's system prompt to agy
// (session instructions, or <external_system_instructions> in the prompt),
// and agy sends it to Antigravity as written, so it is broken up here before
// it goes. What the bridge keys sessions on (instructionsIdentity) is the
// same prompt through reworded. agy-cli hands the client's system prompt to
// agy (session instructions, or <external_system_instructions> in the
// prompt), and agy sends it to Antigravity as written, so it is reworded
// here before it goes. What the bridge keys sessions on (instructionsIdentity) is the
// prompt as the client wrote it.
// TURNED_AWAY are the lines, lower-cased.
// TURNED_AWAY are the lines, lower-cased, Antigravity answers a 429 to
// whatever quota is left. Each goes as SAID_AS says instead.
export const TURNED_AWAY = [
"x-anthropic-billing-header:",
"built on anthropic's claude agent sdk",
@@ -23,13 +23,31 @@ export const TURNED_AWAY = [
"rfc 2119 keywords: must, required, should, recommended, may, optional.",
]
const ZW = "​"
// INVISIBLE are the characters Google's check reads past: since 11-14 a
// line with a zero-width space (U+200B) after the first and second
// character of each word, or after every character, or U+2060, is turned
// away as the line itself, 5 of 5 on a real account for every line here
// (hc295971796 on X, Claude Desktop's Code tab). A copy someone broke up
// that way (the antigravity-cloak middleware before 0.1.7, an older magpie)
// is matched as the line.
const INVISIBLE = "[\\u00ad\\u180e\\u200b-\\u200f\\u2060-\\u2064\\ufeff]"
const INVISIBLE_RE = new RegExp(INVISIBLE, "g")
// lineRe matches line in any case and with any run of white space between
// its words, as Google's check does (a line break, a tab, two spaces or a
// no-break space for one space; packages/antigravity's lineRe). \s takes no
// zero-width space, so a line already broken up isn't matched again.
const lineRe = (line) => new RegExp(line.split(" ").map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+"), "gi")
const escape = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
// lineRe matches line in any case, with any run of white space between its
// words and any invisible characters inside them: Google's check reads a
// line break, a tab, two spaces or a no-break space where the line has one
// space, and turned omp's line away wrapped after "REQUIRED," or after
// "RFC 2119" as it did on one line, while a missing period, a space dropped
// after a comma or the words in another order went through (a real
// account, 11-14). Claude Code's billing line is matched to its end, since
// it goes whole.
const lineRe = (line) => {
const words = line.split(" ").map((w) => [...w].map(escape).join(`${INVISIBLE}*`))
const tail = line === "x-anthropic-billing-header:" ? "[^\\n]*\\n?" : ""
return new RegExp(words.join(`${INVISIBLE}*\\s+${INVISIBLE}*`) + tail, "gi")
}
const TURNED_AWAY_RE = TURNED_AWAY.map(lineRe)
const has = (s, re) => {
re.lastIndex = 0
@@ -44,18 +62,26 @@ export function turnsAway(system) {
return TURNED_AWAY_RE.some((re) => has(s, re))
}
// breakUp puts a zero-width space after the first and after the second
// character of every run of three or more letters or digits in a line.
// One after the first letter only stopped working on 11-11.
const breakUp = (line) => line.replace(/[A-Za-z0-9]{3,}/g, (w) => w[0] + ZW + w[1] + ZW + w.slice(2))
// SAID_AS are the lines no zero-width space gets through reliably, each
// with how it goes instead: a rewording that keeps its meaning. omp's
// RFC 2119 line, broken up as the others are (or after every character,
// or with U+2060 or a soft hyphen), was still turned away 1 to 3 times in
// 10 on a real account on 11-14, while "key words", the RFC's own term,
// went through 10 times in 10 (eric_li8983 on X).
// SAID_AS is how each line goes, with its invisible characters taken out
// and its white space as it was: a rewording that keeps its meaning, each
// answered 5 of 5 on a real account on 11-14 while the line itself, broken
// up or not, was turned away 5 of 5.
// - Claude Code's billing line is left out: it is Anthropic's, and no
// Antigravity model reads anything in it.
// - "built on Anthropic's Claude Agent SDK", the Agent SDK's identity
// line (Claude Desktop's Code tab and its subagents), goes as "built on
// the Claude Agent SDK by Anthropic".
// - Codex's GPT-5 lines go "built on GPT-5" for "based on GPT-5".
// - Hermes' earlier persona goes "built by Nous Research", as Hermes'
// current one says it, for "created by".
// - omp's RFC 2119 line goes as "key words", the RFC's own term (10 of 10
// on 11-14, eric_li8983 on X).
const SAID_AS = {
"x-anthropic-billing-header:": () => "",
"built on anthropic's claude agent sdk": (line) => line.replace(/^(built\s+on\s+)anthropic's(\s+)(claude\s+agent\s+sdk)$/i, "$1the$2$3 by Anthropic"),
"you are codex, an agent based on gpt-5": (line) => line.replace(/based(\s+)on/i, "built$1on"),
"you are codex, a coding agent based on gpt-5": (line) => line.replace(/based(\s+)on/i, "built$1on"),
"hermes agent, an intelligent ai assistant created by nous research": (line) => line.replace(/created(\s+)by/i, "built$1by"),
"rfc 2119 keywords: must, required, should, recommended, may, optional.": (line) => line.replace(/(key)(words)/i, "$1 $2"),
}
@@ -63,14 +89,14 @@ export function cloak(system) {
if (typeof system !== "string" || !turnsAway(system)) return system
const at = []
TURNED_AWAY_RE.forEach((re, i) => {
for (const m of system.matchAll(re)) at.push([m.index, m.index + m[0].length, SAID_AS[TURNED_AWAY[i]] ?? breakUp])
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])
let out = ""
let prev = 0
for (const [from, to, as] of at) {
if (from < prev) continue
out += system.slice(prev, from) + as(system.slice(from, to))
out += system.slice(prev, from) + as(system.slice(from, to).replace(INVISIBLE_RE, ""))
prev = to
}
return out + system.slice(prev)
@@ -94,7 +120,8 @@ export function reword(system) {
return system
}
// outgoing is system text as agy is handed it: broken up, then reworded
// outgoing is system text as agy is handed it: each turned-away line and
// each paragraph of REWORDED reworded
export const outgoing = (system) => reword(cloak(system))
const HINT =
+7 -7
View File
@@ -23,10 +23,10 @@ const samples = [
"",
]
test("every turned-away line is broken up or reworded, and the model still reads it", () => {
test("every turned-away line is reworded, with no invisible character in it", () => {
for (const s of samples) {
const out = cloak(s)
expect(out.replaceAll(ZW, "").replace(/key words/i, (m) => m.replace(" ", ""))).toBe(s)
expect(out).not.toMatch(/[\u00ad\u200b-\u200f\u2060-\u2064]/)
if (turnsAway(s)) {
expect(out).not.toBe(s)
expect(turnsAway(out)).toBe(false)
@@ -39,7 +39,7 @@ test("every turned-away line is broken up or reworded, and the model still reads
)
})
test("a turned-away line wrapped or widened by white space is broken up too", () => {
test("a turned-away line wrapped or widened by white space is reworded too", () => {
for (const s of [samples[7], samples[8], samples[9]]) {
expect(turnsAway(s)).toBe(true)
expect(cloak(s)).not.toBe(s)
@@ -49,8 +49,8 @@ test("a turned-away line wrapped or widened by white space is broken up too", ()
expect(turnsAway(samples[10])).toBe(false)
})
test("agy-cli and antigravity break up and explain the same lines", () => {
for (const line of TURNED_AWAY) {
test("agy-cli and antigravity reword and explain the same lines", () => {
for (const line of [...TURNED_AWAY, ...samples.filter((s) => turnsAway(s)).map((s) => s.replace(/[A-Za-z0-9]{3,}/g, (w) => w[0] + ZW + w[1] + ZW + w.slice(2)))]) {
expect(antigravity.turnsAway(line)).toBe(true)
expect(cloak(line)).toBe(antigravity.cloak(line))
expect(hint(line)).toBe(antigravity.hint(line))
@@ -73,11 +73,11 @@ test("DeepSeek Harness's @-path paragraph goes reworded, the rest as written (#1
expect(outgoing(sys)).toBe("You are DeepSeek Harness.\n\nWhen the user writes @ followed by a path, they are pointing at that file or folder. Relative paths start at the workspace root; absolute paths are host paths. A path ending in a slash is a folder, so list it if its contents matter; otherwise it is a file, so open it with the read tool before relying on it. Paths with spaces appear as @\"...\".\n\nBe brief.")
expect(outgoing("Tokens prefixed with @ are paths. Be brief.")).toBe("Tokens prefixed with @ are paths. Be brief.")
const both = outgoing("x-anthropic-billing-header: cc\n" + DSH)
expect(both).toContain("x-a" + ZW + "n" + ZW + "thropic")
expect(both).not.toContain("anthropic")
expect(both).toContain("When the user writes @ followed by a path")
})
test("agy-cli and antigravity send the same system text, reworded and broken up", () => {
test("agy-cli and antigravity send the same system text, reworded", () => {
for (const [from, to] of REWORDED) {
expect(outgoing(from)).toBe(to)
expect(antigravitySends(from)).toBe(to)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-agy-cli-auth",
"version": "0.1.40",
"version": "0.1.41",
"description": "Magpie/OpenCode model provider that connects your local agy CLI through the Agent Client Protocol (agy acp), so Antigravity subscription models run through the real CLI",
"type": "module",
"main": "./opencode.mjs",
+16 -14
View File
@@ -1356,7 +1356,7 @@ for (const [title, tools, want, name] of [
check("split error marker and quota map to rate_limit_error", error?.type === "rate_limit_error" && error.message.includes("quota exhausted") && textOf(events) === "", JSON.stringify({ error, text: textOf(events) }))
}
// #980: the system lines Antigravity turns away are broken up before agy
// #980: the system lines Antigravity turns away are reworded before agy
// sends them, in the session instructions, in the prompt when agy can't take
// them, and in a later system message; a 429 to such a prompt is not a quota.
{
@@ -1364,20 +1364,22 @@ for (const [title, tools, want, name] of [
const rfc = "RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."
const sdk = "You are a Claude agent, built on Anthropic's Claude Agent SDK."
const system = `${rfc}\nx-anthropic-billing-header: cc_version=2.1.0; cch=1;\n${sdk}\nCLOAK-MARKER`
// omp's line goes as RFC 2119's own "key words", the others broken up
const plain = (text) => String(text ?? "").replaceAll(zw, "").replaceAll("RFC 2119 key words:", "RFC 2119 keywords:")
// omp's line goes as RFC 2119's own "key words", the billing line not at
// all, the Agent SDK's line reworded; no zero-width space, which Google's
// check reads past since 11-14
const sdkSaid = "You are a Claude agent, built on the Claude Agent SDK by Anthropic."
const want = `${rfc.replace("keywords", "key words")}\n${sdkSaid}\nCLOAK-MARKER`
const body = { model, system, messages: [{ role: "user", content: "cloak session instructions" }] }
const events = (await readSSE(await callFetch(body))).events
const init = inits().at(-1)
const sent = init.systemAppend ?? ""
check("#980 a turned-away line is broken up in the session instructions",
sent.includes("CLOAK-MARKER") && !sent.includes(rfc) && !sent.includes("x-anthropic-billing-header") && !sent.includes("Claude Agent SDK") &&
sent.includes("RFC 2119 key words: MUST,") && sent.includes("C" + zw + "l" + zw + "aude A" + zw + "g" + zw + "ent S" + zw + "D" + zw + "K") &&
plain(sent).includes(system), JSON.stringify(sent))
check("#980 a turned-away line is reworded in the session instructions",
!sent.includes(rfc) && !sent.includes("x-anthropic-billing-header") && !sent.includes(sdk) && !sent.includes(zw) &&
sent.includes(want), JSON.stringify(sent))
const convId = init.convId
const before = inits().length
await readSSE(await callFetch(nextTurn(body, events, "cloak second turn")))
check("#980 the broken-up instructions keep the conversation in its session", inits().length === before && lastOf("user").convId === convId,
check("#980 the reworded instructions keep the conversation in its session", inits().length === before && lastOf("user").convId === convId,
JSON.stringify({ inits: inits().length - before, user: lastOf("user") }))
const later = { model, system: "CLOAK-LATER", messages: [{ role: "user", content: "cloak later system" }] }
@@ -1386,7 +1388,7 @@ for (const [title, tools, want, name] of [
next.messages.splice(next.messages.length - 1, 0, { role: "system", content: sdk })
await readSSE(await callFetch(next))
const laterText = lastOf("user").text
check("#980 a later system message is broken up too", !laterText.includes("Claude Agent SDK") && plain(laterText).includes(sdk), JSON.stringify(laterText))
check("#980 a later system message is reworded too", !laterText.includes(sdk) && laterText.includes(sdkSaid), JSON.stringify(laterText))
const user = { model, system: "CLOAK-USER", messages: [{ role: "user", content: `user wrote ${sdk}` }] }
await readSSE(await callFetch(user))
@@ -1395,9 +1397,9 @@ for (const [title, tools, want, name] of [
process.env.FAKE_AGY_APPEND = "0"
await readSSE(await callFetch({ model, system: system + " NOAPPEND", messages: [{ role: "user", content: "cloak in the prompt" }] }))
const prompted = lastOf("user").text
check("#980 a turned-away line is broken up in <external_system_instructions>",
inits().at(-1).systemAppend === null && prompted.includes("<external_system_instructions>") && prompted.includes("CLOAK-MARKER") &&
!prompted.includes(rfc) && !prompted.includes("Claude Agent SDK") && plain(prompted).includes(system), JSON.stringify(prompted))
check("#980 a turned-away line is reworded in <external_system_instructions>",
inits().at(-1).systemAppend === null && prompted.includes("<external_system_instructions>") &&
!prompted.includes(rfc) && !prompted.includes(sdk) && !prompted.includes(zw) && prompted.includes(want), JSON.stringify(prompted))
delete process.env.FAKE_AGY_APPEND
const turned = (await readSSE(await callFetch({ model, system: system + " T429", messages: [{ role: "user", content: "TURNED429 please" }] }))).events
@@ -1856,9 +1858,9 @@ for (const location of ["inline", "system", "developer", "user"]) {
mcpText.includes("# Environment update") &&
mcpText.includes("hasn't heard from you") &&
!mcpText.includes("hook success: Success"), mcpText)
check("#980 a turned-away line in a system notice beside a tool result is broken up",
check("#980 a turned-away line in a system notice beside a tool result is reworded",
!mcpText.includes("You are Codex, a coding agent based on GPT-5") &&
mcpText.replaceAll("\u200b", "").includes("You are Codex, a coding agent based on GPT-5."), mcpText)
mcpText.includes("You are Codex, a coding agent built on GPT-5."), mcpText)
}
{
+11 -9
View File
@@ -5,39 +5,41 @@ Claude Code and Claude Desktop on an Antigravity account, as [magpie](https://us
Antigravity answers a request whose system prompt reads as Claude Code's or the Claude Agent SDK's (which Claude Desktop's chats use) with `429 Resource has been exhausted`, however much quota is left. magpie shows it as a 400 that says so. Tried with a real account, Antigravity matches these pieces of the prompt:
- Claude Code's billing line, `x-anthropic-billing-header: …`;
- `You are a Claude agent, built on Anthropic's Claude Agent SDK`;
- `built on Anthropic's Claude Agent SDK`, the Agent SDK's identity line (Claude Desktop's Code tab and its subagents);
- Codex's own prompt for its GPT-5 models, `You are Codex, an agent based on GPT-5` or `You are Codex, a coding agent based on GPT-5`. A Codex chat begun on a GPT model keeps it after `/model` or a fork onto an Antigravity model, so that chat 429s while a new one works;
- 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). Breaking it after `You` doesn't help; it is broken after the `H`.
- 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, …`.
The same prompt goes through when each has a zero-width space (U+200B) inside it. This middleware puts two (after the first and the second character of each word; one after the first letter only was turned away again on 11-11) in `x-anthropic-billing-header`, `Claude Agent SDK`, those two Codex lines and Hermes' line, 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. The model reads the words as before.
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.
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.
magpie v0.1.1641 and later break these same lines on an Antigravity account by themselves (`magpie provider set antigravity prompt=as-written` turns that off), so there this middleware adds only `extraWords`.
magpie v0.1.1641 and later change these same lines on an Antigravity account by themselves (`magpie provider set antigravity prompt=as-written` turns that off), so there this middleware adds only `saidAs` and `extraWords`.
Install it from magpie's **Plugins › Discover**, or with `magpie plugin add @magpie-community/middleware-antigravity-cloak`.
## Before you turn it on
- This changes what Google is sent so that a request it means to refuse isn't refused. It may be against Antigravity's terms, and Google can ban the account for it. Use it on an account you can afford to lose.
- Google can change what it matches at any time. Then the refusal comes back, and magpie may no longer recognise it as this refusal: it can read as a real quota running out and rest the account. If that happens, add the new words to `extraWords`, or turn the plugin off.
- Google can change what it matches at any time. Then the refusal comes back, and magpie may no longer recognise it as this refusal: it can read as a real quota running out and rest the account. If that happens, add the new words to `saidAs`, or turn the plugin off.
## When the 429 comes back anyway
A `429 Resource has been exhausted` while magpie still shows quota left, and while other requests on the same model and account go through (an agent's title request, say), is this refusal, not quota. Something else in that agent's system prompt is being matched. It is often text that isn't the agent's own: a custom prompt, or a plugin or extension that adds to the prompt (magpie-community/plugins#1031 was a DeepSeek Harness plugin's injected prompt).
To find it, replay the failing request with a short user message and take parts of the system prompt out, half at a time, until the 429 stops. Then add a distinctive phrase from the part that brought it back to `extraWords`, or change or remove that text where it comes from. This middleware breaks only the lines and words it is given; it doesn't hide arbitrary prompts.
To find it, replay the failing request with a short user message and take parts of the system prompt out, half at a time, until the 429 stops. Then add a distinctive phrase from the part that brought it back to `saidAs`, with a rewording that keeps its meaning, or change or remove that text where it comes from. This middleware changes only the lines and phrases it is given; it doesn't hide arbitrary prompts.
## Options
```json
{ "extraWords": [], "accounts": ["antigravity"], "off": false }
{ "saidAs": {}, "extraWords": [], "accounts": ["antigravity"], "off": false }
```
- `extraWords`: more words to break the same way, matched whatever their case.
- `saidAs`: more phrases, each with what goes instead, matched whatever their case and white space.
- `extraWords`: phrases broken up with zero-width spaces, as before 0.1.7. Google reads past that since 11-14; prefer `saidAs`.
- `accounts`: the subscriptions it acts on, by kind. `antigravity` is the default.
- `off`: leave every request as it came.
中文:Antigravity 看到 Claude Code / Claude Agent SDK / Codex GPT-5 / Hermes Agent 旧版默认人设的系统提示词会回一个假的 429。这个中间件只在发给 Antigravity 账号的请求里,往 `x-anthropic-billing-header`、`Claude Agent SDK` 和 Codex 给 GPT-5 模型的身份行(在 GPT 模型上开始、再切到 Antigravity 模型的 Codex 对话会带着它),以及 Hermes Agent 旧版默认人设(SOUL.md)那句里插一个零宽空格,其他供应商(尤其是 Claude 订阅)收到的提示词不变。这样做可能违反 Antigravity 的条款,账号有被封的风险,请只用在可以承受损失的账号上。需要 magpie v0.1.1283 或更新版本。如果还剩额度、同一模型的其他请求也正常,却仍然收到 429,说明系统提示词里还有别的内容被匹配到(常见的是自定义提示词,或其他插件注入的内容):把系统提示词逐段拿掉重放请求,找到触发的那段,再把其中有代表性的短语加进 `extraWords`。
中文:Antigravity 看到 Claude Code / Claude Agent SDK / Codex GPT-5 / Hermes Agent 旧版默认人设 / oh-my-pi 的系统提示词会回一个假的 429。0.1.6 及以前往这几行里插零宽空格;11-14 起 Google 的检查会忽略零宽字符,这招不再有效。现在这个中间件只在发给 Antigravity 账号的请求里,去掉 Claude Code 的计费行,其余几行换成同义说法(built on the Claude Agent SDK by Anthropic、built on GPT-5、built by Nous Research、RFC 2119 key words),其他供应商(尤其是 Claude 订阅)收到的提示词不变。这样做可能违反 Antigravity 的条款,账号有被封的风险,请只用在可以承受损失的账号上。需要 magpie v0.1.1283 或更新版本。如果还剩额度、同一模型的其他请求也正常,却仍然收到 429,说明系统提示词里还有别的内容被匹配到(常见的是自定义提示词,或其他插件注入的内容):把系统提示词逐段拿掉重放请求,找到触发的那段,再把其中有代表性的短语和同义说法加进 `saidAs`。
After [hexiaolv/magpie-antigravity-cloak](https://github.com/hexiaolv/magpie-antigravity-cloak) (MIT), which breaks a longer list of words in every request, whatever provider it goes to.
@@ -1,10 +1,11 @@
// Antigravity answers a request whose system prompt reads as Claude Code's
// or the Claude Agent SDK's with a 429 "Resource has been exhausted", which
// isn't about the account's quota at all. Tried with a real account, it
// matches these words in the system prompt:
// matches these lines in the system prompt:
//
// "x-anthropic-billing-header:" Claude Code's billing line
// "You are a Claude agent, built on Anthropic's Claude Agent SDK"
// "x-anthropic-billing-header: …" Claude Code's billing line
// "built on Anthropic's Claude Agent SDK" the Agent SDK's identity line
// (Claude Desktop's Code tab and its subagents)
// "You are Codex, an agent based on GPT-5" Codex's own prompt
// "You are Codex, a coding agent based on GPT-5" for its GPT-5 models
// "Hermes Agent, an intelligent AI assistant created by Nous Research"
@@ -14,33 +15,59 @@
//
// (a Codex thread begun on a GPT model keeps its prompt after /model or a
// fork onto an Antigravity one)
// and lets the same prompt through with a zero-width space (U+200B) inside
// each. This middleware puts one after the first letter of each word in
// what Antigravity alone is sent (onProvider, ctx.provider.account): every
// other provider, a Claude subscription above all, gets the prompt as the
// agent wrote it. The model reads the words as before. omp's line goes as
// "RFC 2119 key words: …" instead (saidAs): broken up, Google still turned
// it away now and then.
//
// {"extraWords": [], "accounts": ["antigravity"], "off": false}
// 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
// each word, one after every character, or U+2060 instead, each line was
// turned away 5 of 5 on a real account (hc295971796 on X, Claude Desktop's
// Code tab). Each line now goes reworded with the same meaning (saidAs),
// which went through 5 of 5, and only in what Antigravity alone is sent
// (onProvider, ctx.provider.account): every other provider, a Claude
// subscription above all, gets the prompt as the agent wrote it.
//
// extraWords are more words to break the same way, should Google match
// others; accounts are the subscriptions' kinds it acts on.
// {"saidAs": {}, "extraWords": [], "accounts": ["antigravity"], "off": false}
//
// saidAs maps more phrases to what goes instead, should Google match others.
// extraWords are phrases still broken up with zero-width spaces, as before;
// Google reads past that now, so prefer saidAs. accounts are the
// subscriptions' kinds it acts on.
//
// After hexiaolv's magpie-antigravity-cloak (MIT), which does the same to
// every request whatever provider it goes to.
export const words = ["x-anthropic-billing-header", "Claude Agent SDK", "You are Codex, an agent based on GPT-5", "You are Codex, a coding agent based on GPT-5", "Hermes Agent, an intelligent AI assistant created by Nous Research", "RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."]
export const lines = ["x-anthropic-billing-header:", "built on Anthropic's Claude Agent SDK", "You are Codex, an agent based on GPT-5", "You are Codex, a coding agent based on GPT-5", "Hermes Agent, an intelligent AI assistant created by Nous Research", "RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."]
// saidAs is how each line goes, given the line as it was matched with its
// invisible characters taken out and its white space kept: Claude Code's
// billing line not at all (no Antigravity model reads it), the Agent SDK's
// as "built on the Claude Agent SDK by Anthropic", Codex's as "built on
// GPT-5", Hermes' as "built by Nous Research" (as its current persona says
// it), omp's with RFC 2119's own "key words".
const saidAs = [
() => "",
(m) => m.replace(/^(built\s+on\s+)anthropic's(\s+)(claude\s+agent\s+sdk)$/i, "$1the$2$3 by Anthropic"),
(m) => m.replace(/based(\s+)on/i, "built$1on"),
(m) => m.replace(/based(\s+)on/i, "built$1on"),
(m) => m.replace(/created(\s+)by/i, "built$1by"),
(m) => m.replace(/(key)(words)/i, "$1 $2"),
]
const zwsp = "​"
// saidAs are the words no zero-width space gets through reliably, each with
// how it goes instead, a rewording that keeps its meaning: omp's line broken
// up was still turned away 1 to 3 times in 10 on a real account on 11-14,
// whatever the invisible character, while "key words", RFC 2119's own term,
// went through 10 times in 10.
const saidAs = {
"RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL.": (m) => m.replace(/(key)(words)/i, "$1 $2"),
// invisible are the characters Google's check reads past. A line is matched
// with them anywhere inside it, so a copy an older version of this
// middleware or of magpie broke up is reworded as the line.
const invisible = "[\\u00ad\\u180e\\u200b-\\u200f\\u2060-\\u2064\\ufeff]"
const invisibleRe = new RegExp(invisible, "g")
const escape = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
// lineRe matches a line in any case, with any run of white space where it
// has a space: Google's check read omp's line wrapped after "REQUIRED," or
// with a tab or a no-break space for a space as it read the line itself (a
// real account, 11-14). The billing line is matched to its end.
function lineRe(line, toEnd) {
const words = line.split(" ").map((w) => [...w].map(escape).join(`${invisible}*`))
return new RegExp(words.join(`${invisible}*\\s+${invisible}*`) + (toEnd ? "[^\\n]*\\n?" : ""), "gi")
}
export function onProvider(body, ctx) {
@@ -48,8 +75,7 @@ export function onProvider(body, ctx) {
if (o.off) return
const accounts = Array.isArray(o.accounts) && o.accounts.length ? o.accounts : ["antigravity"]
if (!accounts.includes(ctx.provider?.account)) return
const list = words.concat(Array.isArray(o.extraWords) ? o.extraWords.filter((w) => typeof w === "string" && w.length > 1) : [])
const cloak = cloaker(list)
const cloak = cloaker(o)
let changed = false
const text = (s) => {
if (typeof s !== "string") return s
@@ -62,46 +88,55 @@ export function onProvider(body, ctx) {
body.system = typeof body.system === "string" ? text(body.system) : parts(body.system, text)
break
case "chat":
if (Array.isArray(body.messages)) for (const m of body.messages) system(m, text)
if (Array.isArray(body.messages)) body.messages = body.messages.filter((m) => system(m, text))
break
case "responses":
body.instructions = text(body.instructions)
if (Array.isArray(body.input)) for (const m of body.input) system(m, text)
if (Array.isArray(body.input)) body.input = body.input.filter((m) => system(m, text))
break
case "gemini":
for (const k of ["systemInstruction", "system_instruction"]) if (body[k]) parts(body[k].parts, text)
for (const k of ["systemInstruction", "system_instruction"]) if (body[k]) body[k].parts = parts(body[k].parts, text)
break
}
return changed ? body : undefined
}
// a system or developer message's text, a string or parts
// system rewrites a system or developer message's text, a string or parts,
// and says whether the message stays: one that had text and has none left
// (Claude Code's billing line sent as a message of its own) is left out.
function system(m, text) {
if (!m || (m.role !== "system" && m.role !== "developer")) return
if (!m || (m.role !== "system" && m.role !== "developer")) return true
const had = typeof m.content === "string" ? m.content !== "" : Array.isArray(m.content) && m.content.length > 0
m.content = typeof m.content === "string" ? text(m.content) : parts(m.content, text)
return !had || (typeof m.content === "string" ? m.content !== "" : !Array.isArray(m.content) || m.content.length > 0)
}
// 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.
function parts(list, text) {
if (Array.isArray(list)) for (const p of list) if (p && typeof p.text === "string") p.text = text(p.text)
return list
if (!Array.isArray(list)) return list
const out = []
for (const p of list) {
if (p && typeof p.text === "string" && p.text !== "") {
p.text = text(p.text)
if (p.text === "") continue
}
out.push(p)
}
return out
}
// cloaker breaks every word of list where it appears, whatever its case:
// a zero-width space after the first and after the second character of each
// run of three or more letters or digits in it. One after the first letter
// only stopped working on 11-11, when Google turned
// "x\u200b-anthropic-billing-header" and "C\u200blaude Agent SDK" away again.
//
// A word matches with any run of white space where it has a space: Google's
// check read omp's line wrapped after "REQUIRED," or with a tab or a no-break
// space for a space as it read the line itself (a real account, 11-14).
function cloaker(list) {
const res = list.map((w) => new RegExp(w.split(" ").map((p) => p.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+"), "gi"))
// cloaker rewords every line where it appears, then each of saidAs' and
// extraWords' phrases.
function cloaker(o) {
const rules = lines.map((l, i) => [lineRe(l, i === 0), saidAs[i]])
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])
}
const two = (m) => m.replace(/[A-Za-z0-9]{3,}/g, (w) => w[0] + zwsp + w[1] + zwsp + w.slice(2))
for (const w of Array.isArray(o.extraWords) ? o.extraWords : []) if (typeof w === "string" && w.length > 1) rules.push([lineRe(w, false), two])
return (s) => {
list.forEach((w, i) => {
s = s.replace(res[i], saidAs[w] ?? two)
})
for (const [re, as] of rules) s = s.replace(re, (m) => as(m.replace(invisibleRe, "")))
return s
}
}
+19 -16
View File
@@ -1,19 +1,22 @@
[
{"name": "Anthropic: Claude Code's blocks, to Antigravity", "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.0.abc; cc_entrypoint=cli; cch=1a2b3;"}, {"type": "text", "text": "You are a Claude agent, built on Anthropic's Claude Agent SDK.", "cache_control": {"type": "ephemeral"}}], "messages": [{"role": "user", "content": "Claude Agent SDK"}]}, "expect_request": {"model": "m", "system": [{"type": "text", "text": "x-a\u200bn\u200bthropic-b\u200bi\u200blling-h\u200be\u200bader: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}, {"type": "text", "text": "You are a Claude agent, built on Anthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK.", "cache_control": {"type": "ephemeral"}}], "messages": [{"role": "user", "content": "Claude Agent SDK"}]}},
{"name": "Anthropic: the same to a Claude subscription stays as it was", "provider": {"id": "c", "name": "Claude", "account": "claude", "model": "claude-sonnet-4-5"}, "request": {"model": "m", "system": [{"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}, {"type": "text", "text": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}], "messages": []}},
{"name": "Anthropic: an API key, no account, stays as it was", "provider": {"id": "k", "name": "Key", "model": "m"}, "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK.", "messages": []}},
{"name": "Anthropic: a string system, any case", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "request": {"model": "m", "system": "X-Anthropic-Billing-Header: a\nbuilt on the claude agent sdk"}, "expect_request": {"model": "m", "system": "X-A\u200bn\u200bthropic-B\u200bi\u200blling-H\u200be\u200bader: a\nbuilt on the c\u200bl\u200baude a\u200bg\u200bent s\u200bd\u200bk"}},
{"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", "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 Anthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK."}, {"role": "developer", "content": [{"type": "text", "text": "x-a\u200bn\u200bthropic-b\u200bi\u200blling-h\u200be\u200bader: 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."}]}},
{"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 Anthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK.", "input": [{"role": "system", "content": [{"type": "input_text", "text": "x-a\u200bn\u200bthropic-b\u200bi\u200blling-h\u200be\u200bader: 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."}]}]}},
{"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": "Y\u200bo\u200bu a\u200br\u200be C\u200bo\u200bdex, an a\u200bg\u200bent b\u200ba\u200bsed on G\u200bP\u200bT-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: 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": "y\u200bo\u200bu a\u200br\u200be c\u200bo\u200bdex, a c\u200bo\u200bding a\u200bg\u200bent b\u200ba\u200bsed on g\u200bp\u200bt-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, broken after its H", "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 H\u200be\u200brmes A\u200bg\u200bent, an i\u200bn\u200btelligent AI a\u200bs\u200bsistant c\u200br\u200beated by N\u200bo\u200bus R\u200be\u200bsearch. 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 Anthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK."}]}, "contents": []}},
{"name": "extraWords are broken too", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "options": {"extraWords": ["Claude Code"]}, "request": {"model": "m", "system": "You are Claude Code."}, "expect_request": {"model": "m", "system": "You are C\u200bl\u200baude C\u200bo\u200bde."}},
{"name": "accounts says which subscriptions", "provider": {"id": "g", "name": "Gemini", "account": "gemini", "model": "m"}, "options": {"accounts": ["gemini"]}, "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}, "expect_request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK."}},
{"name": "off leaves it", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "options": {"off": true}, "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}},
{"name": "onRequest isn't there: before routing nothing is changed", "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}},
{"name":"Anthropic: Claude Code's blocks, to Antigravity","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.0.abc; cc_entrypoint=cli; cch=1a2b3;"},{"type":"text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK.","cache_control":{"type":"ephemeral"}}],"messages":[{"role":"user","content":"Claude Agent SDK"}]},"expect_request":{"model":"m","system":[{"type":"text","text":"You are a Claude agent, built on the Claude Agent SDK by Anthropic.","cache_control":{"type":"ephemeral"}}],"messages":[{"role":"user","content":"Claude Agent SDK"}]}},
{"name":"Anthropic: the same to a Claude subscription stays as it was","provider":{"id":"c","name":"Claude","account":"claude","model":"claude-sonnet-4-5"},"request":{"model":"m","system":[{"type":"text","text":"x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"},{"type":"text","text":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}],"messages":[]}},
{"name":"Anthropic: an API key, no account, stays as it was","provider":{"id":"k","name":"Key","model":"m"},"request":{"model":"m","system":"You are a Claude agent, built on Anthropic's Claude Agent SDK.","messages":[]}},
{"name":"Anthropic: a string system, any case","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":"X-Anthropic-Billing-Header: a\nbuilt on the claude agent sdk"},"expect_request":{"model":"m","system":"built on the claude agent sdk"}},
{"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":"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: 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":"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":"extraWords are still broken up","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"options":{"extraWords":["Claude Code"]},"request":{"model":"m","system":"You are Claude Code."},"expect_request":{"model":"m","system":"You are C\u200bl\u200baude C\u200bo\u200bde."}},
{"name":"accounts says which subscriptions","provider":{"id":"g","name":"Gemini","account":"gemini","model":"m"},"options":{"accounts":["gemini"]},"request":{"model":"m","system":"You are a Claude agent, built on Anthropic's Claude Agent SDK."},"expect_request":{"model":"m","system":"You are a Claude agent, built on the Claude Agent SDK by Anthropic."}},
{"name":"off leaves it","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"options":{"off":true},"request":{"model":"m","system":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}},
{"name":"onRequest isn't there: before routing nothing is changed","request":{"model":"m","system":"You are a Claude agent, built on Anthropic's Claude Agent SDK."}},
{"name":"omp: its RFC 2119 line, to Antigravity","provider":{"id":"7c1958d885953cd3","name":"Antigravity","account":"antigravity","model":"gemini-3-flash"},"request":{"model":"m","system":[{"type":"text","text":"RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL. `NEVER` = `MUST NOT`."}],"messages":[{"role":"user","content":"hi"}]},"expect_request":{"model":"m","system":[{"type":"text","text":"RFC 2119 key words: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL. `NEVER` = `MUST NOT`."}],"messages":[{"role":"user","content":"hi"}]}},
{"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: 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."}}
]
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/middleware-antigravity-cloak",
"version": "0.1.6",
"version": "0.1.7",
"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",
"files": ["antigravity-cloak.middleware.js", "README.md"],
+9 -4
View File
@@ -86,10 +86,15 @@ requestType: "agent", requestId, request}`):
The plugin also changes the request itself, as the built-in did:
- **System prompt:** lines Antigravity turns away (Claude Code's billing
header, Codex's and Hermes Agent's own prompts, omp's RFC 2119 line) are broken up with a
zero-width space; omp's line goes as "RFC 2119 key words: …", since a
broken-up copy of it was still turned away now and then.
- **System prompt:** lines Antigravity turns away with a 429 whatever quota
is left go reworded with the same meaning, since Google's check reads past
zero-width spaces (11-14): Claude Code's billing header is left out, the
Claude Agent SDK's "built on Anthropic's Claude Agent SDK" (Claude
Desktop's Code tab and its subagents) goes as "built on the Claude Agent
SDK by Anthropic", Codex's GPT-5 lines say "built on GPT-5", Hermes
Agent's earlier persona "built by Nous Research", and omp's line "RFC 2119
key words: …". A copy someone broke up with invisible characters is
reworded the same way.
DeepSeek Harness's paragraph on `@` paths ("Tokens prefixed with @ are
paths…") goes reworded with the same meaning: word for word, it got most
`gemini-4-argon` answers fast, without thinking and shallow (#1028).
+50 -27
View File
@@ -896,9 +896,7 @@ function plainSchema(root) {
// ---- system prompts Antigravity turns away -----------------------------------------------
// TURNED_AWAY are the lines, lower-cased, Antigravity answers a 429 to
// whatever quota is left. Each is broken up before it goes by a zero-width
// space after its first and second character of each word, which Google
// lets through.
// whatever quota is left. Each goes as SAID_AS says instead.
const TURNED_AWAY = [
"x-anthropic-billing-header:",
"built on anthropic's claude agent sdk",
@@ -908,16 +906,31 @@ const TURNED_AWAY = [
"rfc 2119 keywords: must, required, should, recommended, may, optional.",
]
const ZW = "​"
// INVISIBLE are the characters Google's check reads past: since 11-14 a
// line with a zero-width space (U+200B) after the first and second
// character of each word, or after every character, or U+2060, is turned
// away as the line itself, 5 of 5 on a real account for every line here
// (hc295971796 on X, Claude Desktop's Code tab). A copy someone broke up
// that way (the antigravity-cloak middleware before 0.1.7, an older magpie)
// is matched as the line.
const INVISIBLE = "[\\u00ad\\u180e\\u200b-\\u200f\\u2060-\\u2064\\ufeff]"
const INVISIBLE_RE = new RegExp(INVISIBLE, "g")
// lineRe matches line in any case and with any run of white space between
// its words: Google's check reads a line break, a tab, two spaces or a
// no-break space where the line has one space, and turned omp's line away
// wrapped after "REQUIRED," or after "RFC 2119" as it did on one line, while
// a missing period, a space dropped after a comma or the words in another
// order went through (a real account, 11-14). JavaScript's \s takes no
// zero-width space, so a line already broken up isn't matched again.
const lineRe = (line) => new RegExp(line.split(" ").map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+"), "gi")
const escape = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
// lineRe matches line in any case, with any run of white space between its
// words and any invisible characters inside them: Google's check reads a
// line break, a tab, two spaces or a no-break space where the line has one
// space, and turned omp's line away wrapped after "REQUIRED," or after
// "RFC 2119" as it did on one line, while a missing period, a space dropped
// after a comma or the words in another order went through (a real
// account, 11-14). Claude Code's billing line is matched to its end, since
// it goes whole.
const lineRe = (line) => {
const words = line.split(" ").map((w) => [...w].map(escape).join(`${INVISIBLE}*`))
const tail = line === "x-anthropic-billing-header:" ? "[^\\n]*\\n?" : ""
return new RegExp(words.join(`${INVISIBLE}*\\s+${INVISIBLE}*`) + tail, "gi")
}
const TURNED_AWAY_RE = TURNED_AWAY.map(lineRe)
const has = (s, re) => {
re.lastIndex = 0
@@ -929,20 +942,26 @@ const said = (system, line) => has(system, TURNED_AWAY_RE[TURNED_AWAY.indexOf(li
const turnsAway = (system) => TURNED_AWAY_RE.some((re) => has(system, re))
// breakUp puts a zero-width space after the first and after the second
// character of every run of three or more letters or digits in a line.
// One after the first letter only stopped working on 11-11: Google turned
// "x\u200b-anthropic-billing-header:" and "b\u200built on Anthropic's Claude
// Agent SDK" away again, and answered each word broken twice.
const breakUp = (line) => line.replace(/[A-Za-z0-9]{3,}/g, (w) => w[0] + ZW + w[1] + ZW + w.slice(2))
// SAID_AS are the lines no zero-width space gets through reliably, each
// with how it goes instead: a rewording that keeps its meaning. omp's
// RFC 2119 line, broken up as the others are (or after every character,
// or with U+2060 or a soft hyphen), was still turned away 1 to 3 times in
// 10 on a real account on 11-14, while "key words", the RFC's own term,
// went through 10 times in 10 (eric_li8983 on X).
// SAID_AS is how each line goes, with its invisible characters taken out
// and its white space as it was: a rewording that keeps its meaning, each
// answered 5 of 5 on a real account on 11-14 while the line itself, broken
// up or not, was turned away 5 of 5.
// - Claude Code's billing line is left out: it is Anthropic's, and no
// Antigravity model reads anything in it.
// - "built on Anthropic's Claude Agent SDK", the Agent SDK's identity
// line (Claude Desktop's Code tab and its subagents), goes as "built on
// the Claude Agent SDK by Anthropic".
// - Codex's GPT-5 lines go "built on GPT-5" for "based on GPT-5".
// - Hermes' earlier persona goes "built by Nous Research", as Hermes'
// current one says it, for "created by".
// - omp's RFC 2119 line goes as "key words", the RFC's own term (10 of 10
// on 11-14, eric_li8983 on X).
const SAID_AS = {
"x-anthropic-billing-header:": () => "",
"built on anthropic's claude agent sdk": (line) => line.replace(/^(built\s+on\s+)anthropic's(\s+)(claude\s+agent\s+sdk)$/i, "$1the$2$3 by Anthropic"),
"you are codex, an agent based on gpt-5": (line) => line.replace(/based(\s+)on/i, "built$1on"),
"you are codex, a coding agent based on gpt-5": (line) => line.replace(/based(\s+)on/i, "built$1on"),
"hermes agent, an intelligent ai assistant created by nous research": (line) => line.replace(/created(\s+)by/i, "built$1by"),
"rfc 2119 keywords: must, required, should, recommended, may, optional.": (line) => line.replace(/(key)(words)/i, "$1 $2"),
}
@@ -950,14 +969,14 @@ function cloak(system) {
if (!turnsAway(system)) return system
const at = []
TURNED_AWAY_RE.forEach((re, i) => {
for (const m of system.matchAll(re)) at.push([m.index, m.index + m[0].length, SAID_AS[TURNED_AWAY[i]] ?? breakUp])
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])
let out = ""
let prev = 0
for (const [from, to, as] of at) {
if (from < prev) continue
out += system.slice(prev, from) + as(system.slice(from, to))
out += system.slice(prev, from) + as(system.slice(from, to).replace(INVISIBLE_RE, ""))
prev = to
}
return out + system.slice(prev)
@@ -1070,6 +1089,10 @@ function shape(req, sent, at, effort) {
const claude = m.includes("claude")
if (isObj(req.systemInstruction)) {
for (const p of req.systemInstruction.parts ?? []) if (typeof p?.text === "string") p.text = outgoing(p.text)
// Claude Code's billing line, a block of its own, goes out whole and
// leaves an empty text, which a Claude model refuses
const parts = req.systemInstruction.parts
if (Array.isArray(parts) && parts.length > 1) req.systemInstruction.parts = parts.filter((p) => !(isObj(p) && p.text === "" && Object.keys(p).length === 1))
} else if (typeof req.systemInstruction === "string") {
req.systemInstruction = { role: "user", parts: [{ text: outgoing(req.systemInstruction) }] }
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-antigravity-auth",
"version": "0.1.11",
"version": "0.1.12",
"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",
"main": "./opencode.mjs",
+55 -12
View File
@@ -148,22 +148,64 @@ test("omp's line is reworded wherever white space wraps or widens it", () => {
for (const line of OMP_PASSED) expect(cloak(line)).toBe(line)
// the other lines take white space the same way (Hermes' and Codex's
// were turned away wrapped and with a tab on the same account)
expect(cloak("You are Hermes Agent, an intelligent\nAI assistant created by Nous Research.")).toContain("i\u200bn\u200btelligent\nAI a\u200bs\u200bsistant")
expect(cloak("You are Codex, an agent\tbased on GPT-5.")).toContain("a\u200bg\u200bent\tb\u200ba\u200bsed")
expect(cloak("You are Hermes Agent, an intelligent\nAI assistant created by Nous Research.")).toBe("You are Hermes Agent, an intelligent\nAI assistant built by Nous Research.")
expect(cloak("You are Codex, an agent\tbased on GPT-5.")).toBe("You are Codex, an agent\tbuilt on GPT-5.")
})
test("the lines Antigravity turns away are broken up", () => {
const sys = "x-anthropic-billing-header: cc_version=2\nYou are Claude Code, built on Anthropic's Claude Agent SDK.\nhi"
// Claude Desktop's Code tab, as Claude Code 2.1.316 sends it with
// CLAUDE_CODE_ENTRYPOINT=claude-desktop: the billing line and the identity
// line are blocks of their own. Its subagents begin "You are a Claude agent,
// built on Anthropic's Claude Agent SDK." Since 11-14 Google reads past a
// zero-width space: the prompt with either line broken up was turned away
// 10 of 10 on a real account (hc295971796 on X), and the reworded one
// answered 10 of 10.
const BILLING = "x-anthropic-billing-header: cc_version=2.1.316.2e4; cc_entrypoint=claude-desktop;"
const DESKTOP = "You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK."
const SUBAGENT = "You are a Claude agent, built on Anthropic's Claude Agent SDK."
test("Claude Code's billing line is left out, and the Agent SDK's line is reworded", () => {
const { turnsAway, hint } = _internal
const sys = BILLING + "\n" + SUBAGENT + "\nhi"
const out = cloak(sys)
expect(out).not.toBe(sys)
expect(out.replaceAll("​", "")).toBe(sys)
expect(out).toContain("x-a\u200bn\u200bthropic-b\u200bi\u200blling-h\u200be\u200bader:")
expect(out).toContain("b\u200bu\u200bilt on A\u200bn\u200bthropic's C\u200bl\u200baude A\u200bg\u200bent S\u200bD\u200bK")
expect(out).toBe("You are a Claude agent, built on the Claude Agent SDK by Anthropic.\nhi")
expect(turnsAway(out)).toBe(false)
expect(hint(sys)).toContain("Claude Agent SDK")
// twice is the same as once, and other text is left alone
expect(cloak(out)).toBe(out)
expect(cloak("be brief")).toBe("be brief")
const r = shape({ systemInstruction: { parts: [{ text: sys }] }, contents: [] }, "gemini-3-flash", "", "")
expect(r.systemInstruction.parts[0].text).toBe(out)
expect(cloak(DESKTOP)).toBe(DESKTOP)
// the case and white space the agent wrote stay
expect(cloak("built on\nANTHROPIC'S claude agent sdk")).toBe("built on\nthe claude agent sdk by Anthropic")
// as the gateway hands it: each block a part; the billing line's part goes
const r = shape({ systemInstruction: { parts: [{ text: BILLING }, { text: DESKTOP }, { text: SUBAGENT }] }, contents: [] }, "gemini-3-flash", "", "")
expect(r.systemInstruction.parts.map((p) => p.text)).toEqual([DESKTOP, "You are a Claude agent, built on the Claude Agent SDK by Anthropic."])
// a billing line alone in a string stays one (empty) part
expect(shape({ systemInstruction: BILLING, contents: [] }, "gemini-3-flash", "", "").systemInstruction.parts).toEqual([{ text: "" }])
})
test("a line someone broke up with invisible characters is reworded as the line", () => {
const zw = (s, z = "\u200b") => s.replace(/[A-Za-z0-9]{3,}/g, (w) => w[0] + z + w[1] + z + w.slice(2))
const every = (s) => [...s].join("\u2060")
const lines = [
[SUBAGENT, "You are a Claude agent, built on the Claude Agent SDK by Anthropic."],
["You are Codex, an agent based on GPT-5.", "You are Codex, an agent built on GPT-5."],
["You are Codex, a coding agent based on GPT-5.", "You are Codex, a coding agent built on GPT-5."],
["You are Hermes Agent, an intelligent AI assistant created by Nous Research.", "You are Hermes Agent, an intelligent AI assistant built by Nous Research."],
["RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL.", "RFC 2119 key words: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."],
]
// the break-ups also reach words outside the turned-away part, which go as
// written: compare with the invisible characters taken out
const seen = (s) => s.replace(/[\u00ad\u200b\u2060]/g, "")
for (const [line, to] of lines) {
expect(cloak(line)).toBe(to)
for (const broken of [zw(line), every(line), zw(line, "\u00ad")]) {
const out = cloak(broken)
expect(out).not.toBe(broken)
expect(seen(out)).toBe(to)
expect(_internal.turnsAway(out)).toBe(false)
}
}
expect(cloak(zw(BILLING) + "\nhi")).toBe("hi")
})
test("a conversation keeps its session", () => {
@@ -224,8 +266,9 @@ test("DeepSeek Harness's @-path paragraph goes reworded, the rest as written (#1
// a prompt that only mentions @ paths is left as it is
const other = "Tokens prefixed with @ are paths. Be brief."
expect(shape({ systemInstruction: { parts: [{ text: other }] }, contents: [] }, "gemini-4-argon", "", "").systemInstruction.parts[0].text).toBe(other)
// the rewording and the zero-width breaks go together
// the billing line is left out and the paragraph reworded, together
const both = shape({ systemInstruction: { parts: [{ text: "x-anthropic-billing-header: cc\n" + dsh }] }, contents: [] }, "gemini-3-flash", "", "").systemInstruction.parts[0].text
expect(both).toContain("x-a​n​thropic")
expect(both).not.toContain("x-anthropic-billing-header")
expect(both).not.toMatch(/[\u200b-\u200f\u2060]/)
expect(both).toContain("When the user writes @ followed by a path")
})