You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: rate-limit detector too broad — misclassifies CLI format errors as rate limits #148
In run #715, the Copilot CLI exited with error: Invalid command format (a command syntax error), but is_rate_limited classified it as a rate limit and returned exit code 2, causing the session to abort:
[tier1] usage/rate limit detected — exiting with code 2 for engine fallback
limit message: (stderr: error: Invalid command format.
Did you mean: copilot -i "suggest -p ..."
The detector inspects stdout/stderr for keyword matches. Its current pattern set is too broad and matches on phrases like Invalid command format or similar output that has nothing to do with API rate limiting. The consequence is catastrophic: a simple CLI misconfiguration aborts the entire batch session.
Acceptance criteria
Audit current patterns: enumerate every regex/string pattern in is_rate_limited (and any callers) and justify each one against actual rate-limit response bodies from Claude, Gemini, and Copilot CLI.
Tighten patterns: remove or narrow patterns that can match non-rate-limit errors. At minimum, Invalid command format (and the Did you mean: suggestion) must NOT trigger a rate-limit exit.
Logging: when is_rate_limited returns false but the command failed, log the actual error category (e.g., [error] CLI format error — treating as per-PR failure) so post-mortem analysis is unambiguous.
No regression: existing rate-limit strings from Claude (overloaded, 529, rate_limit_error) and Copilot (rate limit, quota) still correctly trigger exit code 2.
Expected tests
Unit (bats): is_rate_limited returns false for each of the following inputs:
error: Invalid command format.
Did you mean: copilot -i ...
unknown flag: --foo
command not found
Unit (bats): is_rate_limited returns true for known rate-limit strings:
overloaded_error / 529
rate limit exceeded
quota exceeded
usage limit reached
Integration: a simulated CLI format-error (mocked exit 1 + Invalid command format stderr) results in a per-PR failure (exit 1) — not a session abort (exit 2) — and the next candidate PR is processed.
Read CLAUDE.md (none found — used README + issue guidance)
Explored codebase — is_rate_limited in scripts/engine.sh:87, 3 call sites in review-one-pr.sh
Audited current rate-limit patterns
Tightened is_rate_limited: removed standalone exhausted; replaced bare overloaded with overloaded_error|service.*overload|overload.*error (prevents false positives from code that discusses "overloaded operators")
Added is_cli_error function to scripts/engine.sh
Fixed all 3 call sites in review-one-pr.sh: is_cli_error check before is_rate_limited; added $single_rc -ne 0 guard to single-review tier (was causing false positives from reviewed PR content)
Created tests/test_rate_limit.bats — unit tests for all AC inputs + false-positive guards
Activity
don-petry commentedon May 12, 2026
Claude finished @don-petry's task in 8m 57s —— View job •
claude/issue-148-20260512-1802• [Create PR ➔](https://github.com/petry-projects/.github-private/compare/main...claude/issue-148-20260512-1802?quick_pull=1&title=Issue%20%23148%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%23148%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)Implementation complete
is_rate_limitedinscripts/engine.sh:87, 3 call sites inreview-one-pr.shis_rate_limited: removed standaloneexhausted; replaced bareoverloadedwithoverloaded_error|service.*overload|overload.*error(prevents false positives from code that discusses "overloaded operators")is_cli_errorfunction toscripts/engine.shreview-one-pr.sh:is_cli_errorcheck beforeis_rate_limited; added$single_rc -ne 0guard to single-review tier (was causing false positives from reviewed PR content)tests/test_rate_limit.bats— unit tests for all AC inputs + false-positive guardstests/test_cli_error_routing.bats— integration routing test covering the exact Copilot run docs(AGENTS): record dev-lead/pr-review automation rules (hands-off label; pr-review is CODEOWNER approver) #715 incidentoverloadedover-broad pattern), pushed fix@petry-projects/org-leadsfor reviewPR
petry-projects/.github-private#149
What changed
scripts/engine.shis_rate_limited; addedis_cli_errorscripts/review-one-pr.shrc ≠ 0guardtests/test_rate_limit.batstests/test_cli_error_routing.batsfix: tighten rate-limit detector, add is_cli_error, route CLI errors …
fix: tighten rate-limit detector, add is_cli_error, route CLI errors …
fix: tighten rate-limit detector, add is_cli_error, route CLI errors …
fix: tighten rate-limit detector, add is_cli_error, route CLI errors …
fix: tighten rate-limit detector, add is_cli_error, route CLI errors …
fix: tighten rate-limit detector, add is_cli_error, route CLI errors …
fix: tighten rate-limit detector, add is_cli_error, route CLI errors …
fix: tighten rate-limit detector, add is_cli_error, route CLI errors …