feat: Introduce Thinking Budget customization for Claude Code (#4618)
This commit is contained in:
1 parent
2af151e736
commit
72029fe205
5 files changed
+21
-3
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"claude-dev": patch
|
||||
---
|
||||
|
||||
feat: Introduce Thinking Budget customization for Claude Code
|
||||
@@ -27,6 +27,7 @@ export class ClaudeCodeHandler implements ApiHandler {
|
||||
messages: filteredMessages,
|
||||
path: this.options.claudeCodePath,
|
||||
modelId: this.getModel().id,
|
||||
thinkingBudgetTokens: this.options.thinkingBudgetTokens,
|
||||
})
|
||||
|
||||
// Usage is included with assistant messages,
|
||||
|
||||
@@ -11,6 +11,7 @@ type ClaudeCodeOptions = {
|
||||
messages: Anthropic.Messages.MessageParam[]
|
||||
path?: string
|
||||
modelId?: string
|
||||
thinkingBudgetTokens?: number
|
||||
}
|
||||
|
||||
type ProcessState = {
|
||||
@@ -107,7 +108,7 @@ const claudeCodeTools = [
|
||||
|
||||
const CLAUDE_CODE_TIMEOUT = 600000 // 10 minutes
|
||||
|
||||
function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions) {
|
||||
function runProcess({ systemPrompt, messages, path, modelId, thinkingBudgetTokens }: ClaudeCodeOptions) {
|
||||
const claudePath = path || "claude"
|
||||
|
||||
const args = [
|
||||
@@ -132,6 +133,7 @@ function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions
|
||||
...process.env,
|
||||
// The default is 32000. However, I've gotten larger responses, so we increase it unless the user specified it.
|
||||
CLAUDE_CODE_MAX_OUTPUT_TOKENS: process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS || "64000",
|
||||
MAX_THINKING_TOKENS: (thinkingBudgetTokens || 0).toString(),
|
||||
}
|
||||
|
||||
// We don't want to consume the user's ANTHROPIC_API_KEY,
|
||||
|
||||
@@ -9,7 +9,11 @@ import { useExtensionState } from "@/context/ExtensionStateContext"
|
||||
import { useApiConfigurationHandlers } from "../utils/useApiConfigurationHandlers"
|
||||
|
||||
// Anthropic models that support thinking/reasoning mode
|
||||
const SUPPORTED_THINKING_MODELS = ["claude-3-7-sonnet-20250219", "claude-sonnet-4-20250514", "claude-opus-4-20250514"]
|
||||
export const SUPPORTED_ANTHROPIC_THINKING_MODELS = [
|
||||
"claude-3-7-sonnet-20250219",
|
||||
"claude-sonnet-4-20250514",
|
||||
"claude-opus-4-20250514",
|
||||
]
|
||||
|
||||
/**
|
||||
* Props for the AnthropicProvider component
|
||||
@@ -54,7 +58,7 @@ export const AnthropicProvider = ({ showModelOptions, isPopup }: AnthropicProvid
|
||||
label="Model"
|
||||
/>
|
||||
|
||||
{SUPPORTED_THINKING_MODELS.includes(selectedModelId) && (
|
||||
{SUPPORTED_ANTHROPIC_THINKING_MODELS.includes(selectedModelId) && (
|
||||
<ThinkingBudgetSlider maxBudget={selectedModelInfo.thinkingConfig?.maxBudget} />
|
||||
)}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import { ModelInfoView } from "../common/ModelInfoView"
|
||||
import { normalizeApiConfiguration } from "../utils/providerUtils"
|
||||
import { useApiConfigurationHandlers } from "../utils/useApiConfigurationHandlers"
|
||||
import { useExtensionState } from "@/context/ExtensionStateContext"
|
||||
import { SUPPORTED_ANTHROPIC_THINKING_MODELS } from "./AnthropicProvider"
|
||||
import ThinkingBudgetSlider from "../ThinkingBudgetSlider"
|
||||
|
||||
/**
|
||||
* Props for the ClaudeCodeProvider component
|
||||
@@ -53,6 +55,10 @@ export const ClaudeCodeProvider = ({ showModelOptions, isPopup }: ClaudeCodeProv
|
||||
label="Model"
|
||||
/>
|
||||
|
||||
{SUPPORTED_ANTHROPIC_THINKING_MODELS.includes(selectedModelId) && (
|
||||
<ThinkingBudgetSlider maxBudget={selectedModelInfo.thinkingConfig?.maxBudget} />
|
||||
)}
|
||||
|
||||
<ModelInfoView selectedModelId={selectedModelId} modelInfo={selectedModelInfo} isPopup={isPopup} />
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user