Feature Request: Hook events for session/context usage thresholds
Resolved 💬 5 comments Opened Mar 28, 2026 by planfit-river Closed May 5, 2026
Feature Request
Problem
There is no way to get notified when context window usage or session-level cumulative usage (e.g., Max plan token/cost budget) reaches certain thresholds. Users who are away or multitasking have no proactive warning before hitting limits.
These are two distinct concerns:
- Context window — how full the current context is (triggers compaction when full)
- Session usage — cumulative tokens/cost consumed across the entire conversation (subject to plan limits like Max plan)
Proposed Solution
Add two new hook events with configurable thresholds:
1. ContextUsageWarning — context window capacity
Fires when context window usage crosses a threshold (e.g., 70%, 80%, 90%).
{
"ContextUsageWarning": [
{
"matcher": "70|80|90",
"hooks": [
{
"type": "command",
"command": "terminal-notifier -title 'Context Window Warning' -message 'Context window usage reached ${THRESHOLD}%' -sound default"
}
]
}
]
}
2. SessionUsageWarning — cumulative session usage / plan budget
Fires when session-level cumulative usage crosses a threshold relative to the plan limit.
{
"SessionUsageWarning": [
{
"matcher": "70|80|90|100",
"hooks": [
{
"type": "command",
"command": "terminal-notifier -title 'Session Usage Warning' -message 'Session usage reached ${THRESHOLD}% of plan limit' -sound default"
}
]
}
]
}
Why
PreCompactonly fires once context is already full — too late to act/costrequires manual checking and is not automatable via hooks- Users running long tasks (tests, multi-file refactors, subagents) benefit from early warnings to plan compaction, start a new session, or budget remaining usage
- This aligns well with the existing hooks system and would be straightforward to configure
Alternatives Considered
- Using
PreCompacthook as a proxy for "context near 100%" — works but only covers one threshold and doesn't address session usage - Polling
/costmanually — not automatable via hooks
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗