Skip to content

fix(background-agent): skip unavailable fallback models#3402

Closed
kywoo26 wants to merge 2 commits into
code-yeongyu:devfrom
kywoo26:fix/3400-skip-unavailable-fallbacks
Closed

fix(background-agent): skip unavailable fallback models#3402
kywoo26 wants to merge 2 commits into
code-yeongyu:devfrom
kywoo26:fix/3400-skip-unavailable-fallbacks

Conversation

@kywoo26

@kywoo26 kywoo26 commented Apr 13, 2026

Copy link
Copy Markdown

Summary

  • skip fallback candidates that are not available in the current runtime model catalog
  • use the runtime's connected-provider model cache when selecting fallback candidates
  • keep the existing provider-based behavior when no model cache is available

Changes

  • update model-fallback candidate selection to prefer runtime-available fallback models
  • update background fallback retry selection to do the same
  • add targeted test coverage for unavailable fallback candidate handling

Testing

bun test src/features/background-agent/fallback-retry-handler.test.ts src/features/background-agent/manager.polling.test.ts src/features/background-agent/session-idle-event-handler.test.ts
bun run typecheck
bun run build

Manual validation:

  • reproduced unavailable fallback attempts in a no-override local setup
  • confirmed the patched selection skips unavailable candidates instead of attempting them

Related Issues

Closes #3400


Summary by cubic

Skip fallback models that aren’t available at runtime to avoid wasted background-agent retries. Use the provider-model cache to pick the first available fallback and prefer the connected preferred provider when possible; fall back to the old provider-based logic when no cache is present.

Written for commit 77d86f2. Summary will update on new commits.

@github-actions

github-actions Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

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

@kywoo26

kywoo26 commented Apr 13, 2026

Copy link
Copy Markdown
Author

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

github-actions Bot added a commit that referenced this pull request Apr 13, 2026

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 3 files

Confidence score: 3/5

  • There is a concrete behavior risk in src/features/background-agent/fallback-retry-handler.ts: availability resolution can ignore the connected preferred provider path, which may skip valid fallback providers when cache data is present.
  • Given the issue is medium severity (6/10) with high confidence (8/10) and affects fallback selection logic, this introduces a real chance of user-facing reliability regressions.
  • Pay close attention to src/features/background-agent/fallback-retry-handler.ts - ensure preferred-provider and cached-availability paths are reconciled so valid fallbacks are not skipped.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/features/background-agent/fallback-retry-handler.ts">

<violation number="1" location="src/features/background-agent/fallback-retry-handler.ts:90">
P2: Availability resolution ignores the connected preferred provider path, so valid fallbacks can be skipped when cache data exists.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/features/background-agent/fallback-retry-handler.ts Outdated

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 4 files (changes from recent commits).

Auto-approved: Fixes wasted fallback retries by checking model availability against the runtime cache. Includes targeted test coverage and maintains legacy behavior when cache is unavailable.

github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 19, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 19, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 19, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 19, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 19, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 20, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 20, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 20, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 20, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 20, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 21, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 22, 2026
github-actions Bot added a commit to Vacbo/oh-my-opencode that referenced this pull request Apr 22, 2026
@code-yeongyu

Copy link
Copy Markdown
Owner

Triage note: rebase onto current dev conflicts in src/features/background-agent/fallback-retry-handler.{ts,test.ts} due to subsequent background-agent fallback evolution: c0544a7 (defer retry notifications), #7a94cc72b (stabilize parent wakes), #3972 (partInfo.input circuit breaker fallback). Partial coverage of the underlying goal (skip unavailable fallback candidates) was also added via #3982 (delegate-task category fallback honoring) and #3934 (localized balance classification).

To re-land:

  1. Rebase onto current dev.
  2. Verify what is now still missing on top of fix(delegate-task): honor user fallback_models when category primary is unreachable #3982 + fix(runtime-fallback): classify localized balance failures as quota exhaustion #3934 + fix(model-fallback): add HTTP statusCode check for GLM rate limit fallback #3773 + the partInfo.input changes (likely the per-attempt runtime model catalog check before launching the fallback session in background-agent/fallback-retry-handler.ts).
  3. Trim the diff to only that gap, confirm bun test --timeout 30000 is 0 fail.

Closes #3400 still applies once #3402 is rebased + verified. Leaving open.

@code-yeongyu

Copy link
Copy Markdown
Owner

Closing as obsolete. Current dev already implements the reachability skip in src/features/background-agent/fallback-retry-handler.ts via:

  • An isReachable(candidate) check against the connected-provider set (lines ~90-106).
  • if (!isReachable(candidate)) { log skip; continue } to skip unreachable fallback candidates.
  • isNoOpFallback check that additionally skips candidates that resolve to the same provider+model as the failing attempt.

This achieves the same goal as this PR (skip unavailable fallback candidates instead of attempting them), so the diff would now be a no-op. Closing along with closing #3400 (the linked issue).

@code-yeongyu

Copy link
Copy Markdown
Owner

Closing as obsolete; the reachability skip is already in HEAD's fallback-retry-handler.ts via isReachable + isNoOpFallback. See triage comment above.

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.

[Bug]: background fallback retries models that are not available in the current runtime

2 participants