feat(hooks): Notification event — fires when agent needs user attention#224
Merged
emal-avala merged 1 commit intomainfrom Apr 23, 2026
Merged
feat(hooks): Notification event — fires when agent needs user attention#224emal-avala merged 1 commit intomainfrom
emal-avala merged 1 commit intomainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
45c4ad4 to
564f73b
Compare
6 tasks
564f73b to
75d6fb5
Compare
Adds a `Notification` hook event. Previously the `sink.on_warning` path only reached stderr (and the JSONL `warning` event as of #215); users couldn't wire a desktop notifier, Slack DM, or SMS to those moments because there was no hook. Context payload: { "session_id": "...", "message": "...", "title": "..." | null, "notification_type": "budget_limit" | "context_full" | ... } `notification_type` lets hook configs filter so a Slack-on-budget hook doesn't also fire on routine context warnings. Wiring: - HookEvent::Notification added with snake_case serde - fire_notification_hooks(message, title, notification_type) async method on QueryEngine - Wired at the 3 most critical user-attention sites in run_turn: - BudgetDecision::Stop -> "budget_limit" - BudgetDecision::ContinueWithWarning -> "budget_warning" - Context window is_blocking -> "context_full" - Non-blocking context % warnings and per-turn rate-limit fallbacks stay warning-only — routing every retry would be noise - HOOK_EVENT_CATALOG, format_hook_event, parse_hook_event updated - hooks/mod.rs module docs updated Tests: 3 new - Schema serde round-trip (notification <-> "notification") - run_hooks dispatches for Notification (async tokio) - parse_hook_event accepts "notification" / "Notification"
75d6fb5 to
c6de64a
Compare
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
Adds a
Notificationhook event. Previously thesink.on_warningpath only reached stderr (and the JSONLwarningevent as of #215); users couldn't wire a desktop notifier, Slack DM, or SMS to those moments because there was no hook.Context payload
{ "session_id": "...", "message": "...", "title": "..." | null, "notification_type": "budget_limit" | "context_full" | ... }notification_typelets hook configs filter so a Slack-on-budget hook doesn't also fire on routine context warnings.Wiring
HookEvent::Notificationadded withsnake_caseserdefire_notification_hooks(message, title, notification_type)async method onQueryEnginerun_turn_with_sink:BudgetDecision::Stop→"budget_limit"BudgetDecision::ContinueWithWarning→"budget_warning"is_blocking→"context_full"HOOK_EVENT_CATALOG,format_hook_event,parse_hook_eventupdatedhooks/mod.rsmodule docs updatedTest plan
cargo clippy --workspace --tests --no-deps -- -D warnings— cleancargo test -p agent-code-lib --lib hooks::tests— 6 passcargo test -p agent-code-lib --lib config::schema::tests::hook_event_serde_roundtrip_notification— passcargo test -p agent-code --bin agent commands::tests::parse_hook_event— 7 pass3 new tests:
notification↔"notification")run_hooksdispatches forNotificationparse_hook_eventaccepts"notification"/"Notification"