mirror of
https://github.com/cline/cline.git
synced 2026-09-17 17:45:33 +08:00
fix(vscode): forward OCA reasoning effort to SDK sessions (#11739)
This commit is contained in:
@@ -438,6 +438,40 @@ describe("buildSessionConfig", () => {
|
||||
expect((config as any).maxTokensPerTurn).toBe(4_096)
|
||||
})
|
||||
|
||||
it("passes OCA reasoning effort from legacy mode settings to SDK sessions", async () => {
|
||||
mocks.stateManager.getApiConfiguration.mockReturnValue({
|
||||
actModeApiProvider: "oca",
|
||||
actModeOcaModelId: "oca-reasoner",
|
||||
ocaApiKey: "oca-key",
|
||||
actModeOcaReasoningEffort: " HIGH ",
|
||||
} as any)
|
||||
|
||||
const config = await buildSessionConfig({ cwd: "/tmp/workspace" })
|
||||
|
||||
expect(config.providerId).toBe("oca")
|
||||
expect(config.modelId).toBe("oca-reasoner")
|
||||
expect(config.thinking).toBe(true)
|
||||
expect(config.reasoningEffort).toBe("high")
|
||||
})
|
||||
|
||||
it("lets legacy OCA none override stale provider reasoning settings", async () => {
|
||||
mocks.providerSettingsManager.getProviderSettings.mockReturnValue({
|
||||
provider: "oca",
|
||||
reasoning: { enabled: true, effort: "medium" },
|
||||
} as any)
|
||||
mocks.stateManager.getApiConfiguration.mockReturnValue({
|
||||
actModeApiProvider: "oca",
|
||||
actModeOcaModelId: "oca-reasoner",
|
||||
ocaApiKey: "oca-key",
|
||||
actModeOcaReasoningEffort: "none",
|
||||
} as any)
|
||||
|
||||
const config = await buildSessionConfig({ cwd: "/tmp/workspace" })
|
||||
|
||||
expect(config.thinking).toBe(false)
|
||||
expect(config.reasoningEffort).toBeUndefined()
|
||||
})
|
||||
|
||||
it("builds structured SAP AI Core config from legacy ApiConfiguration fields", async () => {
|
||||
mocks.stateManager.getApiConfiguration.mockReturnValue({
|
||||
actModeApiProvider: "sapaicore",
|
||||
|
||||
@@ -182,6 +182,20 @@ function resolveProviderReasoningConfig(providerId: string): SessionReasoningCon
|
||||
}
|
||||
}
|
||||
|
||||
function resolveOcaReasoningConfig(mode: Mode, apiConfig: ApiConfiguration | undefined): SessionReasoningConfig | undefined {
|
||||
const rawEffort = mode === "plan" ? apiConfig?.planModeOcaReasoningEffort : apiConfig?.actModeOcaReasoningEffort
|
||||
const effort = rawEffort?.trim().toLowerCase()
|
||||
if (!effort) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
if (effort === "none") {
|
||||
return { thinking: false }
|
||||
}
|
||||
|
||||
return isReasoningEffort(effort) ? { thinking: true, reasoningEffort: effort } : undefined
|
||||
}
|
||||
|
||||
function resolveOpenAiCompatibleMaxTokens(config: ApiConfiguration | undefined, mode: Mode): number | undefined {
|
||||
const modelInfo = mode === "plan" ? config?.planModeOpenAiModelInfo : config?.actModeOpenAiModelInfo
|
||||
const maxTokens = modelInfo?.maxTokens
|
||||
@@ -587,7 +601,10 @@ export async function buildSessionConfig(input: SessionConfigInput): Promise<Cor
|
||||
}
|
||||
apiKey = apiKey ?? ""
|
||||
const maxTokensPerTurn = providerId === "openai" ? resolveOpenAiCompatibleMaxTokens(apiConfig, mode) : undefined
|
||||
const reasoningConfig = resolveProviderReasoningConfig(providerId)
|
||||
const reasoningConfig =
|
||||
providerId === "oca"
|
||||
? (resolveOcaReasoningConfig(mode, apiConfig) ?? resolveProviderReasoningConfig(providerId))
|
||||
: resolveProviderReasoningConfig(providerId)
|
||||
|
||||
// Build the system prompt using the shared prompt builder. Core still
|
||||
// expects callers to provide a concrete systemPrompt, but the prompt builder
|
||||
|
||||
Reference in New Issue
Block a user