agy-cli 0.1.70: say when Google refuses the account (#3501) instead of a fallback list

Three X reports (16 Nov): "You do not have a valid license of this product
(#3501)", "models can't be fetched", and "magpie's agy proxy stopped
working". agy 1.5.9 gets Google's 403 #3501 on its eligibility check and
fails every command with it (agy models, agy -p). The plugin hid it:
models() fell back to the static catalog as if the account had those
models, usage said only "not eligible", and a request got 400 "model ... is
unavailable to this agy account" because the ACP session offers none.

Now:
- usage.mjs: agyRefusal() reads Google's refusal out of agy's output
  (#3501 first, else the eligibility line), never from agy's own log
  lines or a network failure; usage reports the #3501 text with what to
  do (update agy and sign in again, personal Gmail, unset AGY_ADC_AUTH,
  VPN/region).
- index.mjs: a failed `agy models` records the refusal per agy home;
  models() throws it (magpie shows it as the list error) instead of the
  static catalog, and recovers when agy lists again. A request whose
  session offers no model, or whose turn ends on the refusal, answers 403
  permission_error with the reason (stream and JSON), not 400. After a
  sign-in, magpie shows "agy signed in, but" and the refusal.
- README (zh, en): a Troubleshooting entry for #3501.

Run (mote, HOME=$(mktemp -d)):
- bun test ./packages/agy-cli: 35 pass, 0 fail (110s); bun scripts/check.mjs ok.
- test/usage.mjs with cp-hook preload 6 more times: 0 fail. One earlier
  run had "a direct read that fails leaves the region refusal standing"
  red with "agy usage could not start the CLI" at load ~28; the same red
  shows on the base tree (b35d4b35) in the same run, so it is not this
  change.
- Red on the old code (mica, base b35d4b35 with the new tests): catalog's
  two #3501 tests fail, usage.mjs fails to import agyRefusal.
- Real agy 1.5.9 on WSL (magpie-desktop) against a fake Code Assist that
  answers 403 #3501: before, models() gave the fallback list, chat gave 400
  "unavailable"; after, models() throws the #3501 reason, usage carries
  it, chat answers 403 permission_error with it.

Not tried: a real Google account that gets #3501; macOS and Windows with
real agy; a live ACP turn whose agent error carries #3501 (covered by the
fake agy in catalog.mjs only).
This commit is contained in:
yetone
2026-11-16 10:57:34 +08:00
parent b35d4b35b2
commit 175dfd2555
8 changed files with 192 additions and 7 deletions
+55
View File
@@ -596,3 +596,58 @@ test("已登录时登录结果用 agy 存的 Google 账号命名,而不是一
await warmed(kit)
})
})
// agy 1.5.9 when Google answers 403 #3501 at its eligibility check (run
// against a fake Code Assist, 11-16): every command, `agy models` included,
// ends with this and exit 1. Three people on X got a fallback list, "model …
// is unavailable to this agy account" and "not eligible" from the plugin.
const REFUSED_3501 = "Error: Eligibility check failed: PERMISSION_DENIED (code 403): You do not have a valid license of this product. Please contact your administrator to request a license. If you are not an enterprise user and believe you are receiving this message as an error, please try using the latest version and logging in again. (#3501). Please log out (/logout) and log back in (/login).\n"
const REFUSED_LISTING = { code: 1, stderr: "I1116 10:34:03.760516 315 http_helpers.go:876] Failed to make code assist backend request\n" + REFUSED_3501 }
test("#3501 Google 拒了账号:models() 说出原因,不给静态目录冒充账号的型号", async () => {
await withKit({ modelsBehavior: REFUSED_LISTING }, async (kit) => {
await kit.models().catch(() => {})
await warmed(kit)
const error = await kit.models().then(() => null, e => e)
assert.ok(error, "Google 拒了账号,models() 仍给了一份列表")
assert.match(error.message, /#3501/)
assert.match(error.message, /valid license/)
assert.match(error.message, /\/logout.*\/login/)
assert.match(error.message, /AGY_ADC_AUTH/)
// agy 又能列出了(重新登录、换了地区):恢复正常目录
kit.modelsBehavior = DYNAMIC_OK
kit.clock.advance(CATALOG_TTL_MS)
await kit.models().catch(() => {})
await warmed(kit)
assert.ok((await kit.models())["gemini-9-test"], "agy 能列出后仍报拒绝")
})
})
test("#3501 别的失败(网络、超时、未知输出)仍给静态目录,不说成拒绝", async () => {
await withKit({ modelsBehavior: { code: 1, stderr: "Error: Eligibility check failed: EOF\n" } }, async (kit) => {
await kit.models()
await warmed(kit)
assert.ok((await kit.models())["gemini-4-argon"])
})
})
test("#3501 请求:会话一个型号都不开放时答 403 和 Google 的原因,不说型号不可用", async () => {
for (const stream of [true, false]) {
await withKit({ modelsBehavior: REFUSED_LISTING, setModelError: { code: -32603, message: "Unknown model ID: gemini-4-argon-high" } }, async (kit) => {
const response = await kit.request(baseBody({ stream, model: "agy-cli/gemini-4-argon", tools: [], messages: [{ role: "user", content: "hi" }] }))
assert.equal(response.status, 403, `stream=${stream}`)
const body = await response.json()
assert.equal(body.error.type, "permission_error")
assert.match(body.error.message, /#3501/)
assert.doesNotMatch(body.error.message, /unavailable to this agy account/)
await settle(kit)
})
}
// 账号没被拒,型号真的不可用:仍是 400
await withKit({ modelsBehavior: DYNAMIC_OK, setModelError: { code: -32603, message: "Unknown model ID: gemini-4-argon-high" } }, async (kit) => {
const response = await kit.request(baseBody({ model: "agy-cli/gemini-4-argon", tools: [], messages: [{ role: "user", content: "hi" }] }))
assert.equal(response.status, 400)
assert.match((await response.json()).error.message, /unavailable to this agy account/)
await settle(kit)
})
})
+5 -1
View File
@@ -198,6 +198,7 @@ function spawnModels(kit, file, args) {
return
}
if (behavior.stdout) child.stdout.emit("data", behavior.stdout)
if (behavior.stderr) child.stderr.emit("data", behavior.stderr)
child.finish(behavior.code ?? 0)
}
if (!behavior.hang) {
@@ -275,7 +276,9 @@ class FakeAgy {
else this.respond(id, { sessionId: this.sessionId, models })
} else if (method === "session/set_model") {
this.kit.setModels.push(params.modelId)
this.respond(id, {})
// agy whose account Google turned away offers no model: every one is unknown
if (this.kit.setModelError) this.send({ id, error: this.kit.setModelError })
else this.respond(id, {})
} else if (method === "session/prompt") {
this.runPrompt(id, params)
} else if (method === "session/cancel") {
@@ -434,6 +437,7 @@ export async function createBridgeKit(options = {}) {
initialAgyModel: options.initialAgyModel ?? "gemini-3.8-flash-low",
offeredModels: options.offeredModels ?? null,
sessionNewError: options.sessionNewError ?? null,
setModelError: options.setModelError ?? null,
sessionNewDelayMs: options.sessionNewDelayMs ?? 0,
sessionResume: options.sessionResume ?? false,
agentVersion: options.agentVersion ?? "1.5.0",
+19 -1
View File
@@ -6,7 +6,7 @@ import fs from "node:fs/promises"
import os from "node:os"
import path from "node:path"
import { test } from "node:test"
import { createUsageReader, fetchUsage, parseUsageReport, quotaUserAgent, readQuotaDirect } from "../usage.mjs"
import { agyRefusal, createUsageReader, fetchUsage, parseUsageReport, quotaUserAgent, readQuotaDirect } from "../usage.mjs"
import http from "node:http"
import { modelsInGroup, storeCatalogRows } from "../model-ids.mjs"
import { forgetStoredSignIn } from "../signin.mjs"
@@ -587,6 +587,9 @@ test("reports sanitized failures and preserves the bridge sign-in; failures back
["Not logged in secret@example.com https://secret.invalid/token", /sign in again/, "expired"],
["Eligibility check failed: EOF secret@example.com", /eligibility check failed on a network/, "kept"],
["not eligible secret@example.com", /not eligible/, "kept"],
// Google's 403 #3501 (agy 1.5.9's words, three people on X on 11-16):
// the account, with what to do about it, not "not eligible"
["Eligibility check failed: PERMISSION_DENIED (code 403): You do not have a valid license of this product. Please contact your administrator to request a license. If you are not an enterprise user and believe you are receiving this message as an error, please try using the latest version and logging in again. (#3501). Please log out (/logout) and log back in (/login). secret@example.com", /#3501[\s\S]*\/logout[\s\S]*AGY_ADC_AUTH/, "kept"],
["connection refused: secret@example.com https://secret.invalid", /network or proxy/, "kept"],
["unrecognized secret@example.com", /could not read usage/, "kept"],
]) {
@@ -967,3 +970,18 @@ test("only a region refusal reads the quota directly", async t => {
assert.equal(asked, 0, error)
}
})
test("agyRefusal: Google turning the account away, never a network failure or agy's own log lines", () => {
const license = "Error: Eligibility check failed: PERMISSION_DENIED (code 403): You do not have a valid license of this product. ... (#3501). Please log out (/logout) and log back in (/login)."
assert.match(agyRefusal(license), /#3501/)
assert.match(agyRefusal("error: something (#3501)"), /#3501/)
assert.match(agyRefusal("Error: Eligibility check failed: Your current account is not eligible for Antigravity, because it is not currently available in your location."), /not currently available in your location[\s\S]*VPN/)
for (const other of [
"",
"Error: Eligibility check failed: EOF",
"Error: Eligibility check failed: dial tcp: lookup cloudcode-pa.googleapis.com: no such host",
"Error: You are not logged into Antigravity.",
// a background poll agy logged failing, while the command itself failed otherwise
"E1116 10:34:12.084405 248 errorreport.go:307] Failed to poll ListExperiments: PERMISSION_DENIED (code 403): You do not have a valid license of this product. (#3501)\nError: something else",
]) assert.equal(agyRefusal(other), "", other)
})