Skip to content

fix(server): stop provider handoffs from leaving threads stuck - #1085

Merged
badcuban merged 2 commits into
mainfrom
fix/stuck-thread-status
Nov 24, 2026
Merged

badcuban merged 2 commits into
mainfrom
fix/stuck-thread-status

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

Switching a thread between providers could let the outgoing provider's session.exited event overwrite the newly bound session back to the old provider. Once the projected session and live runtime disagreed, ProviderRuntimeIngestion dropped every subsequent event from the live provider as stale and left the thread stuck on Preparing turn. During the same handoff window, concurrent ProviderService.listSessions() calls (such as CheckpointReactor) could also die on a transient binding mismatch.

Fix

  • Require runtime-originated thread.session.set commands to match the thread's current participant, provider instance, and in-flight launch target in both ProviderRuntimeIngestion and the orchestration decider (requireCurrentSession).
  • Mark cross-provider handoffs on ready threads (such as goal updates) as launching so outgoing exit events are blocked before the new bind lands.
  • Rebind drifted session projections when ProviderCommandReactor.ensureSessionForThread reuses a live runtime, preserving any active turn ID.
  • Stop copying the outgoing providerThreadId onto a different provider/driver in bindSessionToThread, and include providerThreadId on AcpAdapter's returned ProviderSession.
  • Track active and just-completed handoff instance pairs in ProviderService.listSessions() so concurrent callers skip only the in-transition half while genuine out-of-band binding corruption still dies.

Switching a thread between providers could let the outgoing provider's session.exited event overwrite the newly bound session back to the old provider, causing ProviderRuntimeIngestion to drop every event from the live session and freeze the thread on Preparing turn. A concurrent listSessions() call during that same handoff window could also die on a transient provider/binding mismatch.

Guard runtime session updates against stale provider instances, in-flight launches, and participant handovers in both ProviderRuntimeIngestion and the orchestration decider, rebind drifted projections when reusing a live runtime without dropping an active turn, stop leaking the outgoing providerThreadId across handoffs (and populate it on ACP sessions), and omit only the in-transition session pair in ProviderService.listSessions() while a replacement start is in flight.
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 24, 2026 6:40am UTC

Request Review

The handoff and rebind test checked session.status === "running" immediately after sendTurn was invoked, before the forked markProviderTurnAccepted fiber finished on slower CI runners. Wait for both sendTurn and the running projection before asserting or advancing to the next step.
@badcuban
badcuban added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 1be7360 Nov 24, 2026
25 checks passed
@badcuban
badcuban deleted the fix/stuck-thread-status branch November 24, 2026 06:50

This branch was previously deployed

1 inactive deployment
Preview — f5664eaa Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant