Skip to content

Commit b372fbb

Browse files
committed
test(server): cover the continuation after rolling back a subagent-only Claude turn
1 parent 596b042 commit b372fbb

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3396,7 +3396,11 @@ describe("ClaudeAdapterV2 background wake turns", () => {
33963396

33973397
it.effect("never records a subagent uuid for a turn with no main-thread assistant message", () =>
33983398
Effect.gen(function* () {
3399-
const harness = yield* makeRollbackHarness;
3399+
// The continuation turn reopens the query, and rollback shut the first queue down.
3400+
const harness = yield* makeWakeHarnessWithOptions({
3401+
close: (sdkMessages) => Queue.shutdown(sdkMessages),
3402+
freshQueueOnReopen: true,
3403+
});
34003404
const now = yield* DateTime.now;
34013405
const subagentUuid = "00000000-0000-4000-8000-000000000644";
34023406
yield* harness.runtime.startTurn(
@@ -3445,6 +3449,32 @@ describe("ClaudeAdapterV2 background wake turns", () => {
34453449
]).pipe(Effect.flip);
34463450
assert.instanceOf(error, ProviderAdapter.ProviderAdapterRollbackThreadError);
34473451
assert.include(String(error.cause), "no SDK assistant message cursor");
3452+
3453+
yield* harness.runtime.startTurn(
3454+
makeClaudeTestTurnInput({
3455+
threadId: harness.threadId,
3456+
providerThread: latest.providerThread,
3457+
now,
3458+
attemptId: RunAttemptId.make("attempt-claude-cursor-subagent-only-next"),
3459+
text: "Continue.",
3460+
attachments: [],
3461+
providerTurnOrdinal: 2,
3462+
}),
3463+
);
3464+
const reopenedQueue = harness.processQueues[1];
3465+
assert.isDefined(reopenedQueue);
3466+
if (reopenedQueue === undefined) return;
3467+
yield* Queue.offerAll(reopenedQueue, [
3468+
makeAssistantTextFrame({
3469+
uuid: "00000000-0000-4000-8000-000000000646",
3470+
text: "Continuing.",
3471+
}),
3472+
makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000647", result: "Done." }),
3473+
]);
3474+
const next = yield* Queue.take(harness.terminalReceipts);
3475+
assert.equal(next.status, "completed");
3476+
// The reopened query must resume from the whole transcript, not pin a subagent uuid.
3477+
assert.isUndefined(harness.getOpenedOptions()?.resumeSessionAt);
34483478
}).pipe(
34493479
Effect.provide(
34503480
Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),

0 commit comments

Comments
 (0)