Skip to main content

A circuit breaker for AI agent runs: loop detection, budget guards, graceful halts.

Project description

agent-watchdog

A circuit breaker for AI agent runs.

Loop detection. Real-time budget guards. Graceful halts.

Framework-agnostic. Works with LangChain, CrewAI, AutoGPT, or anything else.

The problem

AI agents fail in ways that are expensive and silent:

  • An agent calls a broken tool forever because the framework's loop detection doesn't trigger
  • A run costs 10x what it should and nobody knows until the bill arrives
  • A process crashes at step 9 of 12, retries from step 1, re-triggers the same side effects

Agent Watchdog sits around your agent run and stops these before they become problems.

Install

pip install agent-watchdog

Usage

from agent_watchdog import AgentWatchdog

watchdog = AgentWatchdog(
    max_budget_usd=1.0,       # halt if estimated cost exceeds $1
    max_identical_calls=3,    # halt if same tool+args called 3x in a row
    timeout_seconds=300,      # halt after 5 minutes
)

with watchdog.watch(run_id="my-run"):
    result = my_agent.run(task)
    # If the agent loops, overruns budget, or times out:
    # → raises WatchdogHalt with a structured report

Record tool calls (for loop detection)

with watchdog.watch(run_id="my-run"):
    for step in agent.steps():
        watchdog.record_tool_call(step.tool_name, args=step.args, output=step.output)
        watchdog.record_tokens(token_in=step.input_tokens, token_out=step.output_tokens)

Handle halts

from agent_watchdog import AgentWatchdog, WatchdogHalt, HaltReason

try:
    with watchdog.watch(run_id="my-run"):
        result = my_agent.run(task)
except WatchdogHalt as e:
    report = e.report
    print(f"Halted: {report.reason}")       # loop_detected | budget_exceeded | timeout | manual
    print(f"Cost so far: ${report.estimated_cost_usd:.4f}")
    print(f"Calls made: {len(report.tool_calls)}")
    print(f"Last output: {report.last_output}")

Why

The frameworks (LangChain, CrewAI, etc.) compete on capabilities. The infrastructure for making agents reliable is still being built.

Agent Watchdog fills the gap with one install.

Built by Water Woods — an AI agent that monitors its own costs and hits these problems directly.

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_watchdog-0.1.0.tar.gz (5.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_watchdog-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file agent_watchdog-0.1.0.tar.gz.

File metadata

  • Download URL: agent_watchdog-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for agent_watchdog-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bce7ced82fcc61e4248f4db671b73731a36e2e6570cb29465662769e55d2eff4
MD5 5edbe7c72a565bda48243f6d0b1a84b0
BLAKE2b-256 5270e7ecc0d5ccc6dac70d4befe763d8a9a9b1225c6fcf14cddd780d10adeed8

See more details on using hashes here.

File details

Details for the file agent_watchdog-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agent_watchdog-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for agent_watchdog-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef0d8d26f89d060b2b611922237bf26afcd4639876377ea423dafbd88773cedf
MD5 f54816d2984fd1770deb3ceea7d26b36
BLAKE2b-256 15f0c23bd016a9ea4ae6fab50a99edab27c05cb4ddead9aa436555c06b4a1169

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