agy-cli 0.1.95: agy's high-traffic ending is a 503, and 1.5.10's ban wording a 403

When Google had no capacity for the model, agy ended the reply with
"⚠ Our servers are experiencing high traffic right now, please try again
in a minute. (UNAVAILABLE (code 503): No capacity available for model …)".
The bridge passed it on as the whole reply, a 200, so nothing behind
magpie tried again. ifccod found this and patched it in their fork
(ifccod/opencode-agy-cli-auth, MIT, FORK.md "Busy ending"). Their code
is ported here: the ending is held and matched by its start, the way the
quota ending is, and it ends the turn as overloaded_error with status
503 (HTTP 503 without streaming). Retrying is allowed, and the account is
not rested.

agy 1.5.10 words a banned account's 403 without the
"PERMISSION_DENIED (code 403):" that 1.5.9 put in front. A real banned
account was probed over ACP on 11-18: the whole reply was that sentence,
end_turn, a 200. The bare sentence is now a marker, answered with the
same no-retry permission_error 403 as #1201.

Not taken from the fork: its video path. That path has agy's server-side
read_file open videos downloaded into a media folder added with
--add-dir, and it lets any gateway caller have agy read paths on the
host. It was not tried with a real account either, since the probe
account is banned.

Run (mica, HOME=$(mktemp -d), at 89df5a62+this diff):
- packages/agy-cli/test repeat-batch.mjs: 79 pass, 0 fail. usage.mjs
  (cp-hook preload): 44 pass.
- The new tests on the old index.mjs, by hand: 3 of the 4 fail (busy
  stream, busy non-stream 503, 1.5.10 ban). The quoting test passes on
  both, as it should.
- Root bun test: 9070 tests, 0 fail, 20 skip (487s).

Not tried: a real high-traffic ending; it is taken from ifccod's capture.

Co-authored-by: ifccod <102718410+ifccod@users.noreply.github.com>
This commit is contained in:
yetone
2026-11-18 16:14:01 +08:00
co-authored by ifccod
parent 89df5a62c5
commit c18d87f743
5 changed files with 133 additions and 12 deletions
+85
View File
@@ -1371,6 +1371,91 @@ test("the model quoting the Individual quota reached ending with more text after
}
})
// ifccod (opencode-agy-cli-auth FORK.md, 11-18): when every retry met
// Google's "no capacity" 503, agy ended the reply with this notice, and the
// client got it as the whole answer, a 200 nothing behind magpie retried.
const BUSY_LINE = "⚠ Our servers are experiencing high traffic right now, please try again in a minute. (UNAVAILABLE (code 503): No capacity available for model gemini-3.8-flash-high on the server)"
const BUSY = "\n" + BUSY_LINE + "\n"
test("agy's high-traffic ending fails the turn as an overloaded 503, not a rate limit", async () => {
for (const chunks of [
[BUSY],
[BUSY.slice(0, 9), BUSY.slice(9, 47), BUSY.slice(47)],
[BUSY_LINE],
]) {
await withKit({}, async (kit) => {
markerAgent(kit, chunks)
const response = await kit.request(baseBody({ metadata: { user_id: "busy-end" },
messages: [{ role: "user", content: "hello" }] }))
const text = await response.text()
const error = sseError(text)
assert.equal(error.type, "overloaded_error")
assert.equal(error.status, 503)
assert.notEqual(error.noRetry, true)
assert.equal(error.message, "agy bridge: Antigravity has no capacity for this model now: " + BUSY_LINE.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 high-traffic ending fails a non-stream request as an HTTP 503", async () => {
await withKit({}, async (kit) => {
markerAgent(kit, ["Let me look", BUSY.slice(0, 30), BUSY.slice(30)])
const response = await kit.request(baseBody({ metadata: { user_id: "busy-json" },
messages: [{ role: "user", content: "hello" }], stream: false }))
const body = await response.json()
assert.equal(response.status, 503)
assert.equal(response.headers.get("x-should-retry"), null)
assert.equal(body.error.type, "overloaded_error")
assert.match(body.error.message, /No capacity available for model gemini-3\.8-flash-high/)
})
})
test("the model quoting the high-traffic ending with more text after keeps it", async () => {
for (const chunks of [
["agy said\n⚠ Our servers are experiencing", " high traffic right now, please try again.\nThat line is agy's, not mine."],
["agy prints `⚠ Our servers are experiencing high traffic right now` when Google is full."],
]) {
await withKit({}, async (kit) => {
markerAgent(kit, chunks)
const parsed = await readSse(await kit.request(baseBody({ metadata: { user_id: "busy-quoted" },
messages: [{ role: "user", content: "what did agy print?" }] })))
assert.equal(parsed.error, null)
assert.equal(replyText(parsed), chunks.join(""))
})
}
})
// agy 1.5.10, a banned account (seen on a real one, 11-18): Google's
// sentence without the "PERMISSION_DENIED (code 403):" 1.5.9 put before it,
// and the whole reply was that line, a 200.
const BANNED_1510 = "\n⚠ This service has been disabled in this account for violation of Terms of Service. Please submit an appeal to continue using this product.\n"
test("agy 1.5.10's banned-account ending fails the turn as a no-retry 403, streamed or not", async () => {
await withKit({}, async (kit) => {
markerAgent(kit, [BANNED_1510.slice(0, 20), BANNED_1510.slice(20)])
const response = await kit.request(baseBody({ metadata: { user_id: "banned-1510" },
messages: [{ role: "user", content: "hello" }] }))
const text = await response.text()
const error = sseError(text)
assert.equal(error.type, "permission_error")
assert.equal(error.status, 403)
assert.equal(error.noRetry, true)
assert.match(error.message, /disabled this account's access[\s\S]*Terms of Service[\s\S]*appeal/)
assert.ok(!text.includes("⚠"), "no banner reaches the client")
})
await withKit({}, async (kit) => {
markerAgent(kit, [BANNED_1510.trim()])
const response = await kit.request(baseBody({ metadata: { user_id: "banned-1510-json" },
messages: [{ role: "user", content: "hello" }], stream: false }))
const body = await response.json()
assert.equal(response.status, 403)
assert.equal(response.headers.get("x-should-retry"), "false")
assert.equal(body.error.type, "permission_error")
})
})
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) => {