Skip to main content

Structured alert routing to humans and AI agents

Project description

agent-alerts

Structured alert routing to humans and AI agents.

Install

pip install agent-alerts
pip install "agent-alerts[mcp]"
pip install "agent-alerts[agent]"

Python imports stay under alerts.

Quick Start

Send a simple alert directly to Telegram:

from alerts import send

send("Screen complete: 4 names passed", channel="telegram")

That reads TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID from your environment unless you pass token= and chat_id= explicitly.

Use AlertRouter for structured routing, thresholds, quiet hours, and agent follow-up:

from alerts import Alert, AlertCategory, AlertLevel, AlertRouter

router = AlertRouter(config_path="alerting.yaml")

result = router.send(
    Alert(
        title="Estimate revisions turning negative",
        body="NVDA revisions rolled over after guidance.",
        level=AlertLevel.HIGH,
        category=AlertCategory.SIGNAL,
        source="portfolio-system",
        source_type="estimate_revisions",
        metadata={"passed_count": 1},
    )
)

print(result.delivered_channels)
print(result.agent_dispatched)

Channels

Channel Purpose Required config
telegram Fast human notification TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID
imessage Local macOS delivery IMESSAGE_TARGET or channels.imessage.recipient; optional backend, service
email SMTP delivery smtp_host, smtp_port, from, to plus EMAIL_USERNAME, EMAIL_PASSWORD
agent Background agent analysis with human feedback gateway_url, gateway_api_key_env; optional model, feedback_channel

Router Config

Example alerting.yaml:

schema_version: 2
on_config_error: use_last_good

channels:
  telegram:
    enabled: true
  imessage:
    enabled: false
    recipient: "+15555551212"
    backend: applescript
  email:
    enabled: false
    smtp_host: smtp.gmail.com
    smtp_port: 587
    from: alerts@example.com
    to:
      - user@example.com
  agent:
    enabled: true
    gateway_url: "http://127.0.0.1:8002"
    gateway_api_key_env: "ALERTS_GATEWAY_API_KEY"
    model: "claude-sonnet-4-6"
    feedback_channel: telegram

routing:
  critical: [telegram, agent]
  high: [telegram, agent]
  normal: [telegram]
  low: []
  by_category:
    signal:
      critical: [telegram, agent]
    screen_result:
      high: [telegram, agent]

quiet_hours:
  enabled: true
  start: "22:00"
  end: "07:00"
  timezone: "America/New_York"
  per_channel:
    agent:
      enabled: false

rate_limits:
  enabled: true
  global_max_per_hour: 20
  agent_max_per_hour: 5

thresholds:
  _default:
    min_passed_count: 1
    default_level: normal
    max_per_hour: 3
  estimate_revisions:
    min_passed_count: 1
    level_rules:
      - when:
          passed_count_gte: 3
        level: critical

MCP Server

The package exposes an MCP server entry point:

alerts-mcp
python -m alerts.mcp_server

It provides three tools:

  • notify_send
  • notify_list_channels
  • notify_test_channel

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_alerts-0.1.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_alerts-0.1.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file agent_alerts-0.1.1.tar.gz.

File metadata

  • Download URL: agent_alerts-0.1.1.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for agent_alerts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 75f1c90a48444c4fc498cba4956fb638c56f2d766c6bc7dd9bc83de9f55e58aa
MD5 01c8f9c478e9345397d77ef5cc65c9f6
BLAKE2b-256 51c1d0ddc3892cf1d45bf978efe7077bf41144e209d4faecd94bf7d5ed4a1d03

See more details on using hashes here.

File details

Details for the file agent_alerts-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agent_alerts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for agent_alerts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1ec65bc9267c81012017896d361ce70a62a6adcd5f01e60680123d349cbc2f0
MD5 dca68828ecf3555281b6ea4618b88b0d
BLAKE2b-256 5575cf390eca8407f420ac6a35db1653f38345327288805128fb492a3fbce845

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page