Skip to content

fix(runtime-fallback): detect Gemini quota errors in session.status retry events (fixes #2454)#2592

Merged
code-yeongyu merged 2 commits intocode-yeongyu:devfrom
MoerAI:fix/gemini-quota-fallback
Mar 25, 2026
Merged

fix(runtime-fallback): detect Gemini quota errors in session.status retry events (fixes #2454)#2592
code-yeongyu merged 2 commits intocode-yeongyu:devfrom
MoerAI:fix/gemini-quota-fallback

Conversation

@MoerAI
Copy link
Copy Markdown
Contributor

@MoerAI MoerAI commented Mar 16, 2026

Summary

  • Adds fallback pattern matching in the session.status handler when extractAutoRetrySignal fails but status.type is already "retry"

Problem

When Gemini returns a quota exhausted error ("You have exhausted your capacity on this model"), OpenCode auto-retries and fires session.status with type="retry". The runtime-fallback hook's session.status handler uses extractAutoRetrySignal() which requires BOTH conditions to match:

  1. retrying\s+in - the retry countdown text
  2. One of the quota patterns (e.g., exhausted\s+your\s+capacity)

Some providers include only the error message in the retry status without the "retrying in" phrase, causing condition 1 to fail. The handler exits early and never triggers the fallback chain.

Fix

Added a fallback check after extractAutoRetrySignal fails:

if (!retrySignal) {
  // status.type is already "retry", so check message against
  // RETRYABLE_ERROR_PATTERNS directly
  const messageLower = retryMessage.toLowerCase()
  const matchesRetryablePattern = RETRYABLE_ERROR_PATTERNS.some(
    (pattern) => pattern.test(messageLower)
  )
  if (!matchesRetryablePattern) return
}

Since status.type === "retry" already confirms this is a retry event, the "retrying in" text check is redundant. The fallback path checks the message directly against the existing RETRYABLE_ERROR_PATTERNS (which already includes exhausted\s+your\s+capacity, quota\s+will\s+reset\s+after, etc.).

Changes

File Change
session-status-handler.ts Add fallback pattern matching when extractAutoRetrySignal fails

Fixes #2454


Summary by cubic

Detects Gemini quota-exhausted retry events in runtime-fallback by matching session.status retry messages against RETRYABLE_ERROR_PATTERNS when extractAutoRetrySignal fails and status.type === "retry". This triggers the fallback chain even when the message lacks "retrying in", fixing #2454.

Written for commit 7e3c36e. Summary will update on new commits.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@MoerAI
Copy link
Copy Markdown
Contributor Author

MoerAI commented Mar 16, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: The change correctly addresses the issue where certain providers like Gemini omit specific retry text. It safely adds a fallback check against existing error patterns without regressions.

MoerAI added 2 commits March 16, 2026 11:08
…etry events

When Gemini returns a quota exhausted error, OpenCode auto-retries and
fires session.status with type='retry'. The extractAutoRetrySignal
function requires BOTH 'retrying in' text AND a quota pattern to match,
but some providers (like Gemini) include only the error text in the
retry message without the 'retrying in' phrase.

Since status.type='retry' already confirms this is a retry event, the
fix adds a fallback check: if extractAutoRetrySignal fails, check the
message directly against RETRYABLE_ERROR_PATTERNS. This ensures quota
errors like 'exhausted your capacity' trigger the fallback chain even
when the retry message format differs from expected.

Fixes code-yeongyu#2454
@MoerAI MoerAI force-pushed the fix/gemini-quota-fallback branch from 1a3ce72 to 7e3c36e Compare March 16, 2026 02:08
@cryptobetEU
Copy link
Copy Markdown

what 0auth you use to acces gemini ? I got banned, unbanned but soon afterwards banned again with Gemini(when they unbanned people I was raping it REALLY hard for 4 hours).

I really would like to acces Gemini overtime to crosscheck/third opinion.

@dreanzy
Copy link
Copy Markdown

dreanzy commented Mar 16, 2026

what 0auth you use to acces gemini ? I got banned, unbanned but soon afterwards banned again with Gemini(when they unbanned people I was raping it REALLY hard for 4 hours).

I really would like to acces Gemini overtime to crosscheck/third opinion.

I am using the opencode-gemini-auth plugin, and it has not been blocked for more than a month.
I heard that opencode-antigravity-auth is easily blocked, so I just use opencode-gemini-auth.

@MoerAI
Copy link
Copy Markdown
Contributor Author

MoerAI commented Mar 16, 2026

The antigravity auth plugin likely gets blocked more often because it routes through higher-tier models. Google is probably more aggressive about enforcing rate limits on those.

@code-yeongyu code-yeongyu added the triage:bug Confirmed bug with repro steps label Mar 24, 2026
@code-yeongyu code-yeongyu merged commit 7761e48 into code-yeongyu:dev Mar 25, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:bug Confirmed bug with repro steps

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime_fallback does not recognize Gemini 'exhausted your capacity' quota error

4 participants