Skip to content

fix(csa-review): classify gemini quota-exhausted as rate-limit, not MCP (#871)#959

Merged
RyderFreeman4Logos merged 1 commit intomainfrom
fix/871-gemini-quota-vs-mcp
Apr 20, 2026
Merged

fix(csa-review): classify gemini quota-exhausted as rate-limit, not MCP (#871)#959
RyderFreeman4Logos merged 1 commit intomainfrom
fix/871-gemini-quota-vs-mcp

Conversation

@RyderFreeman4Logos
Copy link
Copy Markdown
Owner

Summary

  • detect_tool_diagnostic in review_cmd_output.rs previously matched only the literal "MCP issues detected" / "Run /mcp list" substrings. Gemini-cli error envelopes that contain BOTH the MCP hint AND the real QUOTA_EXHAUSTED cause were misclassified — users saw "Run /mcp list" guidance and an incorrect fallback suggestion (--tool claude-code) when the actual remedy is to configure GEMINI_API_KEY or wait for quota reset.
  • Add a quota-first branch that reuses 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_diagnostic
  • cargo test -p cli-sub-agent review_cmd
  • cargo test --workspace
  • just pre-commit

🤖 Generated with Claude Code

…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>
@RyderFreeman4Logos
Copy link
Copy Markdown
Owner Author

Local pre-PR cumulative review (csa review --range main...HEAD, tier-4-critical, session 01KPNR0Z2RQ0JJ0YWKAVYHV1GC):

Only advisory concern raised: the reused RATE_LIMIT_PATTERNS set is shared with the scheduler's rate-limit detector, and a bare "429" substring in gemini review output would emit the quota diagnostic even if not truly a quota error. Triggering conditions are narrow (tool must be gemini-cli AND output contains literal 429), and the worst-case message is "configure GEMINI_API_KEY or wait for reset" — helpful-or-neutral, not incorrect guidance. Optional narrower matcher is a valid followup; tracked for future hardening.

Merging per severity-tiered protocol: findings=[] + 0 P0/P1 + both reviewers' prose directs "ship". No production regressions introduced — only a new diagnostic branch.

@RyderFreeman4Logos RyderFreeman4Logos merged commit c51673e into main Apr 20, 2026
6 of 7 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +648 to +651
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(),
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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(),
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

csa-review: gemini 429 quota-exhausted misclassified as 'MCP issues detected'

1 participant