Skip to content

Local Agent Mode sessions accumulate without cleanup, leaking ~100+ headless claude processes #57498

Description

@klum-tugo

Summary

The Claude desktop app spawns headless claude CLI sessions for Local Agent Mode but does not appear to reap them. Over a 2-day uptime, ~56 background agent sessions (each a disclaimer wrapper + claude Node child = ~112 processes) accumulated, plus their subagent/MCP children.

Environment

  • Claude desktop app: 1.6259.1
  • Bundled claude-code CLI: 2.1.128 (from ~/Library/Application Support/Claude/claude-code/2.1.128/)
  • macOS 26.4.1 (arm64)
  • Two interactive claude CLI sessions also running (unrelated, accounted for ~4 of the processes)

Observed

  • ps -axo pid,ppid,command | awk '/[c]laude/' | wc -l -> 162 claude processes
  • 56 of them are direct children of the desktop app (/Applications/Claude.app/Contents/MacOS/Claude, PID 52218)
  • All 56 share the Local Agent Mode invocation pattern:
    • --input-format stream-json --output-format stream-json
    • --allow-dangerously-skip-permissions --permission-mode auto
    • --allowedTools mcp__computer-use,mcp__ccd_session__spawn_task,mcp__ccd_session__mark_chapter,mcp__ccd_session_mgmt__list_sessions
    • --plugin-dir paths under local-agent-mode-sessions/
  • Process ETIMEs span from ~1 minute to 1 day 18 hours -- sessions clearly persist long after their work completes
  • Aggregate memory: ~12 GB resident across the family (each ~200 MB RSS, 19-20 threads, 80-100 ports)

Expected

Local Agent Mode sessions should be reaped after task completion, or at minimum on a sane idle timeout. They should not accumulate indefinitely across the desktop app lifetime.

Workaround

Quitting and relaunching the desktop app clears them, but state is lost.

Notes

This is the first user-visible symptom for me -- caught it at 24 GB memory used, 19 GB swap. On lower-memory machines this would degrade the system noticeably.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions