-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Description
Summary
Request a dedicated session:compact or session:compacted hook event that fires when a session is compacted/summarized.
Use Case
When a session is compacted, the agent loses specific memories and operational patterns learned during the session. I want to inject a reminder to re-read key files (like learned-patterns.md, current-focus.md) after compaction so that important knowledge survives.
Current Workaround
I've built a workaround that:
- Hooks into
agent:bootstrap - Detects compaction by looking for markers like "session is being continued" or "ran out of context" in recent messages
- Injects a reminder if detected
This works but is fragile — it depends on specific phrasing in compaction summaries.
Requested Event
A proper session:compact event that fires once when compaction completes, with context like:
sessionId/sessionKeysummaryLengthortokensRetained- Ability to inject messages into the post-compaction context
This would enable reliable post-compaction memory refresh without relying on text detection.
Related
The hooks documentation shows session:start and session:end as "planned events" — this would fit naturally alongside those.