Skip to content

fix(hooks): PreCompact emits bare {} — Claude Code dropped the PreCompact envelope - #108

Merged
mahmoudimus merged 1 commit into
mainfrom
fix/pre-compact-bare-envelope
Jul 20, 2026
Merged

mahmoudimus merged 1 commit into
mainfrom
fix/pre-compact-bare-envelope

Conversation

@mahmoudimus

Copy link
Copy Markdown
Owner

What

Claude Code tightened its hook stdout schema: the hookSpecificOutput union no longer has a PreCompact variant, so the previous envelope {"hookSpecificOutput": {"hookEventName": "PreCompact"}} now fails validation:

PreCompact [simba hook PreCompact] failed: Hook JSON output validation failed — (root): Invalid input

The PreCompact render path now emits a bare {} (every top-level field is optional), which is valid under both the old and new schemas. stderr remains the human-visible channel; the export/distill work itself is unchanged.

Changes

  • src/simba/harness/adapters/claude.py — the PreCompact branch returns {} unconditionally (never suppressOutput, never a hookSpecificOutput envelope).
  • src/simba/hooks/_io.py — docstring carve-out: PreCompact no longer has an envelope variant and never calls into this module.
  • Tests re-targeted to the new contract (adapter + pre_compact/streaming/distill suites); the red-first adapter tests reproduce the exact rejected shapes.

Notes

  • .codex/hooks.json also registers PreCompact through this same render path; a bare {} is an inert no-op there too.
  • The pi bridge posts events to the daemon over HTTP and never consumes this stdout envelope.
  • CanonicalResult.suppress_output is still used by the internal hook-canonical debugging surface; intentionally untouched.

…e PreCompact envelope

Claude Code tightened its hook stdout schema: the hookSpecificOutput
union now only accepts hookEventName in {PreToolUse, UserPromptSubmit,
PostToolUse, PostToolBatch, Stop, SubagentStop}. There is no PreCompact
variant, so our old {"hookSpecificOutput": {"hookEventName": "PreCompact"}}
(and the {"suppressOutput": true} shape) now fails validation:

  PreCompact [simba hook PreCompact] failed: Hook JSON output validation
  failed -- (root): Invalid input

All top-level fields are optional, so the only shape guaranteed to
validate is a bare {}. claude.render's PreCompact branch now always
returns {} regardless of suppress_output/additional_context; stderr
remains the channel for human-visible notes. Other events' envelopes
are unchanged.
@mahmoudimus
mahmoudimus merged commit 804726b into main Jul 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant