@@ -2806,6 +2806,75 @@ describe("ClaudeAdapterV2 background wake turns", () => {
28062806 ),
28072807 );
28082808
2809+ it.effect.each([
2810+ { model: "claude-opus-5-5", expected: "assistant_message" },
2811+ { model: "claude-fable-5-1", expected: "assistant_message" },
2812+ { model: "claude-opus-5", expected: "reasoning" },
2813+ { model: "claude-sonnet-4-6", expected: "reasoning" },
2814+ ] as const)(
2815+ "shows $model thinking right before a tool call as $expected",
2816+ ({ model, expected }) =>
2817+ Effect.gen(function* () {
2818+ const harness = yield* makeWakeHarness;
2819+ yield* harness.runtime.startTurn(
2820+ makeClaudeTestTurnInput({
2821+ threadId: harness.threadId,
2822+ providerThread: harness.providerThread,
2823+ now: yield* DateTime.now,
2824+ attemptId: RunAttemptId.make("thinking-before-tool-attempt"),
2825+ text: "Check the memory file",
2826+ attachments: [],
2827+ }),
2828+ );
2829+ const snapshot = (uuid: string, content: ReadonlyArray<unknown>) =>
2830+ claudeSdkFrame({
2831+ type: "assistant",
2832+ uuid,
2833+ session_id: WAKE_NATIVE_SESSION,
2834+ parent_tool_use_id: null,
2835+ message: { id: "reply-message", model, content },
2836+ });
2837+ const frames = [
2838+ snapshot("reasoning-snapshot", [
2839+ { type: "thinking", thinking: "Planning the check", signature: "sig" },
2840+ ]),
2841+ snapshot("reply-snapshot", [
2842+ {
2843+ type: "thinking",
2844+ thinking: "Found it: the memory file is the cause.",
2845+ signature: "sig",
2846+ },
2847+ ]),
2848+ snapshot("tool-snapshot", [
2849+ { type: "tool_use", id: "tool-1", name: "Bash", input: { command: "ls" } },
2850+ ]),
2851+ makeResultFrame({ uuid: "thinking-before-tool-result", result: "" }),
2852+ ];
2853+ for (const frame of frames) yield* Queue.offer(harness.sdkMessages, frame);
2854+ yield* Queue.take(harness.terminalReceipts);
2855+ const latest = new Map(
2856+ harness.events.flatMap((event) =>
2857+ event.type === "turn_item.updated" &&
2858+ (event.turnItem.type === "reasoning" || event.turnItem.type === "assistant_message")
2859+ ? [[event.turnItem.id, event.turnItem] as const]
2860+ : [],
2861+ ),
2862+ );
2863+ assert.deepEqual(
2864+ [...latest.values()].map((item) => [item.type, item.text]),
2865+ [
2866+ ["reasoning", "Planning the check"],
2867+ [expected, "Found it: the memory file is the cause."],
2868+ ],
2869+ );
2870+ }).pipe(
2871+ Effect.scoped,
2872+ Effect.provide(
2873+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
2874+ ),
2875+ ),
2876+ );
2877+
28092878 it.effect.each(["cancelled", "denied", "permission_denied", undefined])(
28102879 "preserves native tool non-execution metadata %s without inferring a denial from text",
28112880 (kind) =>
0 commit comments