diff --git a/packages/agy-cli/index.mjs b/packages/agy-cli/index.mjs index b1a7c0b..762ce4d 100644 --- a/packages/agy-cli/index.mjs +++ b/packages/agy-cli/index.mjs @@ -111,11 +111,13 @@ const STEP_USAGE_SAME_GEN_WAIT_MS = 75 const STEP_USAGE_POLL_MS = 25 // agy reports an upstream failure as an ordinary message chunk followed by end_turn. // 1.5.8 words a connection that failed every retry, and a spent credit -// balance, on their own (#1136). +// balance, on their own (#1136). 1.5.9 ends a turn whose every retry got 429 +// with the upstream status itself (#1151). const AGENT_ERROR_MARKERS = [ "\n⚠ Agent execution terminated due to error.\n", "\n⚠ There was a network issue connecting to the server, please try again.\n", "\n⚠ Your AI credits balance is too low to continue.\n", + "\n⚠ RESOURCE_EXHAUSTED (code 429): Resource has been exhausted (e.g. check quota).\n", ] const AGENT_ERROR_CORES = AGENT_ERROR_MARKERS.map((marker) => marker.trim()) const CREDITS_CORE = AGENT_ERROR_CORES[2] diff --git a/packages/agy-cli/package.json b/packages/agy-cli/package.json index 97538a9..bfc63ad 100644 --- a/packages/agy-cli/package.json +++ b/packages/agy-cli/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-agy-cli-auth", - "version": "0.1.46", + "version": "0.1.47", "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", diff --git a/packages/agy-cli/test/repeat-batch.mjs b/packages/agy-cli/test/repeat-batch.mjs index 3c3a611..1752a0c 100644 --- a/packages/agy-cli/test/repeat-batch.mjs +++ b/packages/agy-cli/test/repeat-batch.mjs @@ -894,13 +894,16 @@ test("#1136: agy's attempt banners before a retry that works never reach the cli } }) -test("#1136: agy 1.5.8's network and credit endings fail the turn", async () => { +test("#1136, #1151: agy's network, credit and 429 endings fail the turn", async () => { for (const [chunks, want, kind] of [ // Turn B: one attempt, then agy gives up. The attempt's detail names why. [[EOF_ATTEMPT(1) + "\n" + NETWORK], /EOF/, "api_error"], // Turn C: the ending alone, split mid-marker. [[NETWORK.slice(0, 20), NETWORK.slice(20)], /network issue connecting/, "api_error"], [["partial\n⚠ Your AI credits ", "balance is too low to continue.\n"], /credits balance is too low/, "rate_limit_error"], + // #1151: agy 1.5.9's ending after every retry got 429, split mid-marker. + [["partial\n⚠ RESOURCE_EXHAU", "STED (code 429): Resource has been exhausted (e.g. check quota).\n"], /quota or rate limit reached: RESOURCE_EXHAUSTED \(code 429\)/, "rate_limit_error"], + [["\n⚠ RESOURCE_EXHAUSTED (code 429): Resource has been exhausted (e.g. check quota).\n"], /quota or rate limit reached/, "rate_limit_error"], ]) { await withKit({}, async (kit) => { markerAgent(kit, chunks) @@ -914,6 +917,17 @@ test("#1136: agy 1.5.8's network and credit endings fail the turn", async () => } }) +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) => { + markerAgent(kit, chunks) + const parsed = await readSse(await kit.request(baseBody({ metadata: { user_id: "exhausted-quoted" }, + messages: [{ role: "user", content: "what did agy print?" }] }))) + assert.equal(parsed.error, null) + assert.equal(replyText(parsed), chunks.join("")) + }) +}) + test("#1136: the model quoting an attempt banner or the network ending mid-line keeps it", async () => { const chunks = ["agy printed `⚠ API error (attempt 1): EOF` and later", " `⚠ There was a network issue connecting to the server, please try again.` too."] await withKit({}, async (kit) => {