fix(csa-review): classify gemini quota-exhausted as rate-limit, not MCP (#871)#959
Conversation
…CP (#871) detect_tool_diagnostic matched only on "MCP issues detected" text, so gemini error envelopes that emit BOTH an MCP hint AND the real QUOTA_EXHAUSTED cause were misclassified -- users saw "Run /mcp list" guidance and a wrong fallback suggestion (`--tool claude-code`) when the actual remedy is to configure GEMINI_API_KEY or wait for quota reset. Detect quota markers (QUOTA_EXHAUSTED / RESOURCE_EXHAUSTED / quota exceeded / exhausted your capacity / quota will reset) BEFORE the MCP match, and emit guidance pointing at GEMINI_API_KEY fallback. The MCP branch still fires for genuine MCP-server connectivity issues. Closes #871. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Local pre-PR cumulative review (csa review --range main...HEAD, tier-4-critical, session 01KPNR0Z2RQ0JJ0YWKAVYHV1GC):
Only advisory concern raised: the reused Merging per severity-tiered protocol: findings=[] + 0 P0/P1 + both reviewers' prose directs "ship". No production regressions introduced — only a new diagnostic branch. |
There was a problem hiding this comment.
Code Review
This pull request bumps the project version to 0.1.445 and introduces logic to detect Gemini API quota exhaustion within tool output. The detect_tool_diagnostic function now identifies rate-limit patterns and provides a diagnostic message suggesting the configuration of an API key. New unit tests verify this detection and ensure quota issues are prioritized over MCP-related errors. Feedback was provided to improve the diagnostic message by removing a hardcoded Unix-style file path and clarifying the distinction between environment variables and configuration fields.
| return Some( | ||
| "gemini-cli OAuth quota exhausted. Either (a) configure GEMINI_API_KEY in ~/.config/cli-sub-agent/config.toml under [tools.gemini-cli] api_key for automatic retry, or (b) wait for quota reset." | ||
| .to_string(), | ||
| ); |
There was a problem hiding this comment.
The diagnostic message hardcodes a Unix-style path (~/.config/cli-sub-agent/config.toml) which may be incorrect for users on other platforms (e.g., Windows). Additionally, the wording "configure GEMINI_API_KEY ... under ... api_key" is slightly confusing as it mixes the environment variable name with the configuration field name. Consider using a more generic reference to the configuration file and clarifying the field name.
| return Some( | |
| "gemini-cli OAuth quota exhausted. Either (a) configure GEMINI_API_KEY in ~/.config/cli-sub-agent/config.toml under [tools.gemini-cli] api_key for automatic retry, or (b) wait for quota reset." | |
| .to_string(), | |
| ); | |
| return Some( | |
| "gemini-cli OAuth quota exhausted. Either (a) configure your Gemini API key in the CSA config file under [tools.gemini-cli] api_key for automatic retry, or (b) wait for quota reset." | |
| .to_string(), | |
| ); |
Summary
detect_tool_diagnosticinreview_cmd_output.rspreviously matched only the literal "MCP issues detected" / "Run /mcp list" substrings. Gemini-cli error envelopes that contain BOTH the MCP hint AND the realQUOTA_EXHAUSTEDcause were misclassified — users saw "Run /mcp list" guidance and an incorrect fallback suggestion (--tool claude-code) when the actual remedy is to configureGEMINI_API_KEYor wait for quota reset.csa-core::gemini::RATE_LIMIT_PATTERNS(plus\"quota will reset\") and emits GEMINI_API_KEY-fallback guidance. The MCP branch still fires for genuine MCP-server connectivity issues.Closes #871.
Test plan
cargo test -p cli-sub-agent detect_tool_diagnosticcargo test -p cli-sub-agent review_cmdcargo test --workspacejust pre-commit🤖 Generated with Claude Code