Skip to content

[Feature]: Honor fallback model on scheduled task launches and opt-in usage_limit recovery (including without resetAt) #41154

Closed as not planned

Description

@TylerJNewman

Problem

When a primary provider's weekly quota is exhausted (e.g., Codex at 0% remaining returning exceeded retry limit, last status: 429 Too Many Requests), autonomous work stops across both scheduled tasks and active threads even when other providers on the same T3 server (e.g., Claude, Antigravity) have full quota remaining and fallbackModelSelection is configured.

Today, fallbackModelSelection (packages/contracts/src/settings.ts) is only consulted for implicit new threads via resolveNewThreadModelSelection (packages/shared/src/usageLimits.ts). Two high-impact paths still leave threads stuck as Limited:

  1. Unbound scheduled tasks bypass both fallbackModelSelection and ThreadMessageIntake:

    • In apps/server/src/scheduledTasks/ScheduledTaskService.ts (active.threadId === null), scheduled task execution calls threadLaunch.launch({ modelSelection: active.modelSelection, ... }) directly rather than going through ThreadMessageIntake.launchThread or checking resolveNewThreadModelSelection.
    • As a result, every scheduled fire continues launching on the exhausted provider—and even with PR feat: continue on another account with usage left when one runs out #28595 (fallbackToAvailableAccounts in ThreadMessageIntake), unbound scheduled tasks would still bypass fallback unless ScheduledTaskService routes through the same fallback resolver (or supports a per-task fallback / "follow server default + fallback" mode).
    • (Note: Scheduled tasks bound to a thread should be able to follow the thread's current model instead of pinning one #34148 fixed bound scheduled tasks reverting a thread's model after a manual switch, which helps once a human switches the thread—but unbound scheduled tasks and untouched bound threads still hit the exhausted provider first.)
  2. No opt-in automatic failover to fallbackModelSelection on terminal usage_limit failures (especially when resetAt is missing):

    • When a run ends with failure.class === "usage_limit" and resetAt: null (common for Codex retry exhaustion / proxied 429s), neither "Resume at reset" nor fallbackModelSelection recovers the thread.
    • PR feat: continue on another account with usage left when one runs out #28595 moves this forward via fallbackToAvailableAccounts in UsageLimitRecoveryWorker, but it requires providers that report live usage bars to T3 and only looks back 10 minutes. Users who have configured an explicit fallbackModelSelection (e.g., Codex → Claude or Antigravity) also benefit from an opt-in server/task setting to transiently fail over to fallbackModelSelection on terminal usage_limit (using the existing thread.model-selection.set + ContextHandoffService path) without permanently overwriting the task's preferred model once quota resets.

Requested Behavior

  1. Scheduled tasks: Before dispatching an unbound scheduled task (or a bound task whose current thread provider is known exhausted), honor the server's configured fallbackModelSelection (and fallbackToAvailableAccounts if feat: continue on another account with usage left when one runs out #28595 lands), transiently for that run so the task returns to its preferred model once usage resets. Optionally allow a scheduled task to opt out (pinModel: true) or specify a task-level fallback.
  2. Terminal usage_limit failover: Allow UsageLimitRecoveryWorker (behind an opt-in server setting, or unified with feat: continue on another account with usage left when one runs out #28595's fallbackToAvailableAccounts) to fall back to fallbackModelSelection when the failing provider hits terminal usage_limit—even when resetAt is absent—bounded to a single hop per failed turn and respecting concurrent user stops/edits atomically inside the orchestrator.

Related Issues & PRs

Activity

  1. juliusmarminge commented on Nov 23, 2026

    @juliusmarminge
    Member

    Thanks for writing this up. It asks for new behaviour rather than reporting a defect, so it does not belong in the bug tracker and I'm closing it as not planned here. Feature ideas are discussed in Discussions: please post it there.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions