mirror of
https://github.com/cline/cline.git
synced 2026-10-24 02:02:27 +08:00
Fix sonnet thinking options for computer user.
This commit is contained in:
committed by
Dominic Cooney
parent
993c18094b
commit
a7678feaab
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user