Skip to content

Commit 9223781

Browse files
fix(server): a Claude steer no longer waits forever on an unanswered interrupt
The SDK puts no deadline on the interrupt control request, so a CLI that never answers it held the steer indefinitely. The steer now waits at most 5 seconds and is then sent, as when the interrupt fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 133b3ed commit 9223781

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3749,6 +3749,26 @@ describe("ClaudeAdapterV2 background wake turns", () => {
37493749
),
37503750
);
37513751

3752+
// The SDK puts no deadline on the interrupt control request.
3753+
it.effect("a steer is still sent when the command interrupt is never answered", () =>
3754+
Effect.scoped(
3755+
Effect.gen(function* () {
3756+
const interruptStarted = yield* Deferred.make<void>();
3757+
const harness = yield* makeWakeHarnessWithOptions({
3758+
interrupt: Deferred.succeed(interruptStarted, undefined).pipe(
3759+
Effect.andThen(Effect.never),
3760+
),
3761+
});
3762+
const { steer } = yield* steerDuringRunningBash(harness, "steer-interrupt-unanswered");
3763+
const steering = yield* steer.pipe(Effect.forkScoped);
3764+
yield* Deferred.await(interruptStarted);
3765+
yield* TestClock.adjust("5 seconds");
3766+
yield* Fiber.join(steering);
3767+
assert.equal(harness.offeredMessages[1]?.priority, "now");
3768+
}).pipe(Effect.provide(steerTestLayer)),
3769+
),
3770+
);
3771+
37523772
it.effect("announces usage-limit pauses once per window and again on a new turn", () =>
37533773
Effect.gen(function* () {
37543774
const harness = yield* makeWakeHarness;

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ const WORKFLOW_MEMBER_TRANSCRIPT_FLUSH_MS = 500;
313313
// A steer waits at most this long, from its request, for its foreground
314314
// subagents to move to the background before it is sent.
315315
const BACKGROUND_MOVE_TIMEOUT_MS = 5_000;
316+
// A steer waits at most this long for the CLI to answer the interrupt of a
317+
// running command before it is sent anyway.
318+
const CLAUDE_STEER_INTERRUPT_TIMEOUT = "5 seconds";
316319

317320
const CLAUDE_GROUP_WATCH_SCRIPT = [
318321
"{ trap '' TERM; read -r _ <&3; kill -TERM 0; sleep 5; kill -KILL 0; } </dev/null >/dev/null 2>&1 &",
@@ -9948,9 +9951,16 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
99489951
[...currentTurn.toolCalls.values()].some((call) => call.toolName === "Bash") &&
99499952
(yield* Ref.get(pendingRuntimeRequests)).size === 0
99509953
) {
9951-
// The CLI may have aborted before the request failed, and that
9952-
// result is swallowed, so the steer is still sent to continue.
9954+
// The CLI may have aborted before the request failed or timed out,
9955+
// and that result is swallowed, so the steer is still sent to continue.
99539956
yield* existing.query.interrupt.pipe(
9957+
Effect.timeoutOrElse({
9958+
duration: CLAUDE_STEER_INTERRUPT_TIMEOUT,
9959+
orElse: () =>
9960+
Effect.fail(
9961+
queryRunnerError("Claude Code did not answer the interrupt.", "interrupt"),
9962+
),
9963+
}),
99549964
Effect.catch((cause) =>
99559965
Effect.logWarning("orchestration-v2.claude-steer-interrupt-failed", { cause }),
99569966
),

0 commit comments

Comments
 (0)