The best way to control Claude Code, Codex and more from any computer or phone
test(server): Claude steer test no longer hangs for 120s under CI load (#22533)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 20, 2026 at 15:28 UTC
5d27ecd79c33a642efcdf259e89e3eba5a560247
1 file changed
+22
-12
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+22
-12
@@ -17500,6 +17500,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
17500
const FINISHED_TOOL_USE_ID = "toolu-steer-finished";
17501
const calls: Array<string> = [];
17502
let beforeAnswer: Effect.Effect<void> = Effect.void;
17503
+ const lateAnswer = yield* Deferred.make<void>();
17504
const harness = yield* makeWakeHarnessWithOptions({
17505
backgroundTasks: (toolUseId) =>
17506
Effect.sync(() => calls.push(toolUseId)).pipe(
@@ -17517,7 +17518,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
17518
: backgrounding === "never answers"
17519
? Effect.never
17520
: backgrounding === "answers after the steer went out"
17520
- ? Effect.sleep("6 seconds").pipe(Effect.as(true))
17521
+ ? Deferred.await(lateAnswer).pipe(Effect.as(true))
17522
: Effect.succeed(true),
17523
),
17524
),
@@ -17670,16 +17671,29 @@ describe("ClaudeAdapterV2 background wake turns", () => {
17671
),
17672
);
17673
}
17674
+ // The steer arms its 5-second backgrounding timeout after the request
17675
+ // starts on another fiber, so one TestClock.adjust can land before that
17676
+ // timer exists and leave the steer waiting forever. Tick until it ends.
17677
+ const awaitSteerTimeout = <A, E>(fiber: Fiber.Fiber<A, E>) =>
17678
+ Effect.gen(function* () {
17679
+ for (let tick = 0; tick < 100 && fiber.pollUnsafe() === undefined; tick++) {
17680
+ yield* TestClock.adjust("1 second");
17681
+ yield* Effect.yieldNow;
17682
+ }
17683
+ if (fiber.pollUnsafe() === undefined) {
17684
+ return yield* Effect.die("Timed out waiting for the steer.");
17685
+ }
17686
+ return yield* Fiber.await(fiber);
17687
+ });
17688
const steering = yield* Effect.forkScoped(steer);
17674
- if (
17689
+ const timesOut =
17690
backgrounding === "never answers" ||
17676
- backgrounding === "answers after the steer went out"
17677
- ) {
17691
+ backgrounding === "answers after the steer went out";
17692
+ if (timesOut) {
17693
yield* awaitUntil(() => calls.length === 1, "background request");
17694
assert.equal(harness.offeredMessages.length, offered);
17680
- yield* TestClock.adjust("5 seconds");
17695
}
17682
- const steered = yield* Fiber.await(steering);
17696
+ const steered = yield* timesOut ? awaitSteerTimeout(steering) : Fiber.await(steering);
17697
17698
assert.deepEqual(calls, [FOREGROUND_TOOL_USE_ID]);
17699
if (backgrounding === "answers after the turn ended") {
@@ -17693,17 +17707,13 @@ describe("ClaudeAdapterV2 background wake turns", () => {
17707
if (backgrounding === "never answers") {
17708
for (let repeat = 1; repeat <= 2; repeat++) {
17709
const again = yield* Effect.forkScoped(steer);
17696
- for (let tick = 0; tick < 100 && again.pollUnsafe() === undefined; tick++) {
17697
- yield* TestClock.adjust("1 second");
17698
- yield* Effect.yieldNow;
17699
- }
17700
- assert.isTrue(Exit.isSuccess(yield* Fiber.await(again)));
17710
+ assert.isTrue(Exit.isSuccess(yield* awaitSteerTimeout(again)));
17711
assert.equal(harness.offeredMessages.length, offered + 1 + repeat);
17712
}
17713
assert.deepEqual(calls, [FOREGROUND_TOOL_USE_ID]);
17714
}
17715
if (backgrounding === "answers after the steer went out") {
17706
- yield* TestClock.adjust("1 second");
17716
+ yield* Deferred.succeed(lateAnswer, undefined);
17717
} else if (
17718
backgrounding !== "succeeds" &&
17719
backgrounding !== "answers after the subagent ran again"