Files
plugins/packages/agy-cli/cloak.mjs
T
yetone 4170d0e816 antigravity 0.1.11, agy-cli 0.1.40, antigravity-cloak 0.1.6: omp's RFC 2119 line goes as "key words", in any white space
eric_li8983 (X, 11-14): oh-my-pi on Windows with an Antigravity account got
"Antigravity answered 429 to this system prompt" for omp's first line,
"RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY, OPTIONAL."

Two causes, both seen on a real account on 11-14:

- Google's check reads the line in any case with any white space between
  its words: wrapped with LF or CRLF, indented, a tab, two spaces or a
  no-break space were all turned away, while the cloak matched only the
  literal line, so those copies went out whole. Each turned-away line is
  now matched with any run of white space (JavaScript's \s) between its
  words, the same in antigravity, agy-cli's cloak.mjs and the
  antigravity-cloak middleware; Codex's and Hermes' lines too.
- A zero-width-broken copy of omp's line was itself turned away now and
  then (10 sequential requests each: two U+200B a word 3 bare 429s, one
  after every character 3, U+2060 2, soft hyphen 1). omp's line now goes
  as "RFC 2119 key words: …", RFC 2119's own term, with its white space
  as it was. The hint says so.

Real account (sandbox HOME, copy of the live Antigravity account,
gemini-3.8-flash, sequential): the reworded plugin answered omp 18.20.0's
literal prompt 10/10, the full template 10/10, and the line wrapped after
"REQUIRED," 10/10. The zero-width version before it: lit 3, tmpl 1, w1 5
bare 429s in 12 each.

Run at 24c75a16's tree (rebased on 76cfb7fe): the whole bun test (temp
HOME) on WSL magpie-desktop, 8720 pass, 0 fail, 19 skip. Broken by hand: the new tests against the old index.mjs,
cloak.mjs and middleware: 6 fail.

Not tried: omp itself end to end on Windows. Also seen in the same probe:
Claude Code's, Codex's and Hermes' broken-up lines were each refused 1-2
times in 10; filed as #1118.
2026-11-14 09:03:51 +08:00

118 lines
6.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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,
// 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
// 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 = "​"
// 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 TURNED_AWAY_RE = TURNED_AWAY.map(lineRe)
const has = (s, re) => {
re.lastIndex = 0
const yes = re.test(s)
re.lastIndex = 0
return yes
}
const said = (system, line) => has(system, TURNED_AWAY_RE[TURNED_AWAY.indexOf(line)])
export function turnsAway(system) {
const s = String(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).
const SAID_AS = {
"rfc 2119 keywords: must, required, should, recommended, may, optional.": (line) => line.replace(/(key)(words)/i, "$1 $2"),
}
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])
})
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))
prev = to
}
return out + system.slice(prev)
}
// REWORDED are paragraphs that go through but are answered badly, each with
// a rewording that keeps its meaning. DeepSeek Harness's desktop app puts
// the first in every system prompt; word for word, gemini-4-argon answered
// most requests in about 3s with no thinking and ended after one shallow
// step (antigravity #1028).
export const REWORDED = [
[
"Tokens prefixed with @ are paths the user explicitly referenced. Relative paths resolve from the workspace root; absolute paths identify files or directories on the host. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @\"...\" quotes a path containing spaces.",
"When 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 @\"...\".",
],
]
export function reword(system) {
if (typeof system !== "string") return system
for (const [from, to] of REWORDED) if (system.includes(from)) system = system.split(from).join(to)
return system
}
// outgoing is system text as agy is handed it: broken up, then reworded
export const outgoing = (system) => reword(cloak(system))
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 sends that line as \"RFC 2119 key words: …\", which goes through, so this one came from a copy of it that was worded another way"
export function hint(system) {
system = String(system ?? "")
if (said(system, "rfc 2119 keywords: must, required, should, recommended, may, optional.")) return RFC_HINT
if (said(system, "you are codex, an agent based on gpt-5") || said(system, "you are codex, a coding agent based on gpt-5")) return CODEX_HINT
if (said(system, "hermes agent, an intelligent ai assistant created by nous research")) return HERMES_HINT
return HINT
}