Skip to content

Commit fafbc6f

Browse files
committed
test(server): pin that Claude turn snapshots drop SDK messages
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Vkxwfu3bhLfZE4x2Fx8hra
1 parent 524f1cf commit fafbc6f

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

‎apps/server/src/provider/Layers/ClaudeAdapter.test.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6691,6 +6691,56 @@ describe("ClaudeAdapterLive", () => {
66916691
);
66926692
});
66936693

6694+
it.effect("completed turns keep their ids but not the SDK messages", () => {
6695+
const harness = makeHarness();
6696+
return Effect.gen(function* () {
6697+
const adapter = yield* ClaudeAdapter;
6698+
const session = yield* adapter.startSession({
6699+
threadId: THREAD_ID,
6700+
provider: ProviderDriverKind.make("claudeAgent"),
6701+
runtimeMode: "full-access",
6702+
});
6703+
const turn = yield* adapter.sendTurn({
6704+
threadId: session.threadId,
6705+
input: "hello",
6706+
attachments: [],
6707+
});
6708+
const completedFiber = yield* Stream.filter(
6709+
adapter.streamEvents,
6710+
(event) => event.type === "turn.completed",
6711+
).pipe(Stream.runHead, Effect.forkChild);
6712+
6713+
harness.query.emit({
6714+
type: "assistant",
6715+
session_id: "sdk-session-1",
6716+
uuid: "assistant-1",
6717+
parent_tool_use_id: null,
6718+
message: {
6719+
id: "assistant-message-1",
6720+
content: [{ type: "text", text: "Hi" }],
6721+
},
6722+
} as unknown as SDKMessage);
6723+
harness.query.emit({
6724+
type: "result",
6725+
subtype: "success",
6726+
is_error: false,
6727+
errors: [],
6728+
session_id: "sdk-session-1",
6729+
uuid: "result-1",
6730+
} as unknown as SDKMessage);
6731+
yield* Fiber.join(completedFiber);
6732+
6733+
const snapshot = yield* adapter.readThread(session.threadId);
6734+
assert.deepEqual(
6735+
snapshot.turns.map((entry) => ({ id: String(entry.id), items: entry.items })),
6736+
[{ id: String(turn.turnId), items: [] }],
6737+
);
6738+
}).pipe(
6739+
Effect.provideService(Random.Random, makeDeterministicRandomService()),
6740+
Effect.provide(harness.layer),
6741+
);
6742+
});
6743+
66946744
it.effect("rewinds Claude history when the fork omits retained system messages", () => {
66956745
const forkCalls: Array<Parameters<NonNullable<ClaudeAdapterLiveOptions["forkSession"]>>> = [];
66966746
let firstTurnId = "";

0 commit comments

Comments
 (0)