[MODEL] Model repeatedly submits incorrect heredoc despite acknowledging the error
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Claude ignored my instructions or configuration
What You Asked Claude to Do
During a system crontab editing session, I asked Claude Code to update three cron job lines to replace --cwd /Users/{userName}/{folderName} with cd /Users/{userName}/{folderName} &&.
Claude provided a correct preview of the proposed changes, and asked me to confirm, which I did.
The root prompt that triggered the repeated failure was approving this proposed crontab (which Claude had just printed correctly in text):
```
7 9 1-5 cd /Users/{userName}/{folderName} && /Users/{userName}/.local/bin/claude -p "/process-inbox" >> /Users/{userName}/{folderName}/.claude/cron.log 2>&1
7 13 1-5 cd /Users/{userName}/{folderName} && /Users/{userName}/.local/bin/claude -p "/process-inbox" >> /Users/{userName}/{folderName}/.claude/cron.log 2>&1
7 17 1-5 cd /Users/{userName}/{folderName} && /Users/{userName}/.local/bin/claude -p "/process-inbox" >> /Users/{userName}/{folderName}/.claude/cron.log 2>&1
### What Claude Actually Did
The tool call wrote an incorrect version repeatedly, forcing the user to manually make the change themselves.
1. Claude correctly identified the required change and even printed the correct version in plain text — but then submitted the wrong version (missing the `cd` on the first cron job line) in the actual tool call, multiple times in a row.
2. Each time I pointed out the error, Claude acknowledged it, restated the correct version in text, and then made the same mistake again in the next tool call. This happened at least 4-5 times across the session.
3. The specific failure: the first cron line consistently came out without the `cd /Users/{userName}/{folderName} && prefix`, while the other lines in the same heredoc were correct. Claude was clearly pattern-matching from a prior (incorrect) version of the line rather than using the corrected version it had just stated.
### Expected Behavior
When a correction is acknowledged and restated, the next tool call should reflect that correction.
### Files Affected
```shell
macOS crontab
Permission Mode
Accept Edits was OFF (manual approval required)
Can You Reproduce This?
Haven't tried to reproduce
Steps to Reproduce
_No response_
Claude Model
Sonnet
Relevant Conversation
Turn 1 — Claude proposes the correct fix in text, then submits wrong heredoc:
▎ "The fix is to replace --cwd /path with a cd in the cron command."
Then submitted:
7 9 * * 1-5 /Users/{userName}/.local/bin/claude -p "/process-inbox" >> ...
(missing cd /Users/{userName}/{folderName} &&)
---
Turn 2 — User: "that's still wrong." Claude acknowledges:
▎ "I made an error in that — the first process-inbox job lost its cd. Let me fix and verify:"
Then submitted the same incorrect line again.
---
Turn 3 — User: "and still wrong." Claude acknowledges again:
▎ "You're right — the 9:07 job still doesn't have the cd. Let me write it correctly:"
Then submitted the same incorrect line a third time.
---
Turn 4 — User: "I give up. How can I do this myself?" Claude explains:
▎ "I keep making the same mistake. Here's how to fix it yourself: Run crontab -e..."
---
Turn 5 — After user manually fixed it, Claude suggested to add --dangerously-skip-permissions to the inbox jobs. When asked to proceeed, Claude responded:
▎ "The 9:07 job is missing its cd again — same mistake as before. Let me fix it properly:"
Then submitted the same incorrect line again. User rejected it and asked:
User: "not this again. Explain to me why you constantly omit the 'cd' command even though you KNOW it is required and keep telling me that you forgot it"
Claude's response: "Honestly, I don't have a good explanation. I know the rule, I can see the error in my output, and yet I keep submitting the wrong version. It's a failure of self-checking before executing — I'm generating the heredoc from a template in context and the 9:07 line keeps coming out wrong without me catching it before submission."
Impact
Medium - Extra work to undo changes
Claude Code Version
2.1.175 (Claude Code)
Platform
Anthropic API
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗