diff --git a/.changeset/silly-hornets-raise.md b/.changeset/silly-hornets-raise.md new file mode 100644 index 00000000..d0b29062 --- /dev/null +++ b/.changeset/silly-hornets-raise.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Fix Claude Code CLAUDE_CODE_MAX_OUTPUT_TOKENS diff --git a/src/integrations/claude-code/run.ts b/src/integrations/claude-code/run.ts index 7468b632..a8bebf27 100644 --- a/src/integrations/claude-code/run.ts +++ b/src/integrations/claude-code/run.ts @@ -182,6 +182,9 @@ const CLAUDE_CODE_TIMEOUT = 600000 // 10 minutes // https://github.com/sindresorhus/execa/blob/main/docs/api.md#optionsmaxbuffer const BUFFER_SIZE = 20_000_000 // 20 MB +// This is the limit imposed by the CLI +const CLAUDE_CODE_MAX_OUTPUT_TOKENS = "32000" + function runProcess( { systemPrompt, messages, path, modelId, thinkingBudgetTokens, shouldUseFile }: ClaudeCodeOptions, cwd: string, @@ -210,8 +213,7 @@ function runProcess( const env: NodeJS.ProcessEnv = { ...process.env, // Respect the user's environment variables but set defaults. - // The default is 32000. However, I've gotten larger responses. - CLAUDE_CODE_MAX_OUTPUT_TOKENS: process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS || "64000", + CLAUDE_CODE_MAX_OUTPUT_TOKENS: process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS || CLAUDE_CODE_MAX_OUTPUT_TOKENS, // Disable telemetry, auto-updater and error reporting. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC || "1", DISABLE_NON_ESSENTIAL_MODEL_CALLS: process.env.DISABLE_NON_ESSENTIAL_MODEL_CALLS || "1",