From af7e3a4d206293da229b4e823c52ef2dac5f8a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Barreiro?= <52393857+BarreiroT@users.noreply.github.com> Date: Thu, 24 Jul 2025 18:24:30 +0200 Subject: [PATCH] Change the `CLAUDE_CODE_MAX_OUTPUT_TOKENS` (#5142) * Change the CLAUDE_CODE_MAX_OUTPUT_TOKENS * Add changeset * Add comment and variable to explain the changes --- .changeset/silly-hornets-raise.md | 5 +++++ src/integrations/claude-code/run.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/silly-hornets-raise.md 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",