feat(hooks): SessionEnd lifecycle + PreCompact context injection - #172
Open
raymondginger2018-sudo wants to merge 1 commit into
Open
feat(hooks): SessionEnd lifecycle + PreCompact context injection#172raymondginger2018-sudo wants to merge 1 commit into
raymondginger2018-sudo wants to merge 1 commit into
Conversation
- SessionEnd: notification-only hook fired on every terminal path (complete / interrupted / error), so summaries can be persisted even when compaction never ran
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\n\nThis PR enhances the hooks subsystem with two lifecycle improvements:\n\n1. SessionEnd hook — a notification-only hook fired on every terminal turn path (complete / interrupted / error), so session summaries can be persisted even when history compaction never ran.\n2. PreCompact checkpoint reinjection — the PreCompact hook's additionalContexts are appended as a
[PreCompact checkpoint]user message after compaction, so the checkpoint survives history compression and the model can recover context.\n3. Hooks config — accepts the deepcode-hooks MCP hooks_config.json list shape with camelCase event aliases.\n\n## Changes\n\n-core/events/session.py: add_run_end_hookinvoked from the turn finally block (reason mapped from stop_reason)\n-core/agent_runtime/runner.py: capture PreCompact additional_contexts and reinject into compacted history\n-core/harness/hooks/events.py: registerSessionEndevent, add to matcher-less set\n-core/harness/hooks/engine.py: addrun_session_end; pass additional_contexts throughrun_pre_compact\n-core/harness/hooks/discovery.py: support deepcode-hooks MCP hooks_config.json list shape with camelCase aliases\n-core/harness/hooks/execution.py: register SessionEnd / PreCompact decoders\n\n## Notes\n\n- SessionEnd is notification-only: a hook failure is logged and never crashes a turn.\n- All 6 files passpy_compile; total diff +150/-12.