Skip to content

Commit b0614c2

Browse files
committed
test(server): stabilize repeated Claude steer checks
Wait for the background request with a Deferred. Use the live clock for repeated steers so their timeouts are registered after asynchronous skill loading.
1 parent 5edb146 commit b0614c2

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17499,10 +17499,12 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1749917499
const NESTED_TOOL_USE_ID = "toolu-steer-nested";
1750017500
const FINISHED_TOOL_USE_ID = "toolu-steer-finished";
1750117501
const calls: Array<string> = [];
17502+
const backgroundRequested = yield* Deferred.make<void>();
1750217503
let beforeAnswer: Effect.Effect<void> = Effect.void;
1750317504
const harness = yield* makeWakeHarnessWithOptions({
1750417505
backgroundTasks: (toolUseId) =>
1750517506
Effect.sync(() => calls.push(toolUseId)).pipe(
17507+
Effect.andThen(Deferred.succeed(backgroundRequested, undefined)),
1750617508
Effect.andThen(
1750717509
backgrounding === "answers after the turn ended" ||
1750817510
backgrounding === "answers after the subagent ran again"
@@ -17675,7 +17677,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1767517677
backgrounding === "never answers" ||
1767617678
backgrounding === "answers after the steer went out"
1767717679
) {
17678-
yield* awaitUntil(() => calls.length === 1, "background request");
17680+
yield* Deferred.await(backgroundRequested);
1767917681
assert.equal(harness.offeredMessages.length, offered);
1768017682
yield* TestClock.adjust("5 seconds");
1768117683
}
@@ -17692,12 +17694,8 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1769217694
assert.equal(harness.offeredMessages.at(-1)?.priority, "now");
1769317695
if (backgrounding === "never answers") {
1769417696
for (let repeat = 1; repeat <= 2; repeat++) {
17695-
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)));
17697+
const again = yield* TestClock.withLive(Effect.exit(steer));
17698+
assert.isTrue(Exit.isSuccess(again));
1770117699
assert.equal(harness.offeredMessages.length, offered + 1 + repeat);
1770217700
}
1770317701
assert.deepEqual(calls, [FOREGROUND_TOOL_USE_ID]);

0 commit comments

Comments
 (0)