anthropics / anthropics/claude-code-action

Claude Code terminates prematurely without completing all todos in the todo list

Open
#599 5 comments 0 reactions 0 assignees View on GitHub
bug p2 provider:1p
Dominant language
TypeScript
Stars
8.9k
Forks
2.1k
Avg merge
3d 9h
Merged PRs (30d)
10

Description

**Describe the bug**

Claude Code terminates prematurely without completing all todos in the todo list, violating explicit protocol instructions to continue until all tasks are marked complete. The agent stopped after completing only 5 of 10 todos, skipping critical validation steps (format checking, linting, type checking, and PR creation).

**To Reproduce**

Steps to reproduce the behavior:

1. Set up a GitHub Actions workflow using anthropics/claude-code-action@v1 with a structured prompt that includes explicit todo tracking requirements
2. Include a prompt with a multi-step protocol (10+ steps) that uses TodoWrite tool to track progress
3. Add explicit instructions stating "Update your progress tracker to Complete status" and "ALL commands must pass with no errors before proceeding"
4. Trigger the action (e.g., via pull request)
5. Observe that Claude Code exits after completing approximately 50% of todos, leaving remaining tasks incomplete

**Expected behavior**

Claude Code should continue executing until:
- All todos in the todo list are marked as completed
- The protocol explicitly states completion
- Or max-turns limit is reached with a clear indication that the work is incomplete

The agent should NOT terminate while todos remain in pending or in_progress state, especially when the prompt contains explicit instructions to complete all steps.

**Screenshots**

Log evidence showing incomplete execution:

# Initial state - 10 todos created
TodoWrite:
- Todo 1: status "in_progress"
- Todos 2-10: status "pending"

# Progress updates show only 5 completed
TodoWrite:
- Todos 1-5: status "completed"
- Todo 6: status "in_progress"
- Todos 7-10: status "pending"

# Execution terminates here
# Missing: Format check, Linting, Type checking, PR creation

**Workflow yml file**

```yaml
name: Sentry Bug Fixer
on:
pull_request:
types: [opened, synchronize]

jobs:
fix-sentry-bug:
runs-on: ubuntu-latest-8-cores
name: Certa Sentry Bug Bot
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Sentry Bug-fixing Protocol
uses: anthropics/claude-code-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
mode: agent
settings: |
{
"env": {
"MAX_THINKING_TOKENS": "20000",
"GH_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
"GITHUB_REPOSITORY": "${{ github.repository }}",
"BASH_DEFAULT_TIMEOUT_MS": "300000",
"BASH_MAX_TIMEOUT_MS": "300000"
}
}
direct_prompt: |
You are a senior frontend engineer tasked with fixing a critical production bug.

Your goal is to investigate, reproduce, fix, test, and prepare a pull request.
You must track your progress meticulously using the TodoWrite tool.

## PROGRESS TRACKING REQUIREMENTS
You must maintain a detailed progress tracker throughout the entire process.
Update this tracker after each major step.

## BUG FIX PROTOCOL (Non-negotiable steps)

**Step 1: Investigate the Failure**
- Retrieve complete Sentry data

**Step 2: Understand Before Coding**
- Write reproduction instructions

**Step 3: Implement Complete Fix**
- Create failing test
- Fix the root cause

**Step 4: Validate Everything Works**
- Run test suite

**Step 5: Code Quality Validation (MANDATORY)**
- Run format check
- Run linting
- Run type checking
- ALL commands must pass before proceeding

**Step 6: Create PR Description**
- Create comprehensive pr-desc.md file

**Step 7: Stage Changes ONLY**
- Stage all files
- Update progress tracker to Complete status

Begin your investigation now.
max_turns: 30
model: claude-sonnet-4-5-20250929
```

**API Provider**

[x] Anthropic First-Party API (default)
[ ] AWS Bedrock
[ ] GCP Vertex

**Additional context**
error reply
```
{
"type": "user",
"message": {
"role": "user",
"content": [
{
"type": "tool_result",
"content": "Command timed out after 1m 0s",
"is_error": true,
"tool_use_id": "toolu_01VeM3QohtTGSRhd4BAmNvb3"
}
]
},
```
Critical observations:

1. Turn count: The execution did NOT hit the max-turns limit (30 turns configured, ~10-15 turns used)
2. No errors: No exceptions or tool failures occurred that would justify premature termination
3. Clear instructions: The prompt explicitly stated to continue until "Complete status" and "ALL commands must pass"
4. Pattern: The agent consistently stops around 50-60% completion across multiple runs

Impact: This bug causes incomplete work in automated workflows, leaving code changes unvalidated (no linting/type checking) and PRs uncreated, requiring manual intervention to complete what should be automated tasks.

Expected fix: Claude Code should have internal checks to ensure:
- All todos marked in_progress or pending are addressed before termination
- The prompt's completion criteria are met
- Or provide explicit warnings when terminating with incomplete work

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.