SessionStart (compact): expose parent_session_id in hook input

Resolved 💬 2 comments Opened Feb 26, 2026 by MrGossett Closed Mar 27, 2026

Summary

When context compaction fires and a new session starts, the SessionStart hook receives source: compact but has no way to identify which session was just compacted. Adding a parent_session_id field to the hook input would make it straightforward to build compaction-aware hooks.

Use case

A SessionStart (compact) hook that re-injects a reference to the pre-compaction transcript for progressive disclosure — so Claude can read back specific details from the original JSONL after compaction has summarized them away.

The full pre-compaction transcript is already preserved on disk at ~/.claude/projects/<project>/<session-id>.jsonl. The hook just needs to tell Claude where it is. Without parent_session_id, there's no reliable way to identify which JSONL file is the immediate pre-compaction parent, especially when multiple conversations are active in the same project directory with interleaved activity.

Current workaround

A two-hook approach:

  1. PreCompact — write a short-lived marker file at ~/.claude/compact-pending/<session-id> before compaction fires
  2. SessionStart (compact) — scan ~/.claude/compact-pending/ for markers matching JSONL files in this project, take the most recently written match, consume (read + delete) it

This is fragile: it relies on timing heuristics and can mis-identify the parent if two sessions in the same project compact within milliseconds of each other.

Proposed change

Add parent_session_id to the SessionStart hook input when source is compact:

{
  "session_id": "<new-session-id>",
  "parent_session_id": "<old-session-id>",
  "source": "compact",
  "cwd": "/path/to/project"
}

parent_session_id would be null or absent for source values other than compact.

Impact

Enables robust compaction-aware hooks without workarounds. The pre-compaction JSONL path is then trivially derivable: ~/.claude/projects/<project-key>/<parent_session_id>.jsonl.

View original on GitHub ↗

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