Antigravity answers 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's and Hermes Agent's identities, oh-my-pi's RFC 2119 line). The antigravity provider breaks them up with zero-width spaces (TURNED_AWAY / breakUp / cloak); agy-cli sent the client's system prompt to agy as written, and called the 429 an exhausted quota (rate_limit_error), so a client or routing group retried a prompt that fails every time. - cloak.mjs is a copy of antigravity's TURNED_AWAY, cloak and hint (the two-zero-width-space break-up of 11-11). Each package ships on its own, so cloak.test.mjs imports packages/antigravity's _internal and fails when the two give a different answer for any line or sample. - Every route the system text reaches agy is cloaked: the session's systemPrompt.append (session/new and session/resume), <external_system_instructions> when agy can't append, a later system or developer message in the turn or the replayed history (renderTurnMessageParts), and a system/developer notice delivered beside a tool result (extractToolResults). - What the bridge keys and hashes on is unchanged: proc.instructions, sameInstructions, instructionsIdentity, stripVolatileSystem and the session store keep the prompt as the client wrote it; cloak is applied only where the text is sent. User text is not touched. - #formatAgentError: a "code 429 ... Resource has been exhausted" with a turned-away line in the session's instructions is an invalid_request_error, "Antigravity answered 429 to this system prompt: <detail> — <hint>", with the antigravity provider's hint. Any other 429 stays rate_limit_error. - READMEs (en, zh) say so under the minimal-agent section. Run (wsl-run, magpie-desktop, HOME=$(mktemp -d), atf85f9ad0+ this change): - bun test packages/agy-cli: 13 pass 0 fail (smoke ALL OK, 333 checks) - bun scripts/check.mjs: exit 0 - root bun test: 8189 pass, 19 skip, 0 fail (580 files, 408s) - rebased on84ee9b88(day-card, autoclaw, sap-aicore only): bun test packages/agy-cli 13 pass 0 fail and bun scripts/check.mjs exit 0 again at this head Broken by hand (each red, then restored): - append: this.instructions uncloaked -> "#980 ... session instructions" BAD - <external_system_instructions> uncloaked -> its #980 check BAD - later system message uncloaked -> "#980 a later system message" BAD - tool-result notice uncloaked -> "#980 ... system notice beside a tool result" BAD - the turned-away branch of #formatAgentError off -> the 429 came back rate_limit_error, "#980 a 429 ... prompt rejection" BAD - cloak.mjs back to one zero-width space after the first letter -> both cloak.test.mjs tests red Not tried: against real Antigravity or a real agy (no vendor API was reached; the fake agy in test/smoke.mjs stands in). Whether agy's own request puts the appended instructions where Google matches them is taken from the report and the antigravity provider, not measured here. A turned-away line the user pastes into their own message is sent as written, as the antigravity provider does. Reported-by: shaohongwu
80 lines
4.0 KiB
JavaScript
80 lines
4.0 KiB
JavaScript
// System prompt lines Antigravity turns away, the same list and the same
|
||
// break-up as packages/antigravity/index.mjs (TURNED_AWAY, breakUp, cloak,
|
||
// hint). Each package ships on its own, so the code is a copy; cloak.test.mjs
|
||
// fails when the two give a different answer for any line.
|
||
//
|
||
// 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
|
||
// prompt as the client wrote it.
|
||
|
||
// TURNED_AWAY are the lines, lower-cased.
|
||
export const TURNED_AWAY = [
|
||
"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.",
|
||
]
|
||
|
||
const ZW = ""
|
||
|
||
export function turnsAway(system) {
|
||
const low = String(system ?? "").toLowerCase()
|
||
return TURNED_AWAY.some((l) => low.includes(l))
|
||
}
|
||
|
||
const asciiLower = (s) => s.replace(/[A-Z]/g, (c) => c.toLowerCase())
|
||
|
||
// 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))
|
||
|
||
export function cloak(system) {
|
||
if (typeof system !== "string" || !turnsAway(system)) return system
|
||
const low = asciiLower(system)
|
||
const at = []
|
||
for (const line of TURNED_AWAY) {
|
||
for (let i = 0; ; ) {
|
||
const j = low.indexOf(line, i)
|
||
if (j < 0) break
|
||
at.push([j, j + line.length])
|
||
i = j + line.length
|
||
}
|
||
}
|
||
at.sort((a, b) => a[0] - b[0])
|
||
let out = ""
|
||
let prev = 0
|
||
for (const [from, to] of at) {
|
||
if (from < prev) continue
|
||
out += system.slice(prev, from) + breakUp(system.slice(from, to))
|
||
prev = to
|
||
}
|
||
return out + system.slice(prev)
|
||
}
|
||
|
||
const HINT =
|
||
"Antigravity answers this 429 to the system prompt of Claude Code and the Claude Agent SDK (Claude Desktop's chats) whatever quota is left, so it is not a quota and waiting won't help; use another provider for these chats, or put one after Antigravity in a routing group"
|
||
|
||
const CODEX_HINT =
|
||
"Antigravity answers this 429 to Codex's own system prompt for GPT-5 models whatever quota is left, so it is not a quota and waiting won't help; a Codex chat begun on a GPT model keeps that prompt after a model switch or a fork, so start a new chat on this model"
|
||
const HERMES_HINT =
|
||
"Antigravity answers this 429 to Hermes Agent's earlier default persona (its SOUL.md) whatever quota is left, so it is not a quota and waiting won't help; Hermes' current default persona goes through, so put it in SOUL.md, or use another provider for these chats"
|
||
|
||
const RFC_HINT =
|
||
"Antigravity answers this 429 to the line \"RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL.\" that starts oh-my-pi (omp)'s system prompt, and to any prompt that has it, whatever quota is left, so it is not a quota and waiting won't help; magpie breaks that line up before it goes, so this one came from a copy of it that was worded another way"
|
||
|
||
export function hint(system) {
|
||
const low = String(system ?? "").toLowerCase()
|
||
if (low.includes("rfc 2119 keywords: must, required, should, recommended, may, optional.")) return RFC_HINT
|
||
if (low.includes("you are codex, an agent based on gpt-5") || low.includes("you are codex, a coding agent based on gpt-5")) return CODEX_HINT
|
||
if (low.includes("hermes agent, an intelligent ai assistant created by nous research")) return HERMES_HINT
|
||
return HINT
|
||
}
|