Skip to content

Commit 024aab1

Browse files
fix(server): a restart that misses its turn starts as a new turn
A restart_active dispatch whose target run already ended, whose provider turn completed, or that a Stop already reached failed as an unsteerable run and lost the message. Restart means interrupt and start, so when the interrupt has already happened only the start is left: the dispatch now becomes start_immediately, which waits behind a stopping run and keeps a stopped queue's hold. Explicit steers are unchanged. Fixes pingdotgg#32891 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b51547c commit 024aab1

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5831,7 +5831,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
58315831
command.dispatchMode,
58325832
command.deliveryIntent,
58335833
);
5834-
if (dispatchMode.type === "steer_active") {
5834+
if (dispatchMode.type === "steer_active" || dispatchMode.type === "restart_active") {
58355835
const targetRunId = dispatchMode.targetRunId;
58365836
const target = projection.runs.find((run) => run.id === targetRunId);
58375837
const turn = latestProviderTurnForAttempt(
@@ -5843,6 +5843,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
58435843
if (
58445844
target !== undefined &&
58455845
(target.status === "completed" ||
5846+
(dispatchMode.type === "restart_active" && !isActiveRun(target)) ||
58465847
((target.status === "running" || target.status === "waiting") &&
58475848
turn !== undefined &&
58485849
turn.status === "completed"))
@@ -5853,14 +5854,22 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
58535854
// Stop leaves the run reading as running until its provider stops. A plain
58545855
// send in that window queues behind the stopped queue instead of steering
58555856
// text the agent never receives, and like any user send it releases the
5856-
// hold; an explicit steer or restart still fails below.
5857+
// hold; an explicit steer still fails below.
58575858
if (
58585859
command.deliveryIntent === "auto" &&
58595860
(dispatchMode.type === "steer_active" || dispatchMode.type === "restart_active") &&
58605861
(yield* stopReachedRun(command, command.threadId, dispatchMode.targetRunId))
58615862
) {
58625863
dispatchMode = { type: "queue_after_active" };
58635864
}
5865+
// An explicit restart that Stop reached has only its start left; it starts
5866+
// once the stop settles and leaves the stopped queue's hold in place.
5867+
if (
5868+
dispatchMode.type === "restart_active" &&
5869+
(yield* stopReachedRun(command, command.threadId, dispatchMode.targetRunId))
5870+
) {
5871+
dispatchMode = { type: "start_immediately" };
5872+
}
58645873
const freshContext = command.freshContext === true;
58655874
if (
58665875
freshContext &&

0 commit comments

Comments
 (0)