t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Force stop can leave a run running when its provider turn already completed

Open nima20002000 opened this issue 3 weeks ago • 0 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

Code-derived reproduction, not executed:

  1. Create a stranded run A whose projected status is "running", whose active attempt and associated provider turn are "completed".
  2. Keep its provider session live and shared with another working application thread. Use a shared provider scope, so the thread-specific agent kill returns false.
  3. Configure the live runtime’s interrupt operation to remain pending without emitting terminal events.
  4. Call forceStopThread({ threadId, runId: A.id }).
  5. Allow the interrupt effect to reach the session manager’s timeout.

This tests the live-session variant of the completed-provider-turn state already covered by upstream’s released-session test.

Expected behavior

Force stop should settle A without requiring another successful provider interrupt, while preserving the session used by the other working thread.

Actual behavior

Because A is active, Force stop searches only for a provider turn with status "running". It excludes A’s completed provider turn and dispatches ordinary run.interrupt.

That command finds the completed provider turn and live session, then schedules another provider interrupt instead of settling A immediately. Force stop preserves the shared session and detaches the thread. When the interrupt times out, the effect marks Stop unresponsive rather than settling A, leaving A running.

This failure requires an interrupt that does not succeed; a successful interrupt can subsequently settle the run.

Impact

Minor bug or occasional failure

Force stop can return a shared-session outcome without clearing the stranded running run. It needs a provider that doesn't confirm the stop (or the timing described above), so it is occasional rather than constant.

Version or commit

main @ 9e85538535

Environment

Server integration fixture with a shared live provider session. Runtime environment not tested.

Where


Found by reading the code while porting the Stop / Force stop changes (6b1245cced, 5f2c27e706) into a fork. Derived from the code at 9e85538535; not reproduced at runtime.

nima20002000 avatar Nov 04 '26 16:11 nima20002000