@@ -3159,6 +3159,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
31593159 readonly freshQueueOnReopen?: boolean;
31603160 readonly forkSession?: ClaudeAdapterV2.ClaudeAgentSdkQueryRunnerShape["forkSession"];
31613161 readonly allocateSessionId?: Effect.Effect<string>;
3162+ readonly promptSuggestions?: boolean;
31623163 }) =>
31633164 Effect.gen(function* () {
31643165 const fileSystem = yield* FileSystem.FileSystem;
@@ -3329,6 +3330,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
33293330 providerSessionId: ProviderSessionId.make("provider-session-claude-wake"),
33303331 modelSelection: CLAUDE_TEST_MODEL_SELECTION,
33313332 runtimePolicy: CLAUDE_TEST_RUNTIME_POLICY,
3333+ promptSuggestions: Effect.succeed(options?.promptSuggestions === true),
33323334 });
33333335 const providerThread = yield* runtime.ensureThread({
33343336 threadId,
@@ -7864,6 +7866,101 @@ describe("ClaudeAdapterV2 background wake turns", () => {
78647866 ),
78657867 );
78667868
7869+ it.effect.each(["root", "mcp", "subagent", "remote"] as const)(
7870+ "asks Claude for suggestions only on threads a person drives (%s)",
7871+ (lineage) =>
7872+ Effect.gen(function* () {
7873+ const harness = yield* makeWakeHarnessWithOptions({ promptSuggestions: true });
7874+ const base = makeClaudeTestTurnInput({
7875+ threadId: harness.threadId,
7876+ providerThread: harness.providerThread,
7877+ now: yield* DateTime.now,
7878+ attemptId: RunAttemptId.make("attempt-prompt-suggestion"),
7879+ text: "Add a subtract function.",
7880+ attachments: [],
7881+ });
7882+ const parentThreadId = ThreadId.make("thread-claude-suggestion-parent");
7883+ // MCP-launched root threads carry `delegatedFrom: null` at runtime.
7884+ const offered = lineage === "root" || lineage === "mcp";
7885+ const input =
7886+ lineage === "root"
7887+ ? base
7888+ : lineage === "mcp"
7889+ ? {
7890+ ...base,
7891+ appThread: {
7892+ ...base.appThread,
7893+ delegatedFrom: null as unknown as undefined,
7894+ },
7895+ }
7896+ : lineage === "subagent"
7897+ ? {
7898+ ...base,
7899+ appThread: {
7900+ ...base.appThread,
7901+ lineage: {
7902+ parentThreadId,
7903+ relationshipToParent: "subagent" as const,
7904+ rootThreadId: parentThreadId,
7905+ },
7906+ },
7907+ }
7908+ : {
7909+ ...base,
7910+ appThread: {
7911+ ...base.appThread,
7912+ delegatedFrom: {
7913+ environmentId: EnvironmentId.make("environment-claude-suggestion-parent"),
7914+ threadId: parentThreadId,
7915+ title: "Parent",
7916+ },
7917+ },
7918+ };
7919+ yield* harness.runtime.startTurn(input);
7920+ yield* Queue.offer(
7921+ harness.sdkMessages,
7922+ makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000690", result: "Done." }),
7923+ );
7924+ yield* Queue.take(harness.terminalReceipts);
7925+ // Delegated threads have no one typing, so the SDK is never asked for suggestions.
7926+ assert.equal(harness.getOpenedOptions()?.promptSuggestions, offered);
7927+ if (!offered) return;
7928+ yield* Queue.offer(
7929+ harness.sdkMessages,
7930+ claudeSdkFrame({
7931+ type: "prompt_suggestion",
7932+ suggestion: " add tests for subtract\n",
7933+ uuid: "00000000-0000-4000-8000-000000000691",
7934+ session_id: WAKE_NATIVE_SESSION,
7935+ }),
7936+ );
7937+ yield* harness.until(() =>
7938+ harness.events.some((event) => event.type === "prompt_suggestion.updated"),
7939+ );
7940+ assert.deepEqual(
7941+ harness.events.filter((event) => event.type === "prompt_suggestion.updated"),
7942+ [
7943+ {
7944+ type: "prompt_suggestion.updated",
7945+ driver: ClaudeAdapterV2.CLAUDE_PROVIDER,
7946+ threadId: harness.threadId,
7947+ runId: input.runId,
7948+ text: "add tests for subtract",
7949+ },
7950+ ],
7951+ );
7952+ }).pipe(
7953+ Effect.provide(
7954+ Layer.mergeAll(
7955+ IdAllocator.layer,
7956+ McpProviderSessions.layer,
7957+ NodeServices.layer,
7958+ NodeCrypto.layer,
7959+ ),
7960+ ),
7961+ ),
7962+ );
7963+
78677964 it.effect("merges cumulative stream usage into the message_start counts", () =>
78687965 Effect.gen(function* () {
78697966 const harness = yield* makeWakeHarnessWithOptions({
0 commit comments