All plugin hooks stop firing after context compaction

Resolved 💬 5 comments Opened Feb 14, 2026 by Glucksberg Closed Apr 5, 2026

Description

After context compaction (triggered when a conversation exceeds the context window limit), all plugin hooks stop firing for the remainder of the session. This affects every hook type: PostToolUse, SessionStart, Stop — not just a single event type.

MCP server tools continue working normally (health checks, context injection, tool calls all function). Only the hook execution pipeline is affected.

Environment

  • Claude Code version: 2.1.39 (confirmed via version field in session transcript JSONL — the running process, not the auto-updated binary)
  • Platform: Linux (Ubuntu, Hetzner VPS)
  • Node.js: v22.21.1
  • Plugin: claude-mem (v9.1.1) — uses PostToolUse hooks to capture observations

Steps to Reproduce

  1. Start a Claude Code session with a plugin that registers PostToolUse hooks
  2. Use the session extensively until context compaction is triggered (context window limit exceeded)
  3. After compaction, continue using tools in the continued session
  4. Observe that no hook_progress events appear in the transcript JSONL, and no hook commands are executed

Evidence

1. Transcript JSONL analysis (hook_progress events)

Analyzed the session transcript at ~/.claude/projects/.../SESSION_ID.jsonl:

Total hook_progress events in transcript: 347

By event type:
  SessionStart:  3 events   (22:27:05 → 22:27:05)
  PostToolUse:   304 events (22:27:20 → 23:11:13)  ← LAST at 23:11:13
  Stop:          40 events  (22:31:13 → 23:04:22)

hook_progress events after context compaction (23:15 UTC): 0

Zero hook events of any kind after compaction, despite dozens of tool calls continuing in the session.

2. Independent verification via HTTP server logs

The plugin's worker daemon logs all incoming HTTP requests. After compaction, the worker received zero observation POST requests from hooks, while tool calls were clearly happening in the session:

Last hook-triggered POST:     23:15:22 (Bash tool)
Context compaction:           ~23:15 → 23:23
First tool call after:        23:24:26 (Bash tool)  ← NO hook POST
Subsequent tool calls:        23:24:26 → 00:04:57   ← ALL without hook POSTs
Manual POST test:             23:45:36 → Processed successfully (pipeline OK)

3. Transcript timeline around compaction point

23:11:13  hook_progress PostToolUse:Write    ← LAST hook that fired
23:11:19  tool:ExitPlanMode
23:14:20  user result (plan approval)
          [tool calls continue, hooks still working per worker logs]
          [CONTEXT COMPACTION happens here — entries removed from transcript]
23:23:56  assistant                          ← Continued session starts
23:24:20  user (new prompt)
23:24:26  tool:Bash                          ← NO hook_progress
23:24:26  tool:Read                          ← NO hook_progress
23:24:33  tool:Bash                          ← NO hook_progress
          [dozens more tool calls, ZERO hooks of ANY type]

4. Plugin hooks configuration (working correctly before compaction)

From hooks/hooks.json:

{
  "PostToolUse": [{
    "matcher": "*",
    "hooks": [
      {"type": "command", "command": "node ... worker-service.cjs start", "timeout": 60},
      {"type": "command", "command": "node ... worker-service.cjs hook claude-code observation", "timeout": 120}
    ]
  }],
  "SessionStart": [{
    "matcher": "startup|clear|compact",
    "hooks": [...]
  }]
}

Note: SessionStart has "compact" in its matcher, suggesting hooks should re-initialize on compaction, but this doesn't happen.

Expected Behavior

After context compaction, hooks should continue firing for all tool uses in the continued session. At minimum, SessionStart with the "compact" matcher should fire to allow plugins to re-initialize.

Actual Behavior

After context compaction, the hook execution pipeline completely stops. No hook_progress entries are written to the transcript, and no hook commands are executed. This persists for the entire remainder of the session, including across multiple context continuations.

Impact

Any plugin relying on hooks loses all event notifications after a single context compaction. For long-running sessions that exceed context limits, this means:

  • Observation/logging plugins stop capturing data
  • Monitoring hooks stop running
  • Session lifecycle hooks (Stop, summarize) don't fire

Workaround

Starting a new session (/clear or new claude invocation) re-registers hooks via SessionStart and restores normal hook execution.

View original on GitHub ↗

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