diff --git a/src/agents/model-selection.ts b/src/agents/model-selection.ts index 7cdc52e641c..acc29a32bf9 100644 --- a/src/agents/model-selection.ts +++ b/src/agents/model-selection.ts @@ -1,4 +1,4 @@ -import { resolveThinkingDefaultForModel } from "../auto-reply/thinking.js"; +import { resolveThinkingDefaultForModel } from "../auto-reply/thinking.shared.js"; import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentModelFallbackValues, diff --git a/src/auto-reply/thinking.shared.ts b/src/auto-reply/thinking.shared.ts index bbde5b90ce5..7487928eac3 100644 --- a/src/auto-reply/thinking.shared.ts +++ b/src/auto-reply/thinking.shared.ts @@ -12,6 +12,8 @@ export type ThinkingCatalogEntry = { }; const BASE_THINKING_LEVELS: ThinkLevel[] = ["off", "minimal", "low", "medium", "high", "adaptive"]; +const ANTHROPIC_CLAUDE_46_MODEL_RE = /^claude-(?:opus|sonnet)-4(?:\.|-)6(?:$|[-.])/i; +const AMAZON_BEDROCK_CLAUDE_46_MODEL_RE = /claude-(?:opus|sonnet)-4(?:\.|-)6(?:$|[-.])/i; export function normalizeProviderId(provider?: string | null): string { if (!provider) { @@ -101,6 +103,14 @@ export function resolveThinkingDefaultForModel(params: { model: string; catalog?: ThinkingCatalogEntry[]; }): ThinkLevel { + const normalizedProvider = normalizeProviderId(params.provider); + const modelId = params.model.trim(); + if (normalizedProvider === "anthropic" && ANTHROPIC_CLAUDE_46_MODEL_RE.test(modelId)) { + return "adaptive"; + } + if (normalizedProvider === "amazon-bedrock" && AMAZON_BEDROCK_CLAUDE_46_MODEL_RE.test(modelId)) { + return "adaptive"; + } const candidate = params.catalog?.find( (entry) => entry.provider === params.provider && entry.id === params.model, ); diff --git a/src/gateway/gateway-cli-backend.live.test.ts b/src/gateway/gateway-cli-backend.live.test.ts index b0426c59175..d0d313cc455 100644 --- a/src/gateway/gateway-cli-backend.live.test.ts +++ b/src/gateway/gateway-cli-backend.live.test.ts @@ -4,7 +4,7 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; import { parseModelRef } from "../agents/model-selection.js"; -import { loadConfig } from "../config/config.js"; +import { clearRuntimeConfigSnapshot, loadConfig } from "../config/config.js"; import { isTruthyEnvValue } from "../infra/env.js"; import { getFreePortBlockWithPermissionFallback } from "../test-utils/ports.js"; import { GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js"; @@ -166,6 +166,7 @@ async function connectClient(params: { url: string; token: string }) { describeLive("gateway live (cli backend)", () => { it("runs the agent pipeline against the local CLI backend", async () => { + clearRuntimeConfigSnapshot(); const previous = { configPath: process.env.OPENCLAW_CONFIG_PATH, token: process.env.OPENCLAW_GATEWAY_TOKEN, @@ -384,6 +385,7 @@ describeLive("gateway live (cli backend)", () => { } } } finally { + clearRuntimeConfigSnapshot(); client.stop(); await server.close(); await fs.rm(tempDir, { recursive: true, force: true }); diff --git a/src/plugin-sdk/index.ts b/src/plugin-sdk/index.ts index 07b51661d2d..1e78ee1c7e2 100644 --- a/src/plugin-sdk/index.ts +++ b/src/plugin-sdk/index.ts @@ -797,21 +797,21 @@ export { SELF_HOSTED_DEFAULT_CONTEXT_WINDOW, SELF_HOSTED_DEFAULT_COST, SELF_HOSTED_DEFAULT_MAX_TOKENS, -} from "../commands/self-hosted-provider-setup.js"; +} from "../commands/self-hosted-provider-setup.ts"; export { OLLAMA_DEFAULT_BASE_URL, OLLAMA_DEFAULT_MODEL, configureOllamaNonInteractive, ensureOllamaModelPulled, promptAndConfigureOllama, -} from "../commands/ollama-setup.js"; +} from "../commands/ollama-setup.ts"; export { VLLM_DEFAULT_BASE_URL, VLLM_DEFAULT_CONTEXT_WINDOW, VLLM_DEFAULT_COST, VLLM_DEFAULT_MAX_TOKENS, promptAndConfigureVllm, -} from "../commands/vllm-setup.js"; +} from "../commands/vllm-setup.ts"; export { buildOllamaProvider, buildSglangProvider, diff --git a/src/plugin-sdk/ollama-setup.ts b/src/plugin-sdk/ollama-setup.ts index 5b6fd732774..fa8c9032dda 100644 --- a/src/plugin-sdk/ollama-setup.ts +++ b/src/plugin-sdk/ollama-setup.ts @@ -12,6 +12,6 @@ export { configureOllamaNonInteractive, ensureOllamaModelPulled, promptAndConfigureOllama, -} from "../commands/ollama-setup.js"; +} from "../commands/ollama-setup.ts"; export { buildOllamaProvider } from "../agents/models-config.providers.discovery.js"; diff --git a/src/plugin-sdk/provider-setup.ts b/src/plugin-sdk/provider-setup.ts index 6569c36a324..4489c8ae34d 100644 --- a/src/plugin-sdk/provider-setup.ts +++ b/src/plugin-sdk/provider-setup.ts @@ -15,21 +15,21 @@ export { SELF_HOSTED_DEFAULT_CONTEXT_WINDOW, SELF_HOSTED_DEFAULT_COST, SELF_HOSTED_DEFAULT_MAX_TOKENS, -} from "../commands/self-hosted-provider-setup.js"; +} from "../commands/self-hosted-provider-setup.ts"; export { OLLAMA_DEFAULT_BASE_URL, OLLAMA_DEFAULT_MODEL, configureOllamaNonInteractive, ensureOllamaModelPulled, promptAndConfigureOllama, -} from "../commands/ollama-setup.js"; +} from "../commands/ollama-setup.ts"; export { VLLM_DEFAULT_BASE_URL, VLLM_DEFAULT_CONTEXT_WINDOW, VLLM_DEFAULT_COST, VLLM_DEFAULT_MAX_TOKENS, promptAndConfigureVllm, -} from "../commands/vllm-setup.js"; +} from "../commands/vllm-setup.ts"; export { buildOllamaProvider, buildSglangProvider, diff --git a/src/plugin-sdk/self-hosted-provider-setup.ts b/src/plugin-sdk/self-hosted-provider-setup.ts index 950bbbb953e..60be2852a2d 100644 --- a/src/plugin-sdk/self-hosted-provider-setup.ts +++ b/src/plugin-sdk/self-hosted-provider-setup.ts @@ -15,7 +15,7 @@ export { SELF_HOSTED_DEFAULT_CONTEXT_WINDOW, SELF_HOSTED_DEFAULT_COST, SELF_HOSTED_DEFAULT_MAX_TOKENS, -} from "../commands/self-hosted-provider-setup.js"; +} from "../commands/self-hosted-provider-setup.ts"; export { buildSglangProvider,