[BUG] Agents spawning sub-agents causes and endless loop scenario and RAM OOM errors

Resolved 💬 3 comments Opened Jul 31, 2025 by slyfox1186 Closed Jul 31, 2025

Environment

  • Platform (select one):
  • [X] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: <!-- output of claude --version --> 1.0.63
  • Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
  • Ubuntu Jammy fully updated as of today
  • Terminal: <!-- e.g. iTerm2, Terminal App -->

Tilix

Bug Description

<!-- A clear and concise description of the bug -->

Agents spawn the same sub agent within itself causing a race condition issue.

  typescript-guardian(Fix missing API route error)
  ⎿  > kai-crm-frontend@0.1.0 build 
     > next build
     … +165 lines (ctrl+r to expand)
     typescript-guardian(Enhance Google OAuth callback)
     +6 more tool uses

You can see the typescript-guardian calls itself inside of itself typescript-guardian.

Steps to Reproduce

  1. Create an agent using claude itself and describe the agent to claude.
  2. Ask claude to run the subagent and call it by name.
  3. Sometimes the sub agent does not do this but very quickly it will if it is going to.
  4. You must hard close the terminal window and restart it to get it to be able to start over.

<!-- What you expected to happen -->
Not call the subagents recursively.
This can be patched by included these instructions which DOES NOT 100% REMOVE THE BAD BEHAVIOR it just HELPS minimize it!

CORE MANDATES                                                                                                - Absolute Accuracy: 100% accuracy is the only acceptable standard                                      
    - Autonomous Operation: You work alone - no sub-agents, no delegation                                   
    - Native Tools Only: Use only your internal file system and processing capabilities                     
    - No External Commands: Shell commands like find, grep, cat are forbidden                               
    - Persistent Verification: Continue until a full pass yields zero modifications 

Actual Behavior

It crashes the terminal

View original on GitHub ↗

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