agy-cli: a 429 to the reworded prompt in the user turn is a rate limit, not a 400 (0.1.90)
HadStash on X (11-17, Google AI Ultra trial, agy-cli) got "agy bridge: Antigravity answered 429 to this system prompt: RESOURCE_EXHAUSTED (code 429)" as an Anthropic invalid_request_error, while the same account works in the Antigravity client. #formatAgentError called any bare 429 a prompt rejection when the RAW client prompt has a line Antigravity turns away (turnsAway). Claude Code's identity line is always there, so every 429 in a Claude Code session was a 400 the client never retries and a gateway group doesn't treat as a limit, even though what was sent was reworded (cloak.mjs) and sits in the first user turn, the default since 11-15. Now that label is given only when the instructions went in agy's session instructions (AGY_BRIDGE_SYSTEM_APPEND=1), where the reworded prompt is still turned away; in the user turn the 429 is a rate_limit_error (with the existing "not a quota" note for the bare 429), so Claude Code retries it and a group asks the next member. The turn still ends at agy's first 429 banner (Lmohn39), so nothing waits. Real probes, account kumw95ya25, Code Assist direct (plug-raw), Claude Code 2.1.326's captured prompt (SDK and CLI identity), 2 tries each: - raw in system: refused 429 (gemini-3.8-flash) - outgoing() in system: 429 2/2 on gemini-3.8-flash and claude-sonnet-4-6 - outgoing() in the user turn: 200 2/2 on both models - user turn + Claude Code's 12 tools as function declarations: 200 2/2 Control prompt: 200 2/2. Tests: repeat-batch's Lmohn39 test now runs the session-instructions path (testkit's new `appendable`) for the 400 and the user-turn path for the rate limit, Claude Code's identity line included; smoke's #980 case sets AGY_BRIDGE_SYSTEM_APPEND=1 and a new HadStash case checks the user-turn 429. Broken by hand: against origin/main's index.mjs both are red (repeat-batch 1 fail, smoke "BAD - HadStash ..."). Run on mote at this tree (HOME=$(mktemp -d)): bun scripts/check.mjs ok; bun test 9040 pass, 1 fail: agy-cli test/usage.mjs "a hung sign-in with an ended token is never restarted ..." at its 6s deadline, which is #1191 (usage.mjs red on macOS under load, the failing tests change each run; alone it went 5 of 41 red, other tests). Not this change: usage.mjs doesn't reach #formatAgentError. Not tried: the reporter's own account or agent (they don't say which; the Anthropic-shaped error says a /v1/messages client). agy itself was not run end to end: the Mac's agy account is disabled by Google, so the probes went to Code Assist directly with agy-cli's cloak.mjs.
This commit is contained in:
@@ -298,8 +298,11 @@ Antigravity provider does (`cloak.mjs`). Codex's two GPT-5 lines
|
|||||||
("You are Codex, a coding agent based on GPT-5", "You are Codex, an agent based on GPT-5")
|
("You are Codex, a coding agent based on GPT-5", "You are Codex, an agent based on GPT-5")
|
||||||
are turned away in a user's turn too (AGENTS.md, a `<system-reminder>`),
|
are turned away in a user's turn too (AGENTS.md, a `<system-reminder>`),
|
||||||
so they go as "built on GPT-5" there as well. Zero-width spaces no longer help:
|
so they go as "built on GPT-5" there as well. Zero-width spaces no longer help:
|
||||||
since 11-14 Google's check reads past them. Should such a 429 still come
|
since 11-14 Google's check reads past them. Reworded in the first user turn
|
||||||
back, it is reported as a 400 about the prompt, not as a quota.
|
(the default), Claude Code's prompt is answered; in agy's session
|
||||||
|
instructions (`AGY_BRIDGE_SYSTEM_APPEND=1`) it is still turned away. So a
|
||||||
|
bare 429 there is reported as a 400 about the prompt, and in the user turn
|
||||||
|
as a rate limit the client can retry or another account can take.
|
||||||
|
|
||||||
DeepSeek Harness's paragraph on `@` paths ("Tokens prefixed with @ are
|
DeepSeek Harness's paragraph on `@` paths ("Tokens prefixed with @ are
|
||||||
paths…") goes reworded with the same meaning, as the Antigravity provider
|
paths…") goes reworded with the same meaning, as the Antigravity provider
|
||||||
|
|||||||
@@ -214,8 +214,9 @@ agent that helps users with software engineering tasks.",改成 "You're …"
|
|||||||
|
|
||||||
Antigravity 对几行系统提示词(Claude Code 的计费行、Claude Agent SDK、Codex、Hermes Agent、OpenCode
|
Antigravity 对几行系统提示词(Claude Code 的计费行、Claude Agent SDK、Codex、Hermes Agent、OpenCode
|
||||||
和 pi 的身份句、oh-my-pi 的 RFC 2119 行)不论余量多少都回 429 "Resource has been exhausted"。插件在
|
和 pi 的身份句、oh-my-pi 的 RFC 2119 行)不论余量多少都回 429 "Resource has been exhausted"。插件在
|
||||||
agy 发出之前去掉计费那一行,其余几行换成同义的说法("built on the Claude Agent SDK by Anthropic"、"built on GPT-5"、"RFC 2119 key words: …"、"You're Hermes Agent / OpenCode / a coding agent running in the Codex CLI"、"running within pi"),和 Antigravity 提供商的做法一样(`cloak.mjs`)。Codex 的两句 GPT-5 行("You are Codex, a coding agent based on GPT-5"、"You are Codex, an agent based on GPT-5")出现在用户的轮次里(AGENTS.md、`<system-reminder>`)也会被拒,所以用户轮次里也换成 "built on GPT-5"。零宽空格已经没用:11-14 起 Google 的检查会忽略它们。如果仍然
|
agy 发出之前去掉计费那一行,其余几行换成同义的说法("built on the Claude Agent SDK by Anthropic"、"built on GPT-5"、"RFC 2119 key words: …"、"You're Hermes Agent / OpenCode / a coding agent running in the Codex CLI"、"running within pi"),和 Antigravity 提供商的做法一样(`cloak.mjs`)。Codex 的两句 GPT-5 行("You are Codex, a coding agent based on GPT-5"、"You are Codex, an agent based on GPT-5")出现在用户的轮次里(AGENTS.md、`<system-reminder>`)也会被拒,所以用户轮次里也换成 "built on GPT-5"。零宽空格已经没用:11-14 起 Google 的检查会忽略它们。改写后放在第一条用户消息里(默认做法),Claude Code
|
||||||
回了这样的 429,会报成针对提示词的 400,而不是额度用完。
|
的提示词能正常回答;放在 agy 的会话指令里(`AGY_BRIDGE_SYSTEM_APPEND=1`)仍然被拒。所以后者回的 429 报成针对
|
||||||
|
提示词的 400,前者报成限流,客户端可以重试,或交给别的账号。
|
||||||
|
|
||||||
DeepSeek Harness 的 `@` 路径说明段("Tokens prefixed with @ are paths…")也和 Antigravity 提供商一样
|
DeepSeek Harness 的 `@` 路径说明段("Tokens prefixed with @ are paths…")也和 Antigravity 提供商一样
|
||||||
换成同义的说法再发:原文照发时 `gemini-4-argon` 大多很快答完、不思考、只走一步(#1028)。
|
换成同义的说法再发:原文照发时 `gemini-4-argon` 大多很快答完、不思考、只走一步(#1028)。
|
||||||
|
|||||||
@@ -2625,8 +2625,14 @@ class Proc {
|
|||||||
#formatAgentError(detail) {
|
#formatAgentError(detail) {
|
||||||
// The system prompt turned away, not a quota (cloak.mjs): a 400 the next
|
// The system prompt turned away, not a quota (cloak.mjs): a 400 the next
|
||||||
// member of a group is asked after, and the client doesn't retry. It says
|
// member of a group is asked after, and the client doesn't retry. It says
|
||||||
// what Antigravity answered (a 429).
|
// what Antigravity answered (a 429). Only where the cloak isn't enough:
|
||||||
if (/code 429\b/i.test(detail) && /resource has been exhausted/i.test(detail) && turnsAway(this.instructions)) {
|
// in agy's session instructions (AGY_BRIDGE_SYSTEM_APPEND=1) Antigravity
|
||||||
|
// still turns the reworded Claude Code prompt away, while the same
|
||||||
|
// reworded prompt in the first user turn, where it goes by default, is
|
||||||
|
// answered (HadStash on X, 11-17). There a bare 429 is a rate limit the
|
||||||
|
// client may retry, or the next member is asked after, not a 400.
|
||||||
|
if (/code 429\b/i.test(detail) && /resource has been exhausted/i.test(detail) &&
|
||||||
|
this.instructionsInSession && turnsAway(this.instructions)) {
|
||||||
return new AgentTurnError(
|
return new AgentTurnError(
|
||||||
`agy bridge: Antigravity answered 429 to this system prompt: ${detail} — ${hint(this.instructions)}`,
|
`agy bridge: Antigravity answered 429 to this system prompt: ${detail} — ${hint(this.instructions)}`,
|
||||||
"invalid_request_error",
|
"invalid_request_error",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@magpie-community/opencode-agy-cli-auth",
|
"name": "@magpie-community/opencode-agy-cli-auth",
|
||||||
"version": "0.1.89",
|
"version": "0.1.90",
|
||||||
"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",
|
"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",
|
"type": "module",
|
||||||
"main": "./opencode.mjs",
|
"main": "./opencode.mjs",
|
||||||
|
|||||||
@@ -1305,13 +1305,23 @@ const REFUSED_ATTEMPT = (n) => `\n⚠ API error (attempt ${n}): RESOURCE_EXHAUST
|
|||||||
|
|
||||||
test("Lmohn39: a try answered with the bare 429 ends the turn at once, not after agy's retries", async () => {
|
test("Lmohn39: a try answered with the bare 429 ends the turn at once, not after agy's retries", async () => {
|
||||||
const PI = "You are a coding assistant running inside pi, a coding agent harness. Help users inspect files, run commands, and modify code."
|
const PI = "You are a coding assistant running inside pi, a coding agent harness. Help users inspect files, run commands, and modify code."
|
||||||
for (const [system, chunks, want, kind] of [
|
// HadStash on X (11-17): Claude Code through agy-cli got "answered 429 to
|
||||||
|
// this system prompt", a 400 it never retries, though its prompt goes
|
||||||
|
// reworded in the first user turn, where Antigravity answers it
|
||||||
|
const CLAUDE_CODE = "You are Claude Code, Anthropic's official CLI for Claude.\n\nHelp the user."
|
||||||
|
const APPEND = { appendable: true, env: { AGY_BRIDGE_SYSTEM_APPEND: "1" } }
|
||||||
|
for (const [options, system, chunks, want, kind] of [
|
||||||
|
// in the session instructions the cloak isn't enough: a prompt rejection
|
||||||
// the banner's line still open while agy waits to try again
|
// the banner's line still open while agy waits to try again
|
||||||
[PI, [REFUSED_ATTEMPT(1)], /answered 429 to this system prompt: RESOURCE_EXHAUSTED \(code 429\).*pi's default system prompt/, "invalid_request_error"],
|
[APPEND, PI, [REFUSED_ATTEMPT(1)], /answered 429 to this system prompt: RESOURCE_EXHAUSTED \(code 429\).*pi's default system prompt/, "invalid_request_error"],
|
||||||
[PI, [REFUSED_ATTEMPT(1).slice(0, 40), REFUSED_ATTEMPT(1).slice(40) + "\n"], /answered 429 to this system prompt/, "invalid_request_error"],
|
[APPEND, PI, [REFUSED_ATTEMPT(1).slice(0, 40), REFUSED_ATTEMPT(1).slice(40) + "\n"], /answered 429 to this system prompt/, "invalid_request_error"],
|
||||||
["You are a test agent.", ["partial", REFUSED_ATTEMPT(1)], /quota or rate limit reached: RESOURCE_EXHAUSTED \(code 429\).*not a quota/, "rate_limit_error"],
|
[APPEND, CLAUDE_CODE, [REFUSED_ATTEMPT(1)], /answered 429 to this system prompt/, "invalid_request_error"],
|
||||||
|
// reworded in the first user turn (the default): a rate limit
|
||||||
|
[{}, CLAUDE_CODE, [REFUSED_ATTEMPT(1)], /quota or rate limit reached: RESOURCE_EXHAUSTED \(code 429\).*not a quota/, "rate_limit_error"],
|
||||||
|
[{}, PI, [REFUSED_ATTEMPT(1)], /quota or rate limit reached: RESOURCE_EXHAUSTED \(code 429\)/, "rate_limit_error"],
|
||||||
|
[{}, "You are a test agent.", ["partial", REFUSED_ATTEMPT(1)], /quota or rate limit reached: RESOURCE_EXHAUSTED \(code 429\).*not a quota/, "rate_limit_error"],
|
||||||
]) {
|
]) {
|
||||||
await withKit({}, async (kit) => {
|
await withKit(options, async (kit) => {
|
||||||
let tries = 0
|
let tries = 0
|
||||||
kit.defaultPrompt = async (agent) => {
|
kit.defaultPrompt = async (agent) => {
|
||||||
tries++
|
tries++
|
||||||
@@ -1325,7 +1335,10 @@ test("Lmohn39: a try answered with the bare 429 ends the turn at once, not after
|
|||||||
assert.equal(tries, 1)
|
assert.equal(tries, 1)
|
||||||
assert.match(text, want)
|
assert.match(text, want)
|
||||||
assert.ok(text.includes(kind), `${kind} in ${text.slice(-400)}`)
|
assert.ok(text.includes(kind), `${kind} in ${text.slice(-400)}`)
|
||||||
|
assert.ok(!text.includes("answered 429 to this system prompt") || kind === "invalid_request_error", text.slice(-400))
|
||||||
assert.ok(!text.includes("⚠"), "no banner reaches the client")
|
assert.ok(!text.includes("⚠"), "no banner reaches the client")
|
||||||
|
// where the instructions went
|
||||||
|
assert.equal(prompts(kit).join("").includes("<external_system_instructions>"), !options.appendable)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1577,6 +1577,8 @@ for (const [title, tools, want, name] of [
|
|||||||
!prompted.includes(rfc) && !prompted.includes(sdk) && !prompted.includes(zw) && prompted.includes(want), JSON.stringify(prompted))
|
!prompted.includes(rfc) && !prompted.includes(sdk) && !prompted.includes(zw) && prompted.includes(want), JSON.stringify(prompted))
|
||||||
delete process.env.FAKE_AGY_APPEND
|
delete process.env.FAKE_AGY_APPEND
|
||||||
|
|
||||||
|
// in agy's session instructions the reworded prompt is still turned away
|
||||||
|
process.env.AGY_BRIDGE_SYSTEM_APPEND = "1"
|
||||||
const turned = (await readSSE(await callFetch({ model, system: system + " T429", messages: [{ role: "user", content: "TURNED429 please" }] }))).events
|
const turned = (await readSSE(await callFetch({ model, system: system + " T429", messages: [{ role: "user", content: "TURNED429 please" }] }))).events
|
||||||
const turnedError = turned.find(event => event.event === "error")?.data?.error
|
const turnedError = turned.find(event => event.event === "error")?.data?.error
|
||||||
check("#980 a 429 to a turned-away prompt is a prompt rejection, not a quota",
|
check("#980 a 429 to a turned-away prompt is a prompt rejection, not a quota",
|
||||||
@@ -1590,6 +1592,14 @@ for (const [title, tools, want, name] of [
|
|||||||
const turnedWholeBody = await turnedWhole.json()
|
const turnedWholeBody = await turnedWhole.json()
|
||||||
check("#1151 a turned-away prompt asked for a whole reply is a 400",
|
check("#1151 a turned-away prompt asked for a whole reply is a 400",
|
||||||
turnedWhole.status === 400 && turnedWholeBody?.error?.type === "invalid_request_error", JSON.stringify({ status: turnedWhole.status, body: turnedWholeBody }))
|
turnedWhole.status === 400 && turnedWholeBody?.error?.type === "invalid_request_error", JSON.stringify({ status: turnedWhole.status, body: turnedWholeBody }))
|
||||||
|
delete process.env.AGY_BRIDGE_SYSTEM_APPEND
|
||||||
|
// HadStash on X (11-17): reworded in the first user turn, where it goes by
|
||||||
|
// default, Antigravity answers it, so a 429 there is a rate limit
|
||||||
|
const inTurn = (await readSSE(await callFetch({ model, system: system + " T429U", messages: [{ role: "user", content: "TURNED429 in turn" }] }))).events
|
||||||
|
const inTurnError = inTurn.find(event => event.event === "error")?.data?.error
|
||||||
|
check("HadStash a 429 to the reworded prompt in the user turn is a rate limit, not a prompt rejection",
|
||||||
|
inTurnError?.type === "rate_limit_error" && !inTurnError.message.includes("answered 429 to this system prompt") &&
|
||||||
|
inTurnError.status === undefined, JSON.stringify(inTurnError))
|
||||||
const quota = (await readSSE(await callFetch({ model, system: "CLOAK-QUOTA", messages: [{ role: "user", content: "TURNED429 plain" }] }))).events
|
const quota = (await readSSE(await callFetch({ model, system: "CLOAK-QUOTA", messages: [{ role: "user", content: "TURNED429 plain" }] }))).events
|
||||||
const quotaError = quota.find(event => event.event === "error")?.data?.error
|
const quotaError = quota.find(event => event.event === "error")?.data?.error
|
||||||
check("#980 the same 429 to any other prompt is still a rate limit", quotaError?.type === "rate_limit_error" && quotaError.status === undefined, JSON.stringify(quotaError))
|
check("#980 the same 429 to any other prompt is still a rate limit", quotaError?.type === "rate_limit_error" && quotaError.status === undefined, JSON.stringify(quotaError))
|
||||||
|
|||||||
@@ -265,7 +265,11 @@ class FakeAgy {
|
|||||||
this.respond(id, {
|
this.respond(id, {
|
||||||
protocolVersion: 1,
|
protocolVersion: 1,
|
||||||
agentInfo: { name: "fake-agy", version: this.kit.agentVersion },
|
agentInfo: { name: "fake-agy", version: this.kit.agentVersion },
|
||||||
agentCapabilities: this.kit.sessionResume ? { sessionCapabilities: { resume: {} } } : {},
|
agentCapabilities: {
|
||||||
|
...(this.kit.sessionResume ? { sessionCapabilities: { resume: {} } } : {}),
|
||||||
|
// agy 1.5's session instructions (AGY_BRIDGE_SYSTEM_APPEND=1)
|
||||||
|
...(this.kit.appendable ? { _meta: { antigravity: { systemPrompt: { append: true } } } } : {}),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// agy's own start: spawn to initialize is ~0.25s warm, ~1s cold on Linux
|
// agy's own start: spawn to initialize is ~0.25s warm, ~1s cold on Linux
|
||||||
@@ -484,6 +488,7 @@ export async function createBridgeKit(options = {}) {
|
|||||||
initializeDelayMs: options.initializeDelayMs ?? 0,
|
initializeDelayMs: options.initializeDelayMs ?? 0,
|
||||||
initialized: 0,
|
initialized: 0,
|
||||||
sessionResume: options.sessionResume ?? false,
|
sessionResume: options.sessionResume ?? false,
|
||||||
|
appendable: options.appendable ?? false,
|
||||||
listTools: options.listTools ?? true,
|
listTools: options.listTools ?? true,
|
||||||
watchTools: options.watchTools ?? true,
|
watchTools: options.watchTools ?? true,
|
||||||
listings: [],
|
listings: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user