mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
feat: add max_turns parameter support (#149)
* feat: add max_turns parameter support - Add max_turns input to action.yml with proper description - Pass max_turns parameter through to claude-code-base-action - Update README with documentation and examples for max_turns usage - Add comprehensive tests to verify max_turns configuration - Add yaml dependency for test parsing Closes #148 Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com> * chore: remove max-turns test and yaml dependency Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com> * chore: revert package.json and bun.lock changes Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com> * Update action.yml * prettier --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com>
This commit is contained in:
21
README.md
21
README.md
@@ -70,6 +70,8 @@ jobs:
|
||||
# NODE_ENV: test
|
||||
# DEBUG: true
|
||||
# API_URL: https://api.example.com
|
||||
# Optional: limit the number of conversation turns
|
||||
# max_turns: "5"
|
||||
```
|
||||
|
||||
## Inputs
|
||||
@@ -78,6 +80,7 @@ jobs:
|
||||
| --------------------- | -------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
|
||||
| `anthropic_api_key` | Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No\* | - |
|
||||
| `direct_prompt` | Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows) | No | - |
|
||||
| `max_turns` | Maximum number of conversation turns Claude can take (limits back-and-forth exchanges) | No | - |
|
||||
| `timeout_minutes` | Timeout in minutes for execution | No | `30` |
|
||||
| `github_token` | GitHub token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - |
|
||||
| `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - |
|
||||
@@ -311,6 +314,24 @@ You can pass custom environment variables to Claude Code execution using the `cl
|
||||
|
||||
The `claude_env` input accepts YAML format where each line defines a key-value pair. These environment variables will be available to Claude Code during execution, allowing it to run tests, build processes, or other commands that depend on specific environment configurations.
|
||||
|
||||
### Limiting Conversation Turns
|
||||
|
||||
You can use the `max_turns` parameter to limit the number of back-and-forth exchanges Claude can have during task execution. This is useful for:
|
||||
|
||||
- Controlling costs by preventing runaway conversations
|
||||
- Setting time boundaries for automated workflows
|
||||
- Ensuring predictable behavior in CI/CD pipelines
|
||||
|
||||
```yaml
|
||||
- uses: anthropics/claude-code-action@beta
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
max_turns: "5" # Limit to 5 conversation turns
|
||||
# ... other inputs
|
||||
```
|
||||
|
||||
When the turn limit is reached, Claude will stop execution gracefully. Choose a value that gives Claude enough turns to complete typical tasks while preventing excessive usage.
|
||||
|
||||
### Custom Tools
|
||||
|
||||
By default, Claude only has access to:
|
||||
|
||||
@@ -62,6 +62,10 @@ inputs:
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
max_turns:
|
||||
description: "Maximum number of conversation turns"
|
||||
required: false
|
||||
default: ""
|
||||
timeout_minutes:
|
||||
description: "Timeout in minutes for execution"
|
||||
required: false
|
||||
@@ -111,6 +115,7 @@ runs:
|
||||
allowed_tools: ${{ env.ALLOWED_TOOLS }}
|
||||
disallowed_tools: ${{ env.DISALLOWED_TOOLS }}
|
||||
timeout_minutes: ${{ inputs.timeout_minutes }}
|
||||
max_turns: ${{ inputs.max_turns }}
|
||||
model: ${{ inputs.model || inputs.anthropic_model }}
|
||||
mcp_config: ${{ steps.prepare.outputs.mcp_config }}
|
||||
use_bedrock: ${{ inputs.use_bedrock }}
|
||||
|
||||
Reference in New Issue
Block a user