agy-cli 0.1.87: agy's Individual quota reached ending fails the turn as a rate limit

@Airan_FS on X (11-17): when an Antigravity account's own quota is used up,
agy ends the turn with "⚠ Individual quota reached. Please upgrade your
subscription to increase your limits. Resets in 1h18m40s." The bridge only
knew fixed ending lines, so this one went to the client as the model's
reply and magpie never asked the next account.

The bridge now holds a line starting "⚠ Individual quota reached" that
nothing follows, and ends the turn with a rate_limit_error carrying agy's
words and the reset ("agy bridge: Antigravity quota reached: Individual
quota reached. ... Resets in 1h18m40s."; HTTP 429 without streaming).
Words the model wrote before it still reach the client. A quote of the line
with more text after it stays text. magpie rests the account until the
reset it reads from the error (magpie's routing.go change in the same fix).

The words are from a user's report on discuss.ai.google.dev (limit
membingungkan) and @Airan_FS's tweet; the agy binary carries "individual
quota reached".

Run (mote, HOME=$(mktemp -d)): bun test agy-cli.test.mjs 20 pass, 0 fail;
node --test repeat-batch.mjs smoke.mjs 72 pass, 0 fail; bun scripts/check.mjs
ok.

Broken by hand: 0.1.86's index.mjs with these tests: three of the four new
tests fail (the ending alone, after partial text, non-stream 429); the
quoted-line test passes on both.

Not tried: a real agy account with its quota used up.
This commit is contained in:
yetone
2026-11-17 03:56:04 +08:00
parent 38233a569c
commit afe4c08643
5 changed files with 114 additions and 4 deletions
+4
View File
@@ -356,6 +356,10 @@ off unless you turn it on.
`permission_error` with 403 semantics, not as normal reply text. So is the
"Verification Required" ending (Google wants the account verified), with
the link to verify it at when agy logged one, else where to verify it.
The "⚠ Individual quota reached. … Resets in 1h18m40s." ending (the
account's own quota is used up) ends the turn as a rate limit
(`rate_limit_error`, HTTP 429 without streaming) carrying agy's words and
reset, so magpie rests the account until then and asks the next one.
- **HTTP 409 saying tool results do not match the history**: usually the client
rewrote the history or tool IDs mid-conversation. When the plugin can work out
the correct match it rebuilds the session; when it cannot, it refuses rather
+3
View File
@@ -255,6 +255,9 @@ agy 自己的系统提示词,只剩插件的一行工具说明和客户端的
violation of Terms of Service",会按禁止重试的 403 语义 `permission_error` 返回,而不是
当成正常正文。结尾是 "Verification Required"(Google 要求先验证这个账号)时也一样,
并带上 agy 记下的验证链接;没有链接时说明去哪里验证。
结尾是 "⚠ Individual quota reached. … Resets in 1h18m40s."(这个账号自己的额度用完)时,
按额度不足(`rate_limit_error`,非流式为 HTTP 429)结束本轮,原文和重置时间一并带上,
magpie 据此让这个账号歇到重置,并改问下一个账号。
- **HTTP 409,提示工具结果与历史对不上**:通常是客户端在对话中途改写了历史或工具 ID。
能确定对应关系时插件会重建会话;无法确定时直接拒绝,不做猜测。
Hermes Agent 会把一次批量的 `tool_call({"calls": [...]})` 在自己的历史里拆成每项一次调用,
+39 -3
View File
@@ -132,6 +132,15 @@ const AGENT_ERROR_MARKERS = [
"\n⚠ Verification Required\n",
]
const AGENT_ERROR_CORES = AGENT_ERROR_MARKERS.map((marker) => marker.trim())
// agy's ending for an account whose own quota is used up, with Google's
// time until it is back on the same line: "⚠ Individual quota reached.
// Please upgrade your subscription to increase your limits. Resets in
// 1h18m40s." Its tail changes, so it is matched by its start, as a line of
// its own that nothing follows. Answered as text, it was the whole reply
// and the next account was never asked (@Airan_FS on X, 11-17).
const QUOTA_CORE = "⚠ Individual quota reached"
const QUOTA_MARKER = "\n" + QUOTA_CORE
const quotaReached = (detail) => /\bindividual quota reached\b/i.test(detail || "")
const CREDITS_CORE = AGENT_ERROR_CORES[2]
const VERIFY_CORE = AGENT_ERROR_CORES[5]
// agy 1.5.8 writes each failed attempt of a model call into the reply as one
@@ -161,7 +170,7 @@ const CAP_TAIL_CORE = "Please continue from where you left off, keeping your res
const CAP_RETRIES_CORE = "Retries remaining: "
const CAP_RETRIES_LINE = /^Retries remaining: ?\d+\.?$/
const HOLD_MAX = Math.max(
...AGENT_ERROR_MARKERS.map((marker) => marker.length), CAP_MARKER.length, CAP_TAIL_CORE.length,
...AGENT_ERROR_MARKERS.map((marker) => marker.length), CAP_MARKER.length, CAP_TAIL_CORE.length, QUOTA_MARKER.length,
) - 1
// Opt-in. The minimal agent drops agy's own prompt components (~8,400 input
// tokens a model call, against ~500 without them), so the request goes upstream
@@ -1665,9 +1674,15 @@ class Turn {
return
}
}
const quota = this.quotaEnding(text)
if (quota >= 0) {
this.heldText = text.slice(quota)
this.emitText(text.slice(0, quota))
return
}
for (let keep = Math.min(text.length, HOLD_MAX); keep > 0; keep--) {
const tail = text.slice(-keep)
if (AGENT_ERROR_MARKERS.some((marker) => marker.startsWith(tail)) ||
if (AGENT_ERROR_MARKERS.some((marker) => marker.startsWith(tail)) || QUOTA_MARKER.startsWith(tail) ||
(keep > 1 && (RETRY_MARKER.startsWith(tail) || ATTEMPT_MARKER.startsWith(tail) ||
CAP_MARKER.startsWith(tail)))) {
this.heldText = tail
@@ -1678,6 +1693,17 @@ class Turn {
this.emitText(text)
}
// Where agy's quota ending (QUOTA_CORE) starts in text, with the newline
// before it: a line of its own that only whitespace follows, so far. -1
// when there is none; one more text follows was the model quoting it.
quotaEnding(text) {
const at = text.lastIndexOf(QUOTA_CORE)
if (at < 0) return -1
const lineStart = at > 0 ? text[at - 1] === "\n" : this.textTail === "" || this.textTail === "\n"
if (!lineStart || text.slice(at).trimEnd().includes("\n")) return -1
return at > 0 ? at - 1 : at
}
// Removes agy's retry banners, each with its leading and one trailing
// newline, wherever one starts a line: the one-line retry and attempt
// banners, and the three-line output-cap notice (#892). Text that only
@@ -1755,6 +1781,11 @@ class Turn {
this.agentError = true
this.agentErrorCore = core
this.heldText = ""
} else if (this.quotaEnding(this.heldText) >= 0) {
this.agentError = true
this.agentErrorCore = QUOTA_CORE
this.quotaNotice = this.heldText.trim().replace(/^⚠ /, "")
this.heldText = ""
}
}
@@ -2516,6 +2547,11 @@ class Proc {
async #agentError(turn) {
const core = turn.agentErrorCore
if (core === QUOTA_CORE) {
// Google's own words, the reset with them: magpie rests the account
// until then and asks the next one
return new AgentTurnError(`agy bridge: Antigravity quota reached: ${turn.quotaNotice}`, "rate_limit_error")
}
if (core === VERIFY_CORE) {
// the link, when agy logged Google's error whole; the reply has none
const logged = await logTail(this.logPath, turn.logOffset)
@@ -2541,7 +2577,7 @@ class Proc {
"invalid_request_error",
)
}
if (/QUOTA_EXHAUSTED|RESOURCE_EXHAUSTED|MODEL_CAPACITY_EXHAUSTED|code 429\b/i.test(detail)) {
if (/QUOTA_EXHAUSTED|RESOURCE_EXHAUSTED|MODEL_CAPACITY_EXHAUSTED|code 429\b/i.test(detail) || quotaReached(detail)) {
return new AgentTurnError(
`agy bridge: Antigravity quota or rate limit reached${detail ? ": " + detail : ""}${refused429(detail) ? " — Antigravity answers this same bare 429 to a system prompt it turns away whatever quota is left, so if quota is left it is not a quota and waiting won't help: something in this agent's system prompt is being matched" : ""}`,
"rate_limit_error",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-agy-cli-auth",
"version": "0.1.86",
"version": "0.1.87",
"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",
+67
View File
@@ -1208,6 +1208,73 @@ test("the model quoting the Verification Required ending with more text after ke
})
})
// @Airan_FS on X (11-17): an account out of its own quota got agy's
// ending as the whole reply, and magpie never asked the next account. The
// line is Google's words with the time until the quota is back.
const QUOTA_LINE = "⚠ Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 1h18m40s."
const QUOTA = "\n" + QUOTA_LINE + "\n"
test("agy's Individual quota reached ending fails the turn as a rate limit with its reset", async () => {
for (const chunks of [
[QUOTA],
[QUOTA.slice(0, 12), QUOTA.slice(12, 40), QUOTA.slice(40)],
[QUOTA_LINE],
["\n⚠ Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 6d2h."],
]) {
await withKit({}, async (kit) => {
markerAgent(kit, chunks)
const response = await kit.request(baseBody({ metadata: { user_id: "quota-end" },
messages: [{ role: "user", content: "hello" }] }))
const text = await response.text()
const error = sseError(text)
assert.equal(error.type, "rate_limit_error")
assert.equal(error.message, "agy bridge: Antigravity quota reached: " + chunks.join("").trim().replace(/^⚠ /, ""))
assert.ok(!text.includes("⚠"), "no banner reaches the client")
assert.ok(!text.includes("text_delta"), "nothing of it went as the reply")
})
}
})
test("agy's Individual quota reached ending after words the model wrote keeps them and fails the turn", async () => {
await withKit({}, async (kit) => {
markerAgent(kit, ["Let me look", QUOTA.slice(0, 30), QUOTA.slice(30)])
const response = await kit.request(baseBody({ metadata: { user_id: "quota-partial" },
messages: [{ role: "user", content: "hello" }] }))
const text = await response.text()
const parsed = await readSse(new Response(text))
assert.equal(replyText(parsed), "Let me look")
assert.equal(sseError(text).type, "rate_limit_error")
assert.match(sseError(text).message, /Resets in 1h18m40s\.$/)
})
})
test("agy's Individual quota reached ending fails a non-stream request as an HTTP 429", async () => {
await withKit({}, async (kit) => {
markerAgent(kit, [QUOTA])
const response = await kit.request(baseBody({ metadata: { user_id: "quota-json" },
messages: [{ role: "user", content: "hello" }], stream: false }))
const body = await response.json()
assert.equal(response.status, 429)
assert.equal(body.error.type, "rate_limit_error")
assert.match(body.error.message, /Individual quota reached\. .*Resets in 1h18m40s\./)
})
})
test("the model quoting the Individual quota reached ending with more text after keeps it", async () => {
for (const chunks of [
["agy said\n⚠ Individual quota", " reached. Please upgrade. Resets in 1h.\nThat line is agy's, not mine."],
["agy prints `⚠ Individual quota reached. Resets in 1h.` when it is out."],
]) {
await withKit({}, async (kit) => {
markerAgent(kit, chunks)
const parsed = await readSse(await kit.request(baseBody({ metadata: { user_id: "quota-quoted" },
messages: [{ role: "user", content: "what did agy print?" }] })))
assert.equal(parsed.error, null)
assert.equal(replyText(parsed), chunks.join(""))
})
}
})
test("#1151: the model quoting the 429 ending with more text after keeps it", async () => {
const chunks = ["agy ended with\n⚠ RESOURCE_EXHAUSTED (code 429): Resource has", " been exhausted (e.g. check quota).\nThat line is agy's, not mine."]
await withKit({}, async (kit) => {