Feature request: support additionalContext in PreCompact/PostCompact hook output

Resolved 💬 3 comments Opened Apr 10, 2026 by timwinders Closed May 23, 2026

Summary

PreCompact and PostCompact hook events do not support hookSpecificOutput.additionalContext, but they should. Currently the only valid output field for these events is systemMessage (a display-only notification). There's no way to inject context into the compaction summary or the post-compaction conversation.

Use case

When a session compacts, we want the model to:

  1. Before compaction (PreCompact): Be instructed to explicitly include any unwritten structured data (action items, decisions, open questions) in the compaction summary, so they survive context loss and can be written to a database at session end.
  1. After compaction (PostCompact): Be reminded to scan the compaction summary for labeled items and persist them.

This is exactly the kind of workflow that additionalContext enables for UserPromptSubmit — injecting instructions the user shouldn't have to type themselves.

Current behavior

Using hookSpecificOutput with hookEventName: "PreCompact" or "PostCompact" fails validation:

Hook JSON output validation failed:
  - : Invalid input

The schema only accepts "PreToolUse", "UserPromptSubmit", and "PostToolUse" in hookSpecificOutput.hookEventName.

Requested behavior

Extend hookSpecificOutput to support PreCompact and PostCompact event types, with at minimum an additionalContext field (same semantics as UserPromptSubmit):

{
  "hookSpecificOutput": {
    "hookEventName": "PreCompact",
    "additionalContext": "COMPACTION NOTICE: Before summarizing, include any unwritten action items labeled 'UNWRITTEN ACTION ITEM:' so they survive context loss."
  }
}

Workaround

Currently using systemMessage only (display notification) plus a flag file on disk that downstream tools check. This is fragile and doesn't actually influence what the model includes in the compaction summary.

Environment

  • Claude Code CLI (Mac, zsh)
  • Observed in hook schema validation error output

View original on GitHub ↗

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