@@ -17933,103 +17933,117 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1793317933 ),
1793417934 );
1793517935
17936- it.effect("reports forked skill models without guessing their effort", () =>
17937- Effect.scoped(
17938- Effect.gen(function* () {
17939- const harness = yield* makeWakeHarness;
17940- const parentModel = "claude-opus-4-6";
17941- yield* harness.runtime.startTurn(
17942- makeClaudeTestTurnInput({
17943- threadId: harness.threadId,
17944- providerThread: harness.providerThread,
17945- now: yield* DateTime.now,
17946- attemptId: RunAttemptId.make("attempt-forked-skill-model"),
17947- text: "Run two forked skills.",
17948- attachments: [],
17949- modelSelection: {
17950- ...CLAUDE_TEST_MODEL_SELECTION,
17951- model: parentModel,
17952- options: [{ id: "effort", value: "high" }],
17953- },
17954- }),
17955- );
17956- for (const frame of [
17957- ...["one", "two"].map((name, index) =>
17958- claudeSdkFrame({
17959- type: "system",
17960- subtype: "task_started",
17961- task_id: `fork-${name}`,
17962- description: `/${name}`,
17963- task_type: "local_agent",
17964- skip_transcript: true,
17965- ambient: true,
17966- uuid: `00000000-0000-4000-8000-00000000024${index}`,
17967- session_id: WAKE_NATIVE_SESSION,
17968- }),
17969- ),
17970- ...["one", "two"].map((name, index) =>
17971- claudeSdkFrame({
17972- type: "system",
17973- subtype: "task_notification",
17974- task_id: `fork-${name}`,
17975- status: "completed",
17976- summary: `/${name}`,
17977- uuid: `00000000-0000-4000-8000-00000000026${index}`,
17978- session_id: WAKE_NATIVE_SESSION,
17979- }),
17980- ),
17981- ...["one", "two"].map((name, index) =>
17982- claudeSdkFrame({
17983- type: "assistant",
17984- parent_tool_use_id: `forked-command-${name}`,
17985- agent_id: `fork-${name}`,
17986- message: {
17987- model: index === 0 ? "claude-haiku-4-5-20251001" : parentModel,
17988- id: `msg_fork_${name}`,
17989- type: "message",
17990- role: "assistant",
17991- content: [{ type: "text", text: "Done." }],
17936+ it.effect.each([false, true])(
17937+ "reports forked skill models without guessing their effort (frames before start: %s)",
17938+ (framesBeforeStart) =>
17939+ Effect.scoped(
17940+ Effect.gen(function* () {
17941+ const harness = yield* makeWakeHarness;
17942+ const parentModel = "claude-opus-4-6";
17943+ yield* harness.runtime.startTurn(
17944+ makeClaudeTestTurnInput({
17945+ threadId: harness.threadId,
17946+ providerThread: harness.providerThread,
17947+ now: yield* DateTime.now,
17948+ attemptId: RunAttemptId.make("attempt-forked-skill-model"),
17949+ text: "Run two forked skills.",
17950+ attachments: [],
17951+ modelSelection: {
17952+ ...CLAUDE_TEST_MODEL_SELECTION,
17953+ model: parentModel,
17954+ options: [{ id: "effort", value: "high" }],
1799217955 },
17993- uuid: `00000000-0000-4000-8000-00000000025${index}`,
17994- session_id: WAKE_NATIVE_SESSION,
1799517956 }),
17996- ),
17997- makeResultFrame({ uuid: "00000000-0000-4000-8000-000000000252", result: "Done." }),
17998- ]) {
17999- yield* Queue.offer(harness.sdkMessages, frame);
18000- }
18001- yield* Queue.take(harness.terminalReceipts);
18002- const subagents = harness.events.filter((event) => event.type === "subagent.updated");
18003- const children = harness.events.filter((event) => event.type === "app_thread.created");
18004- assert.lengthOf(children, 2);
18005- for (const child of children) {
18006- assert.isUndefined(
18007- getModelSelectionStringOptionValue(child.appThread.modelSelection, "effort"),
1800817957 );
18009- }
18010- for (const [name, expectedModel] of [
18011- ["one", "claude-haiku-4-5"],
18012- ["two", parentModel],
18013- ] as const) {
18014- const task = subagents.findLast(
18015- (event) => event.subagent.nativeTaskRef?.nativeId === `fork-${name}`,
18016- )?.subagent;
18017- assert.equal(task?.model, expectedModel);
18018- assert.equal(task?.modelSelection?.model, expectedModel);
18019- assert.equal(task?.status, "completed");
18020- assert.isUndefined(getModelSelectionStringOptionValue(task?.modelSelection, "effort"));
18021- }
18022- }).pipe(
18023- Effect.provide(
18024- Layer.mergeAll(
18025- IdAllocator.layer,
18026- McpProviderSessions.layer,
18027- NodeServices.layer,
18028- NodeCrypto.layer,
17958+ const tasks = [
17959+ { id: "first-one", command: "one", model: "claude-haiku-4-5" },
17960+ { id: "first-two", command: "two", model: parentModel },
17961+ { id: "second-one", command: "one", model: parentModel },
17962+ { id: "second-two", command: "two", model: "claude-haiku-4-5" },
17963+ ];
17964+ let uuidOrdinal = 240;
17965+ const uuid = () => `00000000-0000-4000-8000-${String(++uuidOrdinal).padStart(12, "0")}`;
17966+ for (const round of [tasks.slice(0, 2), tasks.slice(2)]) {
17967+ const starts = round.map(({ id, command }) =>
17968+ claudeSdkFrame({
17969+ type: "system",
17970+ subtype: "task_started",
17971+ task_id: id,
17972+ description: `/${command}`,
17973+ task_type: "local_agent",
17974+ skip_transcript: true,
17975+ ambient: true,
17976+ uuid: uuid(),
17977+ session_id: WAKE_NATIVE_SESSION,
17978+ }),
17979+ );
17980+ const completions = round.map(({ id, command }) =>
17981+ claudeSdkFrame({
17982+ type: "system",
17983+ subtype: "task_notification",
17984+ task_id: id,
17985+ status: "completed",
17986+ summary: `/${command}`,
17987+ uuid: uuid(),
17988+ session_id: WAKE_NATIVE_SESSION,
17989+ }),
17990+ );
17991+ const assistants = round.map(({ id, command, model }) =>
17992+ claudeSdkFrame({
17993+ type: "assistant",
17994+ parent_tool_use_id: `forked-command-${command}`,
17995+ agent_id: id,
17996+ message: {
17997+ model: model === parentModel ? model : "claude-haiku-4-5-20251001",
17998+ id: `msg_fork_${id}`,
17999+ type: "message",
18000+ role: "assistant",
18001+ content: [{ type: "text", text: `Done ${id}.` }],
18002+ },
18003+ uuid: uuid(),
18004+ session_id: WAKE_NATIVE_SESSION,
18005+ }),
18006+ );
18007+ for (const frame of framesBeforeStart
18008+ ? [...assistants, ...starts, ...completions]
18009+ : [...starts, ...completions, ...assistants]) {
18010+ yield* Queue.offer(harness.sdkMessages, frame);
18011+ }
18012+ }
18013+ yield* Queue.offer(
18014+ harness.sdkMessages,
18015+ makeResultFrame({ uuid: uuid(), result: "Done." }),
18016+ );
18017+ yield* Queue.take(harness.terminalReceipts);
18018+ const subagents = harness.events.filter((event) => event.type === "subagent.updated");
18019+ const children = harness.events.filter((event) => event.type === "app_thread.created");
18020+ assert.lengthOf(children, tasks.length);
18021+ for (const child of children) {
18022+ assert.isUndefined(
18023+ getModelSelectionStringOptionValue(child.appThread.modelSelection, "effort"),
18024+ );
18025+ }
18026+ for (const { id, model: expectedModel } of tasks) {
18027+ const task = subagents.findLast(
18028+ (event) => event.subagent.nativeTaskRef?.nativeId === id,
18029+ )?.subagent;
18030+ assert.isDefined(task?.childThreadId);
18031+ assert.equal(task?.model, expectedModel);
18032+ assert.equal(task?.modelSelection?.model, expectedModel);
18033+ assert.equal(task?.status, "completed");
18034+ assert.isUndefined(getModelSelectionStringOptionValue(task?.modelSelection, "effort"));
18035+ }
18036+ }).pipe(
18037+ Effect.provide(
18038+ Layer.mergeAll(
18039+ IdAllocator.layer,
18040+ McpProviderSessions.layer,
18041+ NodeServices.layer,
18042+ NodeCrypto.layer,
18043+ ),
1802918044 ),
1803018045 ),
1803118046 ),
18032- ),
1803318047 );
1803418048
1803518049 it.effect("resolves a subagent's model and effort against the instance's custom models", () =>
0 commit comments