Skip to content

Claude Code hangs indefinitely during context compaction #19567

Closed as not planned

Description

@TPG24

Summary

Claude Code becomes completely unresponsive when attempting to compact/summarize a large context. The terminal freezes, Ctrl+C doesn't work, and the process becomes orphaned consuming excessive resources indefinitely.

Environment

  • Claude Code version: 2.1.12
  • OS: macOS 26.2 (Build 25C56)
  • Architecture: Apple Silicon (arm64, M3 Max)
  • Shell: zsh

Steps to Reproduce

  1. Start a Claude Code session
  2. Work on a complex task that generates a large context (multiple tool calls, large file reads, spawning subagents)
  3. Continue until the session approaches context limits (~23+ MB session file)
  4. When compaction/summarization is triggered, the terminal becomes completely unresponsive

Expected Behavior

  • Compaction should complete within a reasonable timeout
  • If compaction fails, Claude Code should gracefully handle the error
  • Ctrl+C should be able to interrupt the process
  • The process should not become orphaned

Actual Behavior

  • Terminal goes completely blank/unresponsive
  • Ctrl+C has no effect
  • User must close the terminal window entirely
  • The Claude process becomes orphaned (PPID=1) and continues running
  • Orphaned process consumes excessive resources:
    • CPU: 277%
    • RAM: 11.8 GB (31% of system memory)
    • Runtime: 26+ hours until manually killed

Diagnostic Information

Orphaned process details:

PID   PPID STAT STARTED     ELAPSED        ARGS
34461    1 R    Mon01PM     01-02:45:16    claude --dangerously-skip-permissions

Process was holding these files (no active session file):

stats-cache.json
cc-hud.json
secondbrain.json
settings.json
cc-statusline.json
history.jsonl

Session that likely triggered the hang:

  • Workspace: secondbrain
  • Session file size: 23.6 MB
  • Session had already been compacted once (started with summary)
  • Topic: "CampusIQ Tools Sync & Update Manager"

Impact

  • Data loss: Any unsaved work in the session is lost
  • Resource exhaustion: Orphaned process consumes ~12 GB RAM until manually killed
  • User disruption: Must force-close terminal and hunt for zombie processes

Suggested Fixes

  1. Add timeout for compaction API calls - If summarization takes longer than X seconds, abort gracefully
  2. Preserve Ctrl+C handling - Ensure signal handlers remain active during compaction
  3. Add compaction progress indicator - Show user that compaction is in progress
  4. Graceful degradation - If compaction fails, offer to start a new session with a brief summary rather than hanging
  5. Session size warnings - Warn user when session file exceeds a threshold (e.g., 15 MB) before hitting critical limits

Workaround

Users experiencing this issue should:

  1. Check for orphaned processes: ps aux | grep claude | grep -v grep
  2. Look for processes with PPID=1 and high resource usage
  3. Kill orphaned processes: kill -9 <PID>

Activity

  1. github-actions commented on Jan 20, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [Bug] GC death spiral causes process freeze with unresponsive Ctrl+C during long sessions #19344
    2. [BUG] Claude Code v2.1.9 Complete Freeze - 100% CPU, Main Thread Stuck in Infinite Loop (macOS ARM64) #18532
    3. Orphaned processes after terminal close cause runaway memory consumption (34GB+ per instance) #17391

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. anschmieg commented on Jan 23, 2026

    @anschmieg

    I am experiencing a similar issue, though it usually does not occur during context compaction but rather when making a request that triggers tool calls, subagents or similar. I am using OMC and have not yet tested whether the issue occurs without that plugin.

  3. anschmieg commented on Jan 23, 2026

    @anschmieg

    Actually it appears that the issue was fairly trivial in my case, at least it has not occurred since this fix. Apparently, since I have proctools installed via brew, it overrides the macOS-native pgrep/pkill. When Claude Code calls this incompatible version it cannot find its child processes and proceeds to respawn them until the process table is full.

    I have now been running PATH="/usr/bin:$PATH" claude to put the system-provided versions first in the path so that Claude finds them. This has been working so far, I will probably add this to my shell profiles as an alias.

    If this turns out to be the same issue that has been reported by others, I suggest Claude Code look for the /usr/bin/pgrep and /usr/bin/pkill binaries by their full path on macOS... and maybe add a limit instead of eternally respawning processes if it cannot find them?

  4. anschmieg commented on Jan 27, 2026

    @anschmieg

    @TPG24 Is your issue related to what I described or is it resource usage based on actual agentic actions?

  5. github-actions commented on Mar 1, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  6. github-actions commented on Mar 10, 2026

    @github-actions

    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.

  7. locked as resolved and limited conversation to collaborators on Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions