[BUG] Claude Code Web enters infinite loop when attempting to create large files (~2.5k lines)

Resolved 💬 3 comments Opened Nov 10, 2025 by anmaciel Closed Nov 14, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Title: Claude Code enters infinite loop when attempting to create large files (~2.5k lines)

Description:

I encountered an issue where Claude Code became stuck in an infinite loop and failed to complete the task, requiring me to abort the session.

Environment:

  • Tool: Claude Code (via web interface)
  • Context size at failure: ~111k tokens

Issue Details:

During a coding session, Claude Code attempted to create a large file (approximately 2,500 lines). Instead of executing the file creation, the system entered a loop where it would:

  1. Announce the intention to use the Write tool
  2. Fail to actually execute the tool
  3. Repeat the announcement indefinitely

Error Messages Observed:

remote: Proxy error: failed to send request to upstream… Service Unavailable… 502

Impact:

  • The session became unresponsive
  • Task completion was impossible
  • Manual session restart was required
  • Work progress was lost

Expected Behavior:
Claude Code should either:

  • Successfully create the large file, or
  • Provide a clear error message indicating file size limitations, or
  • Suggest splitting the file into smaller chunks

Actual Behavior:
The system entered an infinite loop of announcing file creation without execution, eventually resulting in proxy errors.

Reproducibility:
Unknown - occurred during large file creation with high token context usage.

---

Quer que eu ajuste algo no texto ou adicione mais informações técnicas?

What Should Happen?

The session became unresponsive
Task completion was impossible
Manual session restart was required
Work progress was lost

Error Messages/Logs

remote: Proxy error: failed to send request to upstream… Service Unavailable… 502

Steps to Reproduce

Reproducibility:

Unfortunately, I cannot provide a reproducible script as this issue occurred during an interactive Claude Code session. The error appears to be related to:

  1. Context window saturation (~111k tokens consumed)
  2. Large file generation (attempting to create ~2.5k line file)
  3. Backend infrastructure issues (proxy 502 errors)

The combination of these factors triggered the loop behavior, but isolating the exact cause for a reproduction script is not feasible since:

  • The issue involves Claude's internal tool execution mechanism
  • It depends on the current context state and token usage
  • The proxy errors suggest backend service availability issues

Suggestion for Investigation:

The Anthropic team might investigate:

  • Tool execution logs during high token usage scenarios
  • Timeout/retry logic when write operations fail
  • Proxy connection handling under heavy load
  • File size limits and their error handling mechanisms

I can provide the session transcript or additional context if that would help with internal debugging.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

Interface: Claude Web (claude.ai) Model: Claude Sonnet 4.5 Date: 2025-11-10

Platform

Other

Operating System

Windows

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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