fix: centralize provider thinking profiles

This commit is contained in:
Peter Steinberger
2026-04-21 09:04:37 +01:00
parent 1cc2fc82ca
commit f1805ab54d
57 changed files with 718 additions and 572 deletions

View File

@@ -178,7 +178,7 @@ describe("llm-task tool (json-only)", () => {
it("throws on unsupported xhigh thinking level", async () => {
const tool = createLlmTaskTool(fakeApi());
await expect(tool.execute("id", { prompt: "x", thinking: "xhigh" })).rejects.toThrow(
/only supported/i,
/not supported/i,
);
});

View File

@@ -4,11 +4,10 @@ import { Type } from "@sinclair/typebox";
import Ajv from "ajv";
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
import {
formatXHighModelHint,
formatThinkingLevels,
isThinkingLevelSupported,
normalizeThinkLevel,
resolvePreferredOpenClawTmpDir,
resolveSupportedThinkingLevel,
supportsXHighThinking,
} from "../api.js";
import type { OpenClawPluginApi } from "../api.js";
@@ -145,15 +144,17 @@ export function createLlmTaskTool(api: OpenClawPluginApi) {
);
}
let resolvedThinkLevel = thinkLevel;
if (thinkLevel === "xhigh" && !supportsXHighThinking(provider, model)) {
throw new Error(`Thinking level "xhigh" is only supported for ${formatXHighModelHint()}.`);
}
if (thinkLevel === "max") {
resolvedThinkLevel = resolveSupportedThinkingLevel({
if (
thinkLevel &&
!isThinkingLevelSupported({
provider,
model,
level: thinkLevel,
});
})
) {
throw new Error(
`Thinking level "${thinkLevel}" is not supported for ${provider}/${model}. Use one of: ${formatThinkingLevels(provider, model)}.`,
);
}
const timeoutMs =