Skip to content

feat(hooks): Notification event — fires when agent needs user attention#224

Merged
emal-avala merged 1 commit intomainfrom
feat/hook-notification-event
Apr 23, 2026
Merged

feat(hooks): Notification event — fires when agent needs user attention#224
emal-avala merged 1 commit intomainfrom
feat/hook-notification-event

Conversation

@emal-avala
Copy link
Copy Markdown
Member

@emal-avala emal-avala commented Apr 23, 2026

Summary

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_with_sink:
    • 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

Test plan

  • cargo clippy --workspace --tests --no-deps -- -D warnings — clean
  • cargo test -p agent-code-lib --lib hooks::tests — 6 pass
  • cargo test -p agent-code-lib --lib config::schema::tests::hook_event_serde_roundtrip_notification — pass
  • cargo test -p agent-code --bin agent commands::tests::parse_hook_event — 7 pass

3 new tests:

  1. Schema serde round-trip (notification"notification")
  2. run_hooks dispatches for Notification
  3. parse_hook_event accepts "notification" / "Notification"

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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"
@emal-avala emal-avala force-pushed the feat/hook-notification-event branch from 75d6fb5 to c6de64a Compare April 23, 2026 21:47
@emal-avala emal-avala merged commit f639cc2 into main Apr 23, 2026
14 checks passed
@emal-avala emal-avala deleted the feat/hook-notification-event branch April 23, 2026 21:48
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