Cross-platform notifications for long-running agentic CLI tools
Project description
agent-notify
agent-notify is a cross-platform CLI utility that sends a notification when a long-running agentic command completes.
It is designed for Codex CLI/app, Claude Code, Gemini CLI, Antigravity, and any other process-based tooling.
Features
- Wrap and run commands:
agent-notify run -- <cmd...> - Attach to existing processes:
agent-notify watch --pid <pid> - Notifications for success and failure
- Summary payload includes duration and exit code, with optional output tail lines
- macOS desktop notifications via Notification Center (
osascript) - Windows desktop notifications via PowerShell + BurntToast, with
win10toastfallback - Console fallback channel for unsupported environments
Installation
Preferred:
pipx install agent-notify
Alternative:
pip install agent-notify
From source:
python -m pip install -e .
Quickstart
Recommended: task-level hooks for interactive CLIs (no exit required).
1) Gemini CLI
Configure Gemini AfterAgent hook:
{
"hooksConfig": {
"enabled": true
},
"hooks": {
"AfterAgent": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "agent-notify gemini-hook --name gemini --channel both --quiet-when-focused --chime ping",
"timeout": 10000
}
]
}
]
}
}
2) Codex CLI
Codex has a built-in notify command hook that fires when an agent turn completes.
Use the provided bridge script:
chmod +x examples/codex_notify_bridge.sh
realpath examples/codex_notify_bridge.sh
Add this to ~/.codex/config.toml:
notify = [
"/absolute/path/to/examples/codex_notify_bridge.sh"
]
This wrapper handles Codex payload format differences and uses your installed agent-notify
binary when available. Optional debug logging is disabled by default and can be enabled with:
export AGENT_NOTIFY_DEBUG=1
Default debug log location:
~/.agentnotify/logs/codex_notify.log
3) Claude Code
Configure Claude hooks (project-local .claude/settings.local.json or user settings):
{
"hooks": {
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "agent-notify claude-hook --event Stop --name claude-code --channel both --quiet-when-focused --chime ping"
}
]
}
],
"SubagentStop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "agent-notify claude-hook --event SubagentStop --name claude-code --channel both --quiet-when-focused --chime ping"
}
]
}
]
}
}
4) Ollama
- Pure
ollama rundoes not expose a native task-finished hook in interactive mode. - If using
ollama launch codexorollama launch claude, configure Codex/Claude hooks above and notifications still work. - For non-interactive JSON output, you can pipe into:
agent-notify ollama-hook --name ollama --channel both
Legacy mode (process exit, not task-level):
eval "$(agent-notify shell-init --shell zsh --min-seconds 10 --channel both)"
Disable legacy shell-exit notifications:
sed -i '' '/agent-notify shell-init/d' ~/.zshrc
source ~/.zshrc
If you want only task-level notifications, do not enable shell-init.
CLI Reference
agent-notify run -- <cmd...>
- Wrapper exit code matches wrapped command exit code.
Options:
--name <tool>: notification label- if omitted,
agent-notifyauto-detects from the wrapped command
- if omitted,
--title <string>: title override--tail-lines <N>: include last N output lines--no-capture: disable stdout/stderr tail capture--channel desktop|console|both: channel selection--verbose: verbose fallback/warning logs
Examples:
agent-notify run --name codex --tail-lines 20 -- codex run "build docs"
agent-notify run --channel both -- python -c "import time; time.sleep(3)"
agent-notify watch --pid <pid>
Options:
--name,--title,--channel,--verbose- if
--nameis omitted,agent-notifytries to detect process name from PID
- if
--poll-interval <seconds>
Example:
python -c "import time; time.sleep(5)" &
agent-notify watch --pid $! --name background-job
agent-notify tail --file <path> --pattern <text>
Optional log watcher mode that notifies when a pattern appears.
agent-notify test-notify
Sends a sample notification through the selected channel.
agent-notify emit (integration/internal)
Sends a completion notification from external hooks with explicit command metadata.
agent-notify gemini-hook
Reads a Gemini hook JSON payload from stdin and notifies for matching events.
Default behavior:
- Event trigger:
AfterAgent - Tool label:
gemini
Useful flags:
--event <name>: trigger on a different hook event--name <tool>: notification label--channel desktop|console|both--quiet-when-focused: suppress notification while terminal is in focus (macOS)--chime none|bell|ping: optional sound when notifying
agent-notify claude-hook
Reads a Claude hook JSON payload from stdin and notifies for matching events.
Default behavior:
- Event trigger:
Stop - Tool label:
claude-code
Useful flags:
--event <name>: trigger on a different hook event (for exampleSubagentStop)--name <tool>: notification label--channel desktop|console|both--quiet-when-focused: suppress notification while terminal is in focus (macOS)--chime none|bell|ping: optional sound when notifying
agent-notify codex-hook [payload]
Reads a Codex notify JSON payload (argument or stdin) and notifies for matching events.
Default behavior:
- Event trigger:
agent-turn-complete - Tool label:
codex
Useful flags:
--event <name>: trigger on a different Codex event type--name <tool>: notification label--channel desktop|console|both--quiet-when-focused: suppress notification while terminal is in focus (macOS)--chime none|bell|ping: optional sound when notifying
agent-notify ollama-hook
Reads Ollama JSON/JSONL output from stdin (use ollama run --format json) and notifies on done=true.
agent-notify shell-init
Prints a shell hook script for zsh/bash. This mode notifies on process exit, not on task-level agent events.
Notification Content
Default title:
- Success:
[<tool>] Done - Failure:
[<tool>] Failed - If no tool is provided, defaults to
[Agent] ...(configurable).
Body includes:
- Duration (human readable)
- Exit code (or
unknownwhen unavailable) - Optional tail output lines
Long bodies are truncated safely.
Configuration
Environment variables:
AGENT_NOTIFY_TITLE_PREFIX="Agent"AGENT_NOTIFY_CHANNELS="desktop,console"AGENT_NOTIFY_TAIL_LINES=20AGENT_NOTIFY_POLL_INTERVAL=1.0
Optional TOML file:
~/.agentnotify/config.toml
title_prefix = "Agent"
channels = ["desktop"]
tail_lines = 20
poll_interval = 1.0
Environment variables override config file values.
Platform Notes
macOS
Uses:
osascript -e 'display notification "..." with title "..."'
If unavailable, agent-notify falls back to console output.
Windows
Primary backend:
- PowerShell + BurntToast (
New-BurntToastNotification)
Install BurntToast:
Install-Module BurntToast -Scope CurrentUser
Fallback backend:
- Python
win10toast(optional):
pip install "agent-notify[windows]"
Examples
Demo scripts:
examples/slow_success.shexamples/slow_fail.sh
Run:
agent-notify run --name demo -- ./examples/slow_success.sh
agent-notify run --name demo -- ./examples/slow_fail.sh
Development
Install dev tools and run checks:
python -m pip install -e ".[dev]"
ruff check .
pytest -q
python -m build
twine check dist/*
GitHub Release
Before first public release:
- Update repository links in
pyproject.toml([project.urls]). - Confirm package metadata and version (
agentnotify/__init__.py,pyproject.toml,CHANGELOG.md). - Run local checks (
ruff check .andpytest -q). - Follow the release checklist in
docs/release_checklist.md.
Project Management
- Project charter:
docs/project_charter.md - Scrum working agreement:
docs/scrum_working_agreement.md - Assumptions log:
docs/assumptions.md - Suggested commit sequencing:
docs/commit_plan.md - Release checklist:
docs/release_checklist.md - Security policy:
SECURITY.md
Roadmap
- Linux desktop backend plugin
- Webhook/Slack channel
- Cooldown/debounce controls
- System tray integration
License
MIT (LICENSE)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_notify-0.1.0.tar.gz.
File metadata
- Download URL: agent_notify-0.1.0.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38ee9d39cd77b09ba224d216cafe50e728127fe49de3d667e564cde9f6db40a1
|
|
| MD5 |
d51fa9c9c3b1f5bcc5bf42cc32380801
|
|
| BLAKE2b-256 |
0032096fdc84beb2f9ca965e074da179988a2604f9830ec1c6d298c5a9e89092
|
File details
Details for the file agent_notify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_notify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc41d364abefb7de31dd9d13f6805c22468dd4d99f34bf0cfb3d01c74d4cb7b0
|
|
| MD5 |
4371c68066fa906a0669578764edc262
|
|
| BLAKE2b-256 |
9c3a3e43050e8e62c37eca801cd9eb0e795ab9e16e8ebd227f28e9563f189b31
|