mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 22:20:21 +00:00
feat(agents): support thinkingDefault: "adaptive" for Anthropic models (#31227)
* feat(agents): support `thinkingDefault: "adaptive"` for Anthropic models Anthropic's Opus 4.6 and Sonnet 4.6 support adaptive thinking where the model dynamically decides when and how much to think. This is now Anthropic's recommended mode and `budget_tokens` is deprecated on these models. Add "adaptive" as a valid thinking level: - Config: `agents.defaults.thinkingDefault: "adaptive"` - CLI: `/think adaptive` or `/think auto` - Pi SDK mapping: "adaptive" → "medium" effort at the pi-agent-core layer, which the Anthropic provider translates to `thinking.type: "adaptive"` with `output_config.effort: "medium"` - Provider fallbacks: OpenRouter and Google map "adaptive" to their respective "medium" equivalents Closes #30880 Made-with: Cursor * style(changelog): format changelog with oxfmt * test(types): fix strict typing in runtime/plugin-context tests --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@ export type ModelRef = {
|
||||
model: string;
|
||||
};
|
||||
|
||||
export type ThinkLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
||||
export type ThinkLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "adaptive";
|
||||
|
||||
export type ModelAliasIndex = {
|
||||
byAlias: Map<string, { alias: string; ref: ModelRef }>;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const resolvePluginToolsMock = vi.fn(() => []);
|
||||
const resolvePluginToolsMock = vi.fn((params?: unknown) => {
|
||||
void params;
|
||||
return [];
|
||||
});
|
||||
|
||||
vi.mock("../plugins/tools.js", () => ({
|
||||
resolvePluginTools: (params: unknown) => resolvePluginToolsMock(params),
|
||||
|
||||
@@ -518,6 +518,9 @@ function mapThinkingLevelToOpenRouterReasoningEffort(
|
||||
if (thinkingLevel === "off") {
|
||||
return "none";
|
||||
}
|
||||
if (thinkingLevel === "adaptive") {
|
||||
return "medium";
|
||||
}
|
||||
return thinkingLevel;
|
||||
}
|
||||
|
||||
@@ -631,6 +634,7 @@ function mapThinkLevelToGoogleThinkingLevel(
|
||||
case "low":
|
||||
return "LOW";
|
||||
case "medium":
|
||||
case "adaptive":
|
||||
return "MEDIUM";
|
||||
case "high":
|
||||
case "xhigh":
|
||||
|
||||
@@ -6,6 +6,13 @@ export function mapThinkingLevel(level?: ThinkLevel): ThinkingLevel {
|
||||
if (!level) {
|
||||
return "off";
|
||||
}
|
||||
// "adaptive" maps to "medium" at the pi-agent-core layer. The Pi SDK
|
||||
// provider then translates this to `thinking.type: "adaptive"` with
|
||||
// `output_config.effort: "medium"` for models that support it (Opus 4.6,
|
||||
// Sonnet 4.6).
|
||||
if (level === "adaptive") {
|
||||
return "medium";
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user