Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions apps/server/src/orchestration-v2/CommandPolicy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function dispatchProjection(
sessionCapabilities === undefined
? []
: [{ runAttemptId: activeAttemptId, status: "running" }],
runtimeRequests: [],
} as unknown as OrchestrationV2ThreadProjection;
}

Expand Down Expand Up @@ -133,6 +134,29 @@ it.each(["preparing", "starting"] as const)(
},
);

// Claude's steer cancels an open question or approval.
it.each(["user_input", "command"] as const)(
"queues only automatic delivery while a %s request waits on the user",
(kind) => {
const projection = {
...dispatchProjection(baseCapabilities),
runtimeRequests: [{ kind, status: "pending" }],
} as unknown as OrchestrationV2ThreadProjection;
assert.deepEqual(
CommandPolicy.resolveMessageDispatchIntent(projection, { type: "start_immediately" }, "auto"),
{ type: "queue_after_active" },
);
assert.deepEqual(
CommandPolicy.resolveMessageDispatchIntent(
projection,
{ type: "start_immediately" },
"steer",
),
{ type: "steer_active", targetRunId: activeRunId },
);
},
);

it.each([
["has not started", []],
["is pending", [{ runAttemptId: activeAttemptId, status: "pending" }]],
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/orchestration-v2/CommandPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ function resolveDeliveryIntent(
) {
return { type: "queue_after_active" };
}
// Steering can withdraw a question or approval the user is still answering.
if (projection.runtimeRequests.some((request) => request.status === "pending")) {
return { type: "queue_after_active" };
}

const capabilities = providerTurnCapabilities(projection, activeRun);
if (capabilities?.supportsActiveSteering === true) {
Expand Down
Loading