mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 19:40: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:
@@ -33,6 +33,12 @@ describe("normalizeThinkLevel", () => {
|
||||
it("accepts on as low", () => {
|
||||
expect(normalizeThinkLevel("on")).toBe("low");
|
||||
});
|
||||
|
||||
it("accepts adaptive and auto aliases", () => {
|
||||
expect(normalizeThinkLevel("adaptive")).toBe("adaptive");
|
||||
expect(normalizeThinkLevel("auto")).toBe("adaptive");
|
||||
expect(normalizeThinkLevel("Adaptive")).toBe("adaptive");
|
||||
});
|
||||
});
|
||||
|
||||
describe("listThinkingLevels", () => {
|
||||
@@ -54,6 +60,11 @@ describe("listThinkingLevels", () => {
|
||||
it("excludes xhigh for non-codex models", () => {
|
||||
expect(listThinkingLevels(undefined, "gpt-4.1-mini")).not.toContain("xhigh");
|
||||
});
|
||||
|
||||
it("always includes adaptive", () => {
|
||||
expect(listThinkingLevels(undefined, "gpt-4.1-mini")).toContain("adaptive");
|
||||
expect(listThinkingLevels("anthropic", "claude-opus-4-6")).toContain("adaptive");
|
||||
});
|
||||
});
|
||||
|
||||
describe("listThinkingLevelLabels", () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type ThinkLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
||||
export type ThinkLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "adaptive";
|
||||
export type VerboseLevel = "off" | "on" | "full";
|
||||
export type NoticeLevel = "off" | "on" | "full";
|
||||
export type ElevatedLevel = "off" | "on" | "ask" | "full";
|
||||
@@ -45,6 +45,9 @@ export function normalizeThinkLevel(raw?: string | null): ThinkLevel | undefined
|
||||
}
|
||||
const key = raw.trim().toLowerCase();
|
||||
const collapsed = key.replace(/[\s_-]+/g, "");
|
||||
if (collapsed === "adaptive" || collapsed === "auto") {
|
||||
return "adaptive";
|
||||
}
|
||||
if (collapsed === "xhigh" || collapsed === "extrahigh") {
|
||||
return "xhigh";
|
||||
}
|
||||
@@ -91,6 +94,7 @@ export function listThinkingLevels(provider?: string | null, model?: string | nu
|
||||
if (supportsXHighThinking(provider, model)) {
|
||||
levels.push("xhigh");
|
||||
}
|
||||
levels.push("adaptive");
|
||||
return levels;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user