Skip to main content

agent-watchdog

PyPI version License: MIT

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
    pattern_window_size=8,    # also detect ABAB / ABCABC repeating patterns (0 = off)
    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.

Framework Examples

Ready-to-use examples for popular frameworks:

Both handle the framework-specific details so you can focus on your agent logic.

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

Metadata

Release files for agent-watchdog 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-watchdog 0.1.5
File Size Uploaded Provenance
agent_watchdog-0.1.5.tar.gz 7.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-watchdog 0.1.5
File Interpreter ABI Platform
agent_watchdog-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / agent_watchdog-0.1.5.tar.gz

Download URL agent_watchdog-0.1.5.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
47173fa5b63118e5a9772e290fbbde1f3266b3e4c58aa0067a35e980e413ac4b
BLAKE2b-256 checksum
How to use checksums
5212a0483e9d0aa824150e76dd66ecfce0495e3d1eaccf1c76ccd0b07c941a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / agent_watchdog-0.1.5-py3-none-any.whl

Download URL agent_watchdog-0.1.5-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22b1d93cac8764d1734d9e04e91355f390a960ae5d72e73909415e3b94a7028a
BLAKE2b-256 checksum
How to use checksums
e35d07bf01b56e971b3183b7e814ba7430cc8a10a9a5a5ddc6262cb2d9e70148
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for agent-watchdog 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page