Repository navigation
Description
Description
Claude Code CLI becomes unresponsive with 100% CPU usage when using the Task tool to spawn sub-agents. The freeze occurs during JSON serialization of the response object, likely when processing large/complex data from a project with an extensive backlog.
To be clear: this is the new agents introduced in 1.0.60
Environment
- OS: macOS 15.5 (24F74)
- Claude Code: v1.0.61
- Node Version: v20.19.1
- Working Directory: Single MCP server project with large backlog file
Steps to Reproduce
- Work in a project with an extensive backlog (long .claude/backlog.md file)
- Use the Task tool to spawn a sub-agent (the new feature with pre-defined roles in .claude/agents/xxx)
- Process freezes during response serialization
Expected Behavior
Task tool sub-agent spawning should complete and return results without freezing.
Actual Behavior
- Process uses 100%+ CPU indefinitely
- Session becomes unresponsive
- Must force kill process (PID)
Technical Details
Process sampling reveals the freeze occurs in V8's JSON serialization:
v8::internal::JsonStringifier::Serialize_<false> (2000+ recursive calls)
v8::internal::JsonStringifier::SerializeArrayLikeSlow
v8::internal::IncrementalStringBuilder::Extend
Multiple garbage collection cycles are triggered, indicating memory pressure from expanding strings.
Root Cause
The issue appears to be caused by attempting to serialize an object containing project context (likely including the large backlog file) with:
- Circular references in the context data
- Extremely deep nesting in project metadata
- Large backlog/project data being included in serialization
Suggested Fix
- Implement circular reference detection before serialization
- Add depth limits for object serialization
- Use a custom JSON.stringify replacer to handle edge cases
- Add timeouts for serialization operations
Impact
This bug makes the Task tool unusable for sub-agent spawning, particularly in projects with large context files.
Additional Information
- Reproducible across multiple attempts
- Specifically affects projects with large .claude/backlog.md files
- No error messages logged before freeze
- Process working directory:
/Users/guillaume/dev/tools/mcp/obsidian-mcp-resources - Full process sample and stack trace available if needed
Labels to add: bug, performance, multi-agent
Activity
megagon commentedon Jul 28, 2025
same here
janreges commentedon Jul 29, 2025
In my case, the same with version 1.0.62. After a few minutes of parallel work of several subagents, the CPU is 100% (single-core with claude process) and it is practically impossible to stop CC in any way other than by killing the process.
Aroton commentedon Jul 30, 2025
I'm seeing this too. I'm on wsl2/ubuntu. I actually started seeing this with the task tool a couple releases ago. I used to be able to run 10x tasks in parallel and merge back in now issues. Now after 2-3 sub agent tasks in serial, my timers even lag out, and I can't type anything into the input box.
I am on node 22 and recently cleared out all claude config files and reinstalled claude fresh.
Aroton commentedon Jul 30, 2025
Did a little bit more digging. And this seems to be munmap related. I do have 2 instances of claude running. And it seems like its getting a ton of write locks relative to everything else.
Aroton commentedon Jul 30, 2025
Ok clearly something wrong with statsig
Aroton commentedon Jul 30, 2025
Ok so. I think i've disabled statsig with env variables and the issue persists. This is during a CPU spike:
Looks like its doing some memory thrashing:
Watching the RES memory in HTOP it constantly goes to 1gig of memory down to 278M, on repeat at 100% cpu
Aroton commentedon Jul 30, 2025
Edit 2:
Alright, I asked claude to optimize memory settings based on large JSON files and it seems to be working very well. Claude Code is running significantly faster than it was and i'm not seeing the memory thrashing anymore. The downside is it's using more memory overall (quite a bit more).
Here are the settings:
EDIT:
It did not fix it. It may have something to do with having 2 claude instances going at the same time. I'll test more tomorrow. But now my munmaps are ungodly slow.
Ok. I may have found a workaround to the memory issue. Basically, tweak the memory stack settings with env variables. Nowall my munmaps are executing much faster.
duquesnay commentedon Jul 30, 2025
@Aroton interesting result. I know mine happened when I used a sub agent to coordinate the work, so I guess that works as the 2 agents situation. The first analysis from Claude suspected about a loop between the main agent monitoring the sub agent output... which would trigger more output somehow, so an infinite loop of increasing output (my words and general idea). It got slightly better when asking the coordinator agent to provide shortened output, but not for long.
I finally removed my coordinator agent and it doesn't happen anymore. The main agent coordinates directly the other sub agents (developer, architect, etc) and I didn't have a freeze. I'm not too sure what I'm doing right to circumvent the previous bug to be honest
KrustyHack commentedon Jul 30, 2025
I'm in a similar situation at the moment. I ask Claude Code to develop something with the help of various sub-agents (fullstack, designer, git-commiter, etc.) and after a some time, nothing more happen, it seems Claude Code is stuck. I have to
kill -9it.At first I tought it was my CLAUDE.md file to heavy (5k lines) but even with lightweight CLAUDE.md file the problem subsist.
toddsundsted commentedon Jul 30, 2025
I don't think this adds much to the thread, but I encounter the same problem running an alpine linux VM with orbstack on OSX. I am using node v22.15.1. The subagent starts working on the problem and never stops (before using a subagent on the task it might take ~5 seconds to do the work). As soon as I hit escape to terminate the work, the orbstack helper shoots up to 100% and the VM becomes unresponsive. Eventually it terminates with the output:
17 remaining items
fullofcaffeine commentedon Aug 30, 2025
+1 claude code CLI has been almost unusable, mac M2.
damianmikla commentedon Sep 11, 2025
+1
shreefentsar commentedon Sep 28, 2025
same error with multi agents
Srules commentedon Oct 1, 2025
I've experienced this issue on Mac for a long time with even a single session. My issue has been resolved so far after uninstalling:
npm uninstall -g @anthropic-ai/claude-codeand reinstall via the recommended method currently for Mac:curl -fsSL https://claude.ai/install.sh | bash. If you also installed via npm, this may help.github-actions commentedon Dec 6, 2025
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
rmonsurate commentedon Dec 18, 2025
same issue
github-actions commentedon Jan 18, 2026
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
marcindulak commentedon Jan 18, 2026
This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at #16497. Please upvote that issue, so maybe it gets noticed.
shoelessrob commentedon Jan 18, 2026
Still experiencing this issue in v2.1.12 on macOS 26.3 (Apple Silicon).
Symptoms:
kill -9the process from another terminalProcess diagnostics:
sampleshowed main thread stuck in tight loop (JS engine churning)UI state when frozen:
The status bar showed
-- INSERT -- ‖ plan mode onbut input was completely blocked.This appears to be the same root cause — subagent/Task tool causing infinite loop with no way to interrupt.
jmhunter83 commentedon Jan 19, 2026
Confirming this issue - v2.1.12, macOS Sequoia
Environment
Symptoms
kill -9)Diagnostic Data
CPU Sample (via
sample <pid> 1):???(JIT code, no symbols)Process state:
Session file trigger:
The project (a Swift iOS app) had accumulated 16 session files over 20MB each, with the active session reaching 78.6MB. Total session directory was 867MB.
Reproduction
Workaround Applied
This reduced the session directory from 867MB to 187MB and restored normal operation.
Suggestion
Consider:
github-actions commentedon Jan 26, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.