Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions script/agent.agy-review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,31 @@ describe("runLocal pipeline (stub agy)", () => {
expect(result.classification).toBe("auth-required");
});

it("quota-exhausted when agy reports RESOURCE_EXHAUSTED", async () => {
const stub = makeStub(
"quota.sh",
`cat >&2 <<'EOF'
error: Individual quota reached. Please upgrade your subscription to increase your limits. Resets in 2h37m14s.
AGY_ERROR: {"short_error":"RESOURCE_EXHAUSTED (code 429): Individual quota reached. Please upgrade your subscription"}
EOF
exit 3`
);
const result = await runAgyReview({ ...base(), agyBin: stub });
expect(result.classification).toBe("quota-exhausted");
});

it("quota-exhausted wins over auth heuristic on mixed stderr", async () => {
const stub = makeStub(
"quotaauth.sh",
`cat >&2 <<'EOF'
RESOURCE_EXHAUSTED (code 429): quota reached; request unauthorized for this window
EOF
exit 3`
);
const result = await runAgyReview({ ...base(), agyBin: stub });
expect(result.classification).toBe("quota-exhausted");
});

it("protected path mutation is detected via git status", async () => {
const repo = join(tmp, "repo");
mkdirSync(repo, { recursive: true });
Expand Down
8 changes: 8 additions & 0 deletions script/agent/agy-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,14 @@ function classify(
if (run.code !== 0) {
result.classification = "agy-error";
reasons.push(`agy exited ${run.code}: ${run.stderr.slice(0, 300)}`);
// Check quota exhaustion before auth: agy's 429 payload can contain
// tokens (e.g. "unauthorized") that would otherwise misfire the auth
// heuristic observed in Issue #226 eval runs.
if (/resource_exhausted|quota reached|individual quota|rate.?limit|too many requests|\b429\b/i.test(run.stderr + run.stdout)) {
result.classification = "quota-exhausted";
reasons.push("agy reported quota exhaustion");
return;
}
const auth = /sign in|oauth|unauthorized|401|403/i.test(run.stderr + run.stdout);
if (auth) {
result.classification = "auth-required";
Expand Down
Loading