Bug Description
maxTurns is never wired through to the SDK in src/entrypoints/run.ts, causing all runs to hit the SDK's default limit of 10 turns regardless of configuration.
Root Cause
src/entrypoints/run.ts line 268 calls runClaude() without passing maxTurns:
const claudeResult: ClaudeRunResult = await runClaude(promptConfig.path, {
claudeArgs: prepareResult.claudeArgs,
appendSystemPrompt: process.env.APPEND_SYSTEM_PROMPT,
model: process.env.ANTHROPIC_MODEL,
pathToClaudeCodeExecutable: process.env.INPUT_PATH_TO_CLAUDE_CODE_EXECUTABLE,
showFullOutput: process.env.INPUT_SHOW_FULL_OUTPUT,
// maxTurns is MISSING
});
The ClaudeOptions type in base-action/src/run-claude.ts supports maxTurns, and parse-sdk-options.ts correctly parses it:
maxTurns: options.maxTurns ? parseInt(options.maxTurns, 10) : undefined,
But since run.ts never provides it, sdkOptions.maxTurns is always undefined, and the SDK defaults to 10.
Notably, the base-action/src/index.ts entrypoint does pass it correctly:
maxTurns: process.env.INPUT_MAX_TURNS,
But the main action uses src/entrypoints/run.ts, not the base-action entrypoint.
Why --max-turns in claude_args doesn't work either
Passing --max-turns 50 via claude_args puts the value into extraArgs["max-turns"], which is passed through to the CLI subprocess. However, the SDK enforces its own turn counter from sdkOptions.maxTurns (which is undefined → 10), so the CLI never gets a chance to process more than 10 turns.
Error
Claude Code returned an error result: Reached maximum number of turns (10)
at readMessages (/home/runner/work/_actions/anthropics/claude-code-action/v1/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs:58:14849)
Suggested Fix
Add maxTurns to the runClaude() call in src/entrypoints/run.ts, and add a max_turns input to action.yml:
action.yml:
max_turns:
description: "Maximum number of conversation turns for the SDK"
required: false
src/entrypoints/run.ts:
const claudeResult: ClaudeRunResult = await runClaude(promptConfig.path, {
claudeArgs: prepareResult.claudeArgs,
appendSystemPrompt: process.env.APPEND_SYSTEM_PROMPT,
model: process.env.ANTHROPIC_MODEL,
maxTurns: process.env.INPUT_MAX_TURNS, // <-- add this
pathToClaudeCodeExecutable: process.env.INPUT_PATH_TO_CLAUDE_CODE_EXECUTABLE,
showFullOutput: process.env.INPUT_SHOW_FULL_OUTPUT,
});
And wire INPUT_MAX_TURNS in the run step env:
INPUT_MAX_TURNS: ${{ inputs.max_turns }}
Same issue likely applies to systemPrompt, allowedTools, disallowedTools, mcpConfig, and fallbackModel — all supported by ClaudeOptions but not passed from run.ts.
Reproduction
- Create a workflow using
anthropics/claude-code-action@v1
- Set
claude_args: "--max-turns 50" or max_turns: 50
- Trigger the action with a task requiring more than 10 turns
- Observe:
Reached maximum number of turns (10)
Environment
- Action version:
anthropics/claude-code-action@v1
- Claude Code version installed by action:
2.1.92
Bug Description
maxTurnsis never wired through to the SDK insrc/entrypoints/run.ts, causing all runs to hit the SDK's default limit of 10 turns regardless of configuration.Root Cause
src/entrypoints/run.tsline 268 callsrunClaude()without passingmaxTurns:The
ClaudeOptionstype inbase-action/src/run-claude.tssupportsmaxTurns, andparse-sdk-options.tscorrectly parses it:But since
run.tsnever provides it,sdkOptions.maxTurnsis alwaysundefined, and the SDK defaults to 10.Notably, the
base-action/src/index.tsentrypoint does pass it correctly:But the main action uses
src/entrypoints/run.ts, not the base-action entrypoint.Why
--max-turnsinclaude_argsdoesn't work eitherPassing
--max-turns 50viaclaude_argsputs the value intoextraArgs["max-turns"], which is passed through to the CLI subprocess. However, the SDK enforces its own turn counter fromsdkOptions.maxTurns(which isundefined→ 10), so the CLI never gets a chance to process more than 10 turns.Error
Suggested Fix
Add
maxTurnsto therunClaude()call insrc/entrypoints/run.ts, and add amax_turnsinput toaction.yml:action.yml:
src/entrypoints/run.ts:
And wire
INPUT_MAX_TURNSin the run step env:Same issue likely applies to
systemPrompt,allowedTools,disallowedTools,mcpConfig, andfallbackModel— all supported byClaudeOptionsbut not passed fromrun.ts.Reproduction
anthropics/claude-code-action@v1claude_args: "--max-turns 50"ormax_turns: 50Reached maximum number of turns (10)Environment
anthropics/claude-code-action@v12.1.92