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:
@@ -367,7 +367,8 @@ off unless you turn it on.
|
||||
the output token limit", its instruction to continue, and "Retries
|
||||
remaining: N"); the model's continuation after them still reaches the client.
|
||||
An ending that says "This service has been disabled in this account
|
||||
for violation of Terms of Service" is returned as a no-retry
|
||||
for violation of Terms of Service" (agy 1.5.9 puts "PERMISSION_DENIED
|
||||
(code 403):" before it, 1.5.10 doesn't) is returned as a no-retry
|
||||
`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.
|
||||
@@ -375,6 +376,11 @@ off unless you turn it on.
|
||||
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.
|
||||
The "⚠ Our servers are experiencing high traffic right now …" ending
|
||||
(Google has no capacity for the model now, and agy's own retries met the
|
||||
same 503) ends the turn as `overloaded_error` (HTTP 503 without
|
||||
streaming), so the account is not rested and magpie tries again or
|
||||
elsewhere. Found by ifccod, and ported from their patch.
|
||||
- **A reply with only thinking, no text and no tool call** (billion-context's
|
||||
"the turn degenerated again after the continuation nudge"): when one of the
|
||||
model's replies comes back empty, agy writes "⚠ Model produced invalid
|
||||
|
||||
@@ -260,12 +260,15 @@ agy 自己的系统提示词,只剩插件的一行工具说明和客户端的
|
||||
("Your previous response was cut off because it exceeded the output token limit"、
|
||||
它的续写指令和 "Retries remaining: N"),这三行同样会被去掉,后面模型的续写照常
|
||||
输出。若结尾是 "This service has been disabled in this account for
|
||||
violation of Terms of Service",会按禁止重试的 403 语义 `permission_error` 返回,而不是
|
||||
violation of Terms of Service"(agy 1.5.9 前面带 "PERMISSION_DENIED (code 403):",1.5.10 不带),会按禁止重试的 403 语义 `permission_error` 返回,而不是
|
||||
当成正常正文。结尾是 "Verification Required"(Google 要求先验证这个账号)时也一样,
|
||||
并带上 agy 记下的验证链接;没有链接时说明去哪里验证。
|
||||
结尾是 "⚠ Individual quota reached. … Resets in 1h18m40s."(这个账号自己的额度用完)时,
|
||||
按额度不足(`rate_limit_error`,非流式为 HTTP 429)结束本轮,原文和重置时间一并带上,
|
||||
magpie 据此让这个账号歇到重置,并改问下一个账号。
|
||||
结尾是 "⚠ Our servers are experiencing high traffic right now …"(Google 这个模型暂时没有
|
||||
余量,agy 的重试也都碰上了 503)时,按 `overloaded_error`(非流式为 HTTP 503)结束本轮,
|
||||
不让账号歇着,magpie 会再试或改问别处。(由 ifccod 发现并移植自他的补丁。)
|
||||
- **回复只有思考、没有正文也没有工具调用**(billion-context 报 "the turn degenerated
|
||||
again after the continuation nudge"):模型的一次回复空了时,agy 会写一行
|
||||
"⚠ Model produced invalid output." 并重试;重试也空时,agy 以正常结束收尾。插件不把这样
|
||||
|
||||
@@ -7,7 +7,7 @@ import net from "node:net"
|
||||
import os from "node:os"
|
||||
import path from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { agyRefusal, createUsageReader, verifyLinkIn, verifyRefused } from "./usage.mjs"
|
||||
import { ACCOUNT_DISABLED_REFUSED, agyRefusal, createUsageReader, verifyLinkIn, verifyRefused } from "./usage.mjs"
|
||||
import { catalogRows, storeCatalogRows } from "./model-ids.mjs"
|
||||
import { backgroundBlocked, cannotSignIn, forgetStoredSignIn, storedEmail, storedSignInNow } from "./signin.mjs"
|
||||
import { sanitizePatternFields } from "./re2-pattern.mjs"
|
||||
@@ -133,6 +133,9 @@ const AGENT_ERROR_MARKERS = [
|
||||
// (CustomUserErrorMessageFromHTTPError): the account must be verified
|
||||
// first. Answered as text, it was the whole reply (kidgpt on X, 11-16).
|
||||
"\n⚠ Verification Required\n",
|
||||
// agy 1.5.10's words for the same banned account: Google's sentence with
|
||||
// no status before it. Answered as text, it was the whole reply, a 200.
|
||||
"\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",
|
||||
]
|
||||
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
|
||||
@@ -146,6 +149,17 @@ 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]
|
||||
const DISABLED_CORE = AGENT_ERROR_CORES[6]
|
||||
// agy's ending when every retry met Google's "no capacity" 503 (ifccod):
|
||||
// "⚠ 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)". Its tail names the model, so it is
|
||||
// matched by its start, as the quota ending is. Answered as text, it was a
|
||||
// 200 whose whole reply was the notice, and nothing behind magpie tried
|
||||
// again. It is a 503 overloaded_error: the model's, not the account's, so
|
||||
// the account is not rested as a 429 would rest it.
|
||||
const BUSY_CORE = "⚠ Our servers are experiencing high traffic right now"
|
||||
const BUSY_MARKER = "\n" + BUSY_CORE
|
||||
// agy 1.5.8 writes each failed attempt of a model call into the reply as one
|
||||
// line, then tries again in the same turn (#1136). The line is agy's.
|
||||
const ATTEMPT_CORE = "⚠ API error (attempt "
|
||||
@@ -181,7 +195,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, QUOTA_MARKER.length,
|
||||
...AGENT_ERROR_MARKERS.map((marker) => marker.length), CAP_MARKER.length, CAP_TAIL_CORE.length, QUOTA_MARKER.length, BUSY_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
|
||||
@@ -1184,6 +1198,8 @@ export function streamErrorOf(error) {
|
||||
// Google refused the account (refusedError): its status, so magpie
|
||||
// reads it as the account's refusal, not as a failed reply.
|
||||
if (type === "permission_error") out.status = 403
|
||||
// Google had no capacity for the model (BUSY_CORE): try again, or elsewhere
|
||||
if (type === "overloaded_error") out.status = 503
|
||||
if (error?.noRetry) out.noRetry = true
|
||||
return out
|
||||
}
|
||||
@@ -1753,7 +1769,7 @@ class Turn {
|
||||
return
|
||||
}
|
||||
}
|
||||
const quota = this.quotaEnding(text)
|
||||
const quota = Math.max(this.quotaEnding(text), this.quotaEnding(text, BUSY_CORE))
|
||||
if (quota >= 0) {
|
||||
this.heldText = text.slice(quota)
|
||||
this.emitText(text.slice(0, quota))
|
||||
@@ -1762,7 +1778,7 @@ class Turn {
|
||||
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)) || QUOTA_MARKER.startsWith(tail) ||
|
||||
(keep > 1 && (RETRY_MARKER.startsWith(tail) || ATTEMPT_MARKER.startsWith(tail) ||
|
||||
BUSY_MARKER.startsWith(tail) || (keep > 1 && (RETRY_MARKER.startsWith(tail) || ATTEMPT_MARKER.startsWith(tail) ||
|
||||
CAP_MARKER.startsWith(tail)))) {
|
||||
this.heldText = tail
|
||||
text = text.slice(0, -keep)
|
||||
@@ -1772,11 +1788,12 @@ 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)
|
||||
// Where agy's quota ending (QUOTA_CORE), or another ending matched by its
|
||||
// start (BUSY_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, core = QUOTA_CORE) {
|
||||
const at = text.lastIndexOf(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
|
||||
@@ -1867,6 +1884,11 @@ class Turn {
|
||||
this.agentErrorCore = QUOTA_CORE
|
||||
this.quotaNotice = this.heldText.trim().replace(/^⚠ /, "")
|
||||
this.heldText = ""
|
||||
} else if (this.quotaEnding(this.heldText, BUSY_CORE) >= 0) {
|
||||
this.agentError = true
|
||||
this.agentErrorCore = BUSY_CORE
|
||||
this.quotaNotice = this.heldText.trim().replace(/^⚠ /, "")
|
||||
this.heldText = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2665,6 +2687,11 @@ class Proc {
|
||||
// until then and asks the next one
|
||||
return new AgentTurnError(`agy bridge: Antigravity quota reached: ${turn.quotaNotice}`, "rate_limit_error")
|
||||
}
|
||||
if (core === BUSY_CORE) {
|
||||
return new AgentTurnError(`agy bridge: Antigravity has no capacity for this model now: ${turn.quotaNotice}`, "overloaded_error")
|
||||
}
|
||||
// agy 1.5.10 leaves out the status agyRefusal reads the ban by
|
||||
if (core === DISABLED_CORE) return refusedError(ACCOUNT_DISABLED_REFUSED)
|
||||
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)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-agy-cli-auth",
|
||||
"version": "0.1.94",
|
||||
"version": "0.1.95",
|
||||
"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",
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user