Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions apps/server/src/provider/Layers/ClaudeAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ interface ClaudeTurnState {
* steered instead (the queued message continues the same turn).
*/
readonly synthetic?: boolean;
readonly items: Array<unknown>;
readonly assistantTextBlocks: Map<number, AssistantTextBlockState>;
readonly assistantTextBlockOrder: Array<AssistantTextBlockState>;
readonly capturedProposedPlanKeys: Set<string>;
Expand Down Expand Up @@ -422,10 +421,8 @@ interface ClaudeSessionContext {
resumeSessionId: string | undefined;
readonly pendingApprovals: Map<ApprovalRequestId, PendingApproval>;
readonly pendingUserInputs: Map<ApprovalRequestId, PendingUserInput>;
readonly turns: Array<{
id: TurnId;
items: Array<unknown>;
}>;
/** Turn ids completed in this live session. The native Claude session file is the transcript. */
readonly turns: Array<{ readonly id: TurnId }>;
readonly inFlightTools: Map<number, ToolInFlight>;
readonly claudeTasks: Map<string, ClaudeTaskState>;
readonly taskAgents: Map<string, ClaudeTaskAgentState>;
Expand Down Expand Up @@ -2176,10 +2173,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
}
return {
threadId,
turns: context.turns.map((turn) => ({
id: turn.id,
items: [...turn.items],
})),
turns: context.turns.map((turn) => ({ id: turn.id, items: [] })),
};
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readThread now returns empty items for completed Claude turns, changing its observable snapshot behavior. Could you add a focused adapter test that completes a turn, calls readThread, and verifies the turn ID remains while its items are empty (and item events still carry the content)?

Posted via Macroscope — Effect Service Conventions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not adding this. Asserting items is empty would only restate the literal items: [] in snapshotThread (ClaudeAdapter.ts:2176). The turn count after completed turns is already checked by readThread at ClaudeAdapter.test.ts:6631 and by the rollback snapshots at :6745, and item content is covered by the existing item event tests. readThread also has no production caller.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing tests don’t cover this observable contract: they verify turn count or events separately, but not that readThread retains the completed turn ID while omitting its items. Since readThread is part of the adapter interface, I still think the focused regression test is warranted.

Expand Down Expand Up @@ -2808,10 +2802,7 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
});
}

context.turns.push({
id: turnState.turnId,
items: [...turnState.items],
});
context.turns.push({ id: turnState.turnId });

yield* emitThreadTokenUsage(context, usageSnapshot, {
rawMethod: "claude/result",
Expand Down Expand Up @@ -3175,10 +3166,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
return;
}

if (context.turnState) {
context.turnState.items.push(message.message);
}

for (const toolResult of toolResultBlocksFromUserMessage(message)) {
const toolEntry = Array.from(context.inFlightTools.entries()).find(
([, tool]) => tool.itemId === toolResult.toolUseId,
Expand Down Expand Up @@ -3378,7 +3365,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
turnId,
startedAt,
synthetic: true,
items: [],
assistantTextBlocks: new Map(),
assistantTextBlockOrder: [],
capturedProposedPlanKeys: new Set(),
Expand Down Expand Up @@ -3461,7 +3447,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
cwd: path.resolve(context.session.cwd ?? "."),
});
}
context.turnState.items.push(message.message);
if (
normalizeClaudeActiveTokenUsage(
message.message.usage,
Expand Down Expand Up @@ -5205,7 +5190,6 @@ export const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
const turnState: ClaudeTurnState = {
turnId,
startedAt: yield* nowIso,
items: [],
assistantTextBlocks: new Map(),
assistantTextBlockOrder: [],
capturedProposedPlanKeys: new Set(),
Expand Down
Loading