diff --git a/apps/cli/src/runtime/interactive/computer-user.test.ts b/apps/cli/src/runtime/interactive/computer-user.test.ts index 0034571524..8e5e669ec5 100644 --- a/apps/cli/src/runtime/interactive/computer-user.test.ts +++ b/apps/cli/src/runtime/interactive/computer-user.test.ts @@ -186,7 +186,7 @@ describe("createInteractiveComputerUser", () => { await result?.dispose(); }); - it("starts the helper with one adaptive reasoning snapshot", async () => { + it("starts the helper with one moderate adaptive reasoning snapshot", async () => { const started = await startStubBackend(); server = started.server; destroyConnections = started.destroyConnections; @@ -204,9 +204,14 @@ describe("createInteractiveComputerUser", () => { stop: vi.fn(async () => {}), dispose: vi.fn(async () => {}), }); + const driverConfig = { + ...makeConfig(), + thinking: true, + reasoningEffort: "high" as const, + }; const result = await createInteractiveComputerUser({ - config: makeConfig(), + config: driverConfig, providerSettingsManager: makeSettings({ provider: "anthropic", apiKey: "sk-ant-x", @@ -223,7 +228,7 @@ describe("createInteractiveComputerUser", () => { notifyDriver: () => {}, env: { CLINE_COMPUTER_USE_PORT: String(started.port), - CLINE_COMPUTER_USER_MODEL: "claude-opus-4-7", + CLINE_COMPUTER_USER_MODEL: "anthropic/claude-sonnet-5", } as NodeJS.ProcessEnv, }); const startTool = result?.driverTools.find( @@ -236,14 +241,14 @@ describe("createInteractiveComputerUser", () => { interactive: true, config: expect.objectContaining({ providerId: "anthropic", - modelId: "claude-opus-4-7", + modelId: "claude-sonnet-5", thinking: true, - reasoningEffort: "high", + reasoningEffort: "medium", providerConfig: expect.objectContaining({ providerId: "anthropic", - modelId: "claude-opus-4-7", + modelId: "claude-sonnet-5", thinking: true, - reasoningEffort: "high", + reasoningEffort: "medium", clientType: undefined, routingProviderId: undefined, thinkingBudgetTokens: undefined, @@ -253,6 +258,10 @@ describe("createInteractiveComputerUser", () => { expect(start.mock.calls[0]?.[0]?.config).not.toHaveProperty( "thinkingBudgetTokens", ); + expect(driverConfig).toMatchObject({ + thinking: true, + reasoningEffort: "high", + }); await result?.dispose(); }); @@ -327,6 +336,14 @@ describe("resolveHelperModelId", () => { ).toBe("claude-opus-4-7"); }); + it("removes the redundant namespace for the direct Anthropic provider", () => { + expect( + resolveHelperModelId(undefined, { + CLINE_COMPUTER_USER_MODEL: "anthropic/claude-sonnet-5", + } as NodeJS.ProcessEnv), + ).toBe("claude-sonnet-5"); + }); + it("falls back to the Anthropic provider entry's saved model", () => { expect( resolveHelperModelId( diff --git a/apps/cli/src/runtime/interactive/computer-user.ts b/apps/cli/src/runtime/interactive/computer-user.ts index ddb6e69893..aaa1f89af9 100644 --- a/apps/cli/src/runtime/interactive/computer-user.ts +++ b/apps/cli/src/runtime/interactive/computer-user.ts @@ -40,9 +40,16 @@ const HELPER_DEFAULT_MODEL_ID = "claude-sonnet-4-6"; const HELPER_MODEL_ENV_VAR = "CLINE_COMPUTER_USER_MODEL"; const HELPER_REASONING = { thinking: true, - reasoningEffort: "high" as const, + reasoningEffort: "medium" as const, }; +function toDirectAnthropicModelId(modelId: string): string { + const directProviderPrefix = `${HELPER_PROVIDER_ID}/`; + return modelId.startsWith(directProviderPrefix) + ? modelId.slice(directProviderPrefix.length) + : modelId; +} + /** * Resolves the helper's Anthropic model id. The helper's model is chosen * independently of the driver's: CLINE_COMPUTER_USER_MODEL wins, then the @@ -58,13 +65,13 @@ export function resolveHelperModelId( ): string { const fromEnv = env[HELPER_MODEL_ENV_VAR]?.trim(); if (fromEnv) { - return fromEnv; + return toDirectAnthropicModelId(fromEnv); } if ( typeof helperSettings?.model === "string" && helperSettings.model.trim() ) { - return helperSettings.model.trim(); + return toDirectAnthropicModelId(helperSettings.model.trim()); } return HELPER_DEFAULT_MODEL_ID; } diff --git a/sdk/packages/llms/src/providers/routing/provider-options.test.ts b/sdk/packages/llms/src/providers/routing/provider-options.test.ts index c150fda7b4..04da70eb4b 100644 --- a/sdk/packages/llms/src/providers/routing/provider-options.test.ts +++ b/sdk/packages/llms/src/providers/routing/provider-options.test.ts @@ -593,6 +593,30 @@ describe("composeAiSdkProviderOptions: Anthropic thinking precedence", () => { }, ], }, + { + name: "Sonnet 5 uses adaptive thinking with medium effort", + request: { + providerId: "anthropic", + modelId: "claude-sonnet-5", + reasoning: { enabled: true, effort: "medium" }, + }, + context: { + family: "claude-sonnet", + reasoningOptions: effortOptions([ + "low", + "medium", + "high", + "xhigh", + "max", + ]), + }, + expect: [ + { + bucket: "anthropic", + has: { thinking: ADAPTIVE_THINKING, effort: "medium" }, + }, + ], + }, { name: "Sonnet 5 emits the explicit disabled thinking control", request: {