@@ -12499,13 +12499,60 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1249912499 ),
1250012500 );
1250112501
12502- it.effect("resolves a subagent's model and effort against the instance's custom models", () =>
12502+ it.effect.each([
12503+ {
12504+ route: "bare",
12505+ reportedModel: "gateway-route",
12506+ tagged: false,
12507+ selection: { model: "gateway-route", options: [{ id: "effort", value: "high" }] },
12508+ contextWindow: undefined,
12509+ },
12510+ {
12511+ route: "expanded",
12512+ reportedModel: "gateway-route[1m]",
12513+ tagged: false,
12514+ selection: {
12515+ model: "gateway-route",
12516+ options: [
12517+ { id: "contextWindow", value: "1m" },
12518+ { id: "effort", value: "high" },
12519+ ],
12520+ },
12521+ contextWindow: 1_000_000,
12522+ },
12523+ {
12524+ route: "explicitly tagged",
12525+ reportedModel: "gateway-route[1m]",
12526+ tagged: true,
12527+ selection: { model: "gateway-route[1m]", options: [{ id: "effort", value: "high" }] },
12528+ contextWindow: 1_000_000,
12529+ },
12530+ {
12531+ route: "unconfigured",
12532+ reportedModel: "unconfigured-route[1m]",
12533+ tagged: false,
12534+ selection: { model: "unconfigured-route[1m]" },
12535+ contextWindow: undefined,
12536+ },
12537+ ])("resolves custom subagent models, effort, and $route context", (testCase) =>
1250312538 Effect.scoped(
1250412539 Effect.gen(function* () {
1250512540 const TUNED_TOOL_USE_ID = "toolu-effort-custom-tuned";
1250612541 const SHADOW_TOOL_USE_ID = "toolu-effort-custom-shadow";
12542+ const CONTEXT_TOOL_USE_ID = "toolu-context-custom";
1250712543 const harness = yield* makeWakeHarnessWithOptions({
12508- settings: CUSTOM_MODEL_CLAUDE_SETTINGS,
12544+ settings: {
12545+ ...CUSTOM_MODEL_CLAUDE_SETTINGS,
12546+ customModels: [
12547+ ...CUSTOM_MODEL_CLAUDE_SETTINGS.customModels,
12548+ ...CUSTOM_CONTEXT_CLAUDE_SETTINGS.customModels,
12549+ ...(testCase.tagged
12550+ ? CUSTOM_CONTEXT_CLAUDE_SETTINGS.customModels.flatMap((entry) =>
12551+ typeof entry === "string" ? [] : [{ ...entry, slug: "gateway-route[1m]" }],
12552+ )
12553+ : []),
12554+ ],
12555+ },
1250912556 });
1251012557 const now = yield* DateTime.now;
1251112558 yield* harness.runtime.startTurn(
@@ -12551,12 +12598,24 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1255112598 prompt: "Check another thing.",
1255212599 },
1255312600 },
12601+ {
12602+ type: "tool_use",
12603+ id: CONTEXT_TOOL_USE_ID,
12604+ name: "Agent",
12605+ input: {
12606+ description: "Context",
12607+ subagent_type: "general-purpose",
12608+ model: "gateway-route",
12609+ effort: "high",
12610+ prompt: "Check the context window.",
12611+ },
12612+ },
1255412613 ],
1255512614 },
1255612615 uuid: "00000000-0000-4000-8000-000000000231",
1255712616 session_id: WAKE_NATIVE_SESSION,
1255812617 }),
12559- ...[TUNED_TOOL_USE_ID, SHADOW_TOOL_USE_ID].map((id, index) =>
12618+ ...[TUNED_TOOL_USE_ID, SHADOW_TOOL_USE_ID, CONTEXT_TOOL_USE_ID ].map((id, index) =>
1256012619 claudeSdkFrame({
1256112620 type: "system",
1256212621 subtype: "task_started",
@@ -12568,8 +12627,21 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1256812627 session_id: WAKE_NATIVE_SESSION,
1256912628 }),
1257012629 ),
12630+ claudeSdkFrame({
12631+ type: "assistant",
12632+ parent_tool_use_id: CONTEXT_TOOL_USE_ID,
12633+ message: {
12634+ model: testCase.reportedModel,
12635+ id: "msg_custom_context_observed",
12636+ type: "message",
12637+ role: "assistant",
12638+ content: [{ type: "text", text: "Checking." }],
12639+ },
12640+ uuid: "00000000-0000-4000-8000-000000000235",
12641+ session_id: WAKE_NATIVE_SESSION,
12642+ }),
1257112643 makeResultFrame({
12572- uuid: "00000000-0000-4000-8000-000000000234 ",
12644+ uuid: "00000000-0000-4000-8000-000000000236 ",
1257312645 result: "Spawned the subagents.",
1257412646 }),
1257512647 ]) {
@@ -12592,7 +12664,12 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1259212664 options: [{ id: "effort", value: "brutal" }],
1259312665 },
1259412666 [`task-${SHADOW_TOOL_USE_ID}`]: { instanceId, model: "opus" },
12667+ [`task-${CONTEXT_TOOL_USE_ID}`]: { instanceId, ...testCase.selection },
1259512668 });
12669+ assert.strictEqual(
12670+ harness.runtime.getModelContextWindow?.(selections[`task-${CONTEXT_TOOL_USE_ID}`]),
12671+ testCase.contextWindow,
12672+ );
1259612673 }).pipe(
1259712674 Effect.provide(
1259812675 Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
0 commit comments