[BUG] Read tool can inject huge partial file output into context, causing repeated ECONNRESET on follow-up turns

Open 💬 3 comments Opened Jun 13, 2026 by RainyBlossom

Preflight Checklist

  • [x] I have searched existing issues for similar reports. Related but not identical: #51164, #20223, #18653, #27560.
  • [x] This is a single bug report.
  • [x] I am using the latest version of Claude Code available to me.
  • [x] This report does not contain private source code or secrets.

What's Wrong?

Claude Code can use the Read tool on a large file and inject a very large partial file view into the conversation context. In my case, a normal interactive coding session became effectively unusable after Claude read a large CSS file.

The returned tool result included this warning:

[Truncated: PARTIAL view — showing lines 1-2171 of 6374 total (62374 tokens, cap 25000). Call Read with offset=2172 limit=2171 for the next page, or Grep to find a specific section. Do NOT answer from this page alone if the answer may be further in the file.]

That large tool_result was then persisted into the session JSONL and included in subsequent follow-up turns. After that, simple follow-up prompts like continue repeatedly failed with:

API Error: Unable to connect to API (ECONNRESET)
The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()

This led me to spend a long time debugging VPN/proxy/network settings. However, a fresh minimal Claude Code request in the same terminal, same account, same proxy, same machine, and same CLI environment succeeded immediately:

claude -p "Reply OK" --model sonnet --effort low --no-session-persistence --output-format json
# completed in ~2.3s with result: OK

So this does not look like a general network outage or auth failure. It looks like a session/context failure mode triggered by a very large Read result being retained in the conversation.

What Should Happen?

Claude Code should protect users from this class of self-inflicted context bloat.

Possible mitigations:

  1. Read should not inject tens of thousands of tokens into context by default for large files, especially when the result is already marked partial/truncated.
  2. For files above a size/line/token threshold, Read should either require an explicit small offset/limit, return only a structural summary plus instructions to use Grep/line ranges, or ask the model to narrow the read first.
  3. If a tool result exceeds a safe threshold, Claude Code should surface a clear warning to the user and/or auto-compact before the next API turn.
  4. If the same follow-up turn repeatedly fails with ECONNRESET after a large tool result, Claude Code should suggest context reduction/compaction/new session instead of spending all retries on the same oversized request.
  5. The context display / auto-compact heuristics should account for large pending tool results before the next turn is sent.

The user should not need to know that a prior tool call inserted a huge partial file into hidden context. From the user's point of view, they simply typed a normal follow-up and Claude Code started failing.

Error Messages / Logs

Relevant redacted JSONL excerpt:

{
  "type": "user",
  "message": {
    "role": "user",
    "content": [
      {
        "tool_use_id": "toolu_...",
        "type": "tool_result",
        "content": "<system-reminder>[Truncated: PARTIAL view — showing lines 1-2171 of 6374 total (62374 tokens, cap 25000). Call Read with offset=2172 limit=2171 for the next page, or Grep to find a specific section. Do NOT answer from this page alone if the answer may be further in the file.]</system-reminder>\\n\\n1\\t@import \\\"tailwindcss\\\";\\n..."
      }
    ]
  },
  "entrypoint": "cli",
  "version": "2.1.177"
}

Subsequent follow-up failures:

{
  "type": "system",
  "subtype": "api_error",
  "level": "error",
  "error": {
    "message": "Connection error.",
    "formatted": "Unable to connect to API (ECONNRESET)",
    "connection": {
      "code": "ECONNRESET",
      "message": "The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()",
      "isSSLError": false
    },
    "isNetworkDown": false,
    "rateLimits": null
  },
  "retryAttempt": 1,
  "maxRetries": 12,
  "entrypoint": "cli",
  "version": "2.1.177"
}

The next retries continued with the same ECONNRESET pattern.

Steps to Reproduce

  1. Start an interactive Claude Code session in a frontend project.
  2. Ask Claude to inspect or modify a page that has a large CSS file nearby.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗