Skip to content

fix(background-task): register fallback chain for background sessions (fixes #2203)#2800

Merged
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
MoerAI:fix/background-task-fallback-chain
Mar 24, 2026
Merged

fix(background-task): register fallback chain for background sessions (fixes #2203)#2800
code-yeongyu merged 1 commit intocode-yeongyu:devfrom
MoerAI:fix/background-task-fallback-chain

Conversation

@MoerAI
Copy link
Copy Markdown
Contributor

@MoerAI MoerAI commented Mar 24, 2026

Summary

  • Register user-configured fallback_models for background task sessions so runtime-fallback uses the correct chain

Problem

When a background task encounters a model error (rate limit, quota, etc.), the runtime-fallback hook checks sessionFallbackChains.get(sessionID) to find the user's configured fallback models. For background tasks, this map entry was never set because executeBackgroundTask() passes the fallbackChain to manager.launch() as input but never calls setSessionFallbackChain() to register it.

In sync-task.ts (line 66), setSessionFallbackChain(sessionID, fallbackChain) is called after session creation. Background tasks lacked this call, causing sessionFallbackChains.get(sessionID) to return undefined. The fallback hook then falls through to the hardcoded requirements?.fallbackChain instead of using the user's configured fallback_models.

Fix

Added setSessionFallbackChain(sessionId, fallbackChain) call in executeBackgroundTask() after the session ID becomes available (after the wait-for-session loop), matching the pattern used in executeSyncTask().

Changes

File Change
src/tools/delegate-task/background-task.ts Import setSessionFallbackChain, call it after session ID is resolved

Fixes #2203


Summary by cubic

Register the user-configured fallback chain for background task sessions so runtime fallback uses the correct models. Fixes #2203.

  • Bug Fixes
    • Background tasks didn’t register fallbackChain, causing fallback to use defaults.
    • After resolving sessionId, call setSessionFallbackChain(sessionId, fallbackChain) in executeBackgroundTask() (mirrors sync path).

Written for commit d2d48fc. Summary will update on new commits.

@MoerAI
Copy link
Copy Markdown
Contributor Author

MoerAI commented Mar 24, 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: Targeted fix to register fallback chains for background tasks, mirroring existing sync task logic. Minimal change with no impact on core execution flow.

@code-yeongyu code-yeongyu merged commit 81c912c into code-yeongyu:dev Mar 24, 2026
8 checks passed
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.

Background task model-fallback ignores user fallback_models, falls through to hardcoded chain

2 participants