Skip to content

Public request-aware handoff ownership for safe provider fallback #5552

Description

@wonderlandgardens

Workflow

When an ordinary Claude Code turn is rejected because Account Pooler has no eligible account, continue it on an authenticated, available Codex subscription using the existing Handoff plugin and workspace. The source retry and destination must never both execute the failed input.

This requests agreement on a public core contract, not a new provider or billing route.

Observed contracts

Installed bb 0.46.0, SDK 0.6.37, Handoff 0.7.1 on macOS. Inspected core main at 05771e3. Handoff has a memory-only lock and dispatches before persisting destination history. Its public operation has no request-aware durable identity. Core same-thread retry validates request identity, but spawn cannot conditionally consume that retry.

A real-SQLite server test on main reproduces two different pending destination IDs from repeated createThreadFromRequest calls. A proposed experimental_failedTurnTransfer field is stripped by the current schema; this is a missing feature, not a claim that current spawn promises idempotency. The test uses a future sendAt and fake daemon, and consumes no Claude or Codex inference. Verbatim result: AssertionError: expected 'thr_97kj5pn2mj' to be 'thr_s9hbiezg5v'.

Proposed minimum

Extend the existing create/spawn path with a failed-source request precondition and durable operation identity. Persist destination identity and recoverable first input together. Repeated/concurrent requests and restarts reconcile that same destination.

Preserve the original retry until destination admission. At admission, one transaction checks source request identity, cancellation, archive/delete and newer input, commits destination ownership and consumes the original retry-chain rows, including claimed rows. Every source retry append path must enforce ownership in its transaction, including Send-now and the no-hook queue fast path. Whichever side dispatches first invalidates the other. A failed preparation leaves the original retry usable; ambiguous admitted dispatch remains destination-owned.

Expose through the existing CLI/SDK path with experimental naming. Handoff remains responsible for exporting complete history and the exact unaccepted input, preserving accepted side effects as history, checking Codex subscription authentication/capacity, and linking the destination from the source. Provider Retry remains responsible for the narrow exhaustion policy; no automatic bounce from Codex.

Evidence and boundaries

Searches for handoff, provider fallback and idempotent transfer found related tasks/continuation issues but no matching request-level cross-provider ownership contract. Task claims (#5188) and successor threads (#4547) concern different ownership boundaries.

A local prototype is in progress. No feature PR, installed runtime change, automatic switching or live acceptance is claimed. Please confirm the contract direction before an upstream feature PR, per CONTRIBUTING.md.

AGENT GENERATED

Activity

  1. added
    threads
    providers
    provider-retry
    on Oct 15, 2026
  2. bb-slop-cop commented on Oct 15, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Applied classification: Type: Feature · Priority: Medium · Effort: High.
    Labels: threads, providers, provider-retry. No existing classifications or labels were replaced.

    This requests a new durable cross-provider ownership contract rather than reporting a violation of an existing guarantee. Medium priority reflects the limited fallback scenario; high effort reflects transactional persistence, retry coordination, and public API design.

    No reproduction report or pull request: this is a feature requiring architecture and contract decisions, not a simple bug fix.

  3. wonderlandgardens commented on Oct 15, 2026

    @wonderlandgardens
    Author

    A local prototype is ready for contract review.
    Core provides threads.experimental_transferFailedTurn, durable source/request ownership, admission-time invalidation checks, and exclusion of source retries after destination admission.
    Focused core tests (86), database tests (622), SDK tests (119), Handoff tests (155), typechecks, and builds pass; independent safety review found no remaining blocker.
    Controlled isolated acceptance used simulated Claude exhaustion and existing Codex subscription authentication, producing one destination, no replayed accepted side effect, and no Claude inference; broad server installer tests remain unstable on both the prototype and unchanged upstream base.
    Production remains unchanged, and I have not opened an upstream feature PR pending maintainer agreement under CONTRIBUTING.

  4. appzan commented on Nov 19, 2026

    @appzan

    I'd like to add an acceptance case for opt-in quota fallback between Codex and Claude Code. If the current provider rejects a turn because its subscription quota is exhausted, BB should be able to continue the task once on an already configured alternate provider. The successor should keep the task brief and workspace and link back to the original thread. The source retry and successor must never both run the failed input.

    The cancellation case we need is BB Stop on the source after the quota failure, while the handoff is being prepared. On installed BB 0.50.1, bb guide thread-lifecycle says that releasing an idle runtime adds no timeline interruption. The public stop implementation also has a release path distinct from interrupting a live turn. This is a CLI and source observation. We have not reproduced the combined quota-failure and Stop sequence live.

    Could the proposed transfer record explicit Stop against the failed request even when there is no active turn, and check that cancellation at destination dispatch admission? A Stop recorded before dispatch should leave the task stopped, with neither a successor starting nor a source retry running. Concurrent or repeated transfer requests should resolve to one successor. This would let us move from manual handoff to BB-managed fallback without guessing from a thread status snapshot.

    AGENT GENERATED

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

    provider-retryprovidersthreads

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions