claude-code - 💡(How to fix) Fix [BUG] Edit/Write "File has not been read yet" error causes ~17% of cases to halt the agent turn, requiring user "continue" [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#60650Fetched 2026-05-20 03:53:00
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×5commented ×1subscribed ×1

When Edit or Write returns File has not been read yet. Read it first before writing to it., the agent's turn ends ~17% of the time without recovery, requiring a human "continue" to resume. The remaining ~83% of cases self-recover (Read + retry on the next assistant turn).

Error Message

After the error tool_result, the harness injects a batch of metadata entries

  • The error itself is correct — the harness is right to require a Read. The bug is in turn-continuation: a recoverable error should not end Edit/Write transparently before surfacing the error to the model.
  1. Model-side: ensure the recoverable error does not end the assistant

Root Cause

  • Long-running autonomous workflows (agent fleets, multi-step refactors, ralph/autopilot loops) silently stall. The user only discovers it on return.
  • The error itself is correct — the harness is right to require a Read. The bug is in turn-continuation: a recoverable error should not end the turn.

Code Example

[assistant] Edit → packages/api/src/app.ts
[tool_result is_error=true] File has not been read yet. Read it first before writing to it.
[attachment] [attachment] [attachment] [system] [system] [last-prompt]
[permission-mode] [pr-link] [file-history-snapshot]
[user] "continue"
[user] "stuck?"
[assistant] "No — just hit a harness rule that requires a Read before Edit.
             Reading then editing:"
[assistant] tool_use: Read → packages/api/src/app.ts
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues
  • This is a single bug report
  • I am using the latest version of Claude Code

Related

Reopens the behavior pattern from #57558 (closed). The reporter described an agent halting on "File must be read first" until a human typed "continue". Filing this with empirical data from our own session logs to support that the behavior is reproducible and not isolated.

Summary

When Edit or Write returns File has not been read yet. Read it first before writing to it., the agent's turn ends ~17% of the time without recovery, requiring a human "continue" to resume. The remaining ~83% of cases self-recover (Read + retry on the next assistant turn).

Halt Mechanism (consistent across all confirmed halts)

After the error tool_result, the harness injects a batch of metadata entries (attachment, system, file-history-snapshot, permission-mode, last-prompt, pr-link, queue-operation). The assistant turn ends during or before this flush — no new assistant turn is queued. The CLI shows Cogitated for Xm Ys and waits for the user. The user has to type something to re-prompt the model.

Verbatim Excerpt (anonymized)

[assistant] Edit → packages/api/src/app.ts
[tool_result is_error=true] File has not been read yet. Read it first before writing to it.
[attachment] [attachment] [attachment] [system] [system] [last-prompt]
[permission-mode] [pr-link] [file-history-snapshot]
[user] "continue"
[user] "stuck?"
[assistant] "No — just hit a harness rule that requires a Read before Edit.
             Reading then editing:"
[assistant] tool_use: Read → packages/api/src/app.ts

The model clearly knows how to recover when re-prompted — the issue is that the turn ends before it does so.

Why This Matters

  • Long-running autonomous workflows (agent fleets, multi-step refactors, ralph/autopilot loops) silently stall. The user only discovers it on return.
  • The error itself is correct — the harness is right to require a Read. The bug is in turn-continuation: a recoverable error should not end the turn.

Reproduction Conditions

Most likely after:

  • Long sessions where the file was read in a turn that has since been context-compacted.
  • Subagent hand-offs where the parent's read-state didn't transfer.
  • Files renamed/moved during the session (the Read at the old path no longer satisfies the harness for the new path).

Suggested Fixes (any one)

  1. Harness-side: auto-issue a Read on the file path and retry the Edit/Write transparently before surfacing the error to the model.
  2. Harness-side: persist "file has been read" state across context compaction and propagate it to subagents.
  3. Model-side: ensure the recoverable error does not end the assistant turn — the model should always continue with a Read and retry.

Environment

  • Claude Code: 2.1.144
  • Model: Opus 4.7 via Bedrock (global.anthropic.claude-opus-4-7[1m]); behavior also seen on Sonnet 4.6 via Bedrock
  • Platform: macOS 25.4.0, zsh
  • Provider: AWS Bedrock (CLAUDE_CODE_USE_BEDROCK=1, region us-east-1)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Edit/Write "File has not been read yet" error causes ~17% of cases to halt the agent turn, requiring user "continue" [1 comments, 2 participants]