Skip to content
Source
Sign inSign up
pingdotgg/t3code

Feat/mid thread provider switching #9392

ClosedBandaySajid(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/9392/headopened View on GitHub

What Changed

Unlocks mid-thread provider switching. Previously threads were locked to their initial provider instance, switching Codex/Claude/OpenCode mid-conversation was either blocked in the UI or failed with a hard driver-mismatch error. Now the server stops the previous provider session cleanly, starts a fresh one without incompatible driver cursors, and injects a synthesized Markdown conversation-history block into the initial turn prompt so the new provider has context. Follow-up fixes keep skill chips intact across the switch, keep the handoff transparent to the user (no "previous agent" leakage), and preserve session state correctly across switches.

Why

Users want to change providers mid-conversation, e.g. moving from Codex to Claude when they hit a subscription usage limit,without losing thread history or starting over. The previous hard-block/driver-mismatch failure made that impossible.

UI Changes

NONE


Note

High Risk Changes core turn/session orchestration and injects large synthesized prompts on provider handoff; regressions could affect session binding, input limits, or continuity on retry/failure paths.

Overview Mid-thread provider switching is now supported end-to-end. The server no longer rejects cross-driver or incompatible-continuation switches; on handoff it stops the prior session, starts the new provider with an explicit clean resume (resumeCursor: null), and on the first post-switch turn prepends a bounded [Thread Continuity Context] block (prior user/assistant text, re-carried attachments, escaped $skill tokens) plus Current Request. Failed sends that included that context re-queue the handoff so retries still carry history.

ProviderService treats resumeCursor: null as a forced fresh session; omitting the field still reuses a persisted cursor when the instance matches.

Clients unlock the provider picker for started threads unless the active instance sets requiresNewThreadForModelChange. Composers and timelines use resolveProviderSkillsForCwdAcrossProviders (with per-provider fallback in slash menus) so skills stay visible after a switch.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2bfe9088b2d27b42b5fcb2dac60ebebfb63265ca. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add mid-thread provider switching with conversation continuity and cross-provider skills

  • ProviderCommandReactor.ensureSessionForThread replaces rejection of cross-driver model switches with handoff handling: stops the old session, starts the new provider with a null resume cursor, and builds a bounded continuity prompt from prior user/assistant messages and attachments.
  • ProviderService.startSession distinguishes omitted vs explicit null resume cursors, forcing a clean adapter session when null is passed so persisted cursors are not reused.
  • deriveLockedProvider in ChatView.logic.ts now uses provider snapshots to lock a started thread only when the current provider explicitly requires a new thread for model changes.
  • Web and mobile composers and timelines use the new resolveProviderSkillsForCwdAcrossProviders to show deduplicated skills from all configured providers, falling back when the selected provider has no cwd-resolved skills.
  • escapeThreadContinuitySkillTokens prefixes standalone dollar skill tokens with a backslash so continuity prompts do not trigger skill execution on the replacement provider.
  • Risk: buildSendTurnRequestForThread clears the pending-continuity flag only after session/capability checks; a send failure restores it via the turn-start processor. Reviewers should verify the flag lifecycle in ProviderCommandReactor.ts to ensure retries rebuild context and that no path leaves the flag stuck.
Macroscope summarized 2bfe908.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/dfd70ed9ee8a7d71101f03a116f3d47405308c6f/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts#L967

      After a provider handoff, a server restart causes the next turn without modelSelection to use the pre-handoff thread.modelSelection, reverting the thread to the old provider. The new selection is stored only in the process-local threadModelSelections map at 967, so it is lost on restart; persist the selected model/instance in the thread projection as part of the handoff.

      ✅ Resolved in 2bfe9088b2d27b42b5fcb2dac60ebebfb63265ca

    3. Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).

      Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dfd70ed9ee8a7d71101f03a116f3d47405308c6f. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR introduces cross-provider mid-thread handoffs with session restarts, synthesized conversation context, attachment propagation, and coordinated web/mobile UI changes, rather than a small isolated adjustment. An unresolved high-severity finding also identifies a concrete request-size failure risk for handoffs carrying attachments.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge closed this

    6. Closing as part of the open-PR backlog sweep (wave 2).

      Reason: Duplicate mid-thread provider switch of more complete #9181 Related: #9181

      Reopen if this is still wanted and you’re willing to rebase onto current main.

Sign in to join this conversation.