Skip to main content

kevlar-agent

Reliability primitives for AI agents that have to survive real use — extracted from a voice AI assistant that has run continuously, unattended, in production. Zero dependencies (an optional one for the watchdog). MIT licensed.

Why this exists / the full case study →

pip install kevlar-agent

The six primitives

from kevlar_agent import dedupe, budget_guard, require_confirmation, silent, AuditLog, Watchdog

dedupe — suppress duplicate calls

@dedupe(window_seconds=5)
def launch_session(device_id: str) -> str:
    return f"launched {device_id}"

An identical call within the window is skipped instead of running the side effect twice — fixes the "model emitted the same tool call twice" class of bug.

budget_guard — independent per-feature spend ceilings

@budget_guard("image_gen", monthly_limit_usd=3.0, cost_usd=0.04)
def generate_clip(prompt: str) -> str:
    ...

Raises BudgetExceeded before the call runs if this specific feature would go over its own monthly ceiling — even if ten other features share the same underlying API key.

require_confirmation — code-enforced consent for irreversible actions

@require_confirmation(lambda amount: f"transfer ${amount}")
def transfer(amount: float) -> str:
    ...

transfer(50)                    # raises ConfirmationRequired
transfer(50, confirmed=True)    # runs

A prompt-only guardrail is a suggestion the model can miss. This one is a gate.

silent — call anything with a hard timeout, from any thread

try:
    token = silent(refresh_oauth_token, timeout_seconds=15)
except SilentTimeout:
    token = None  # fail fast instead of hanging forever

Fixes the "OAuth helper opened a browser and waited for a click that never came, because nobody was watching" class of bug.

AuditLog — structured, append-only call log

log = AuditLog("logs/audit")
log.record("send_email", {"to": "x@example.com"}, result="sent", source="voice")
log.tail(limit=20)

One JSON object per line, one file per day. Never raises.

Watchdog — restart what dies

from kevlar_agent.watchdog import Watched

wd = Watchdog([
    Watched("telegram_bot.py", start=["python", "telegram_bot.py"]),
    Watched("mobile_relay.py", start=["python", "mobile_relay.py"]),
])
wd.run_forever(interval_seconds=300)

Liveness checking uses psutil by default (pip install kevlar-agent[watchdog]), or pass your own is_alive callable.

Development

pip install -e ".[dev]"
pytest

License

MIT

Download files

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

Source Distribution

kevlar_agent-0.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

kevlar_agent-0.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kevlar_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for kevlar_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ab6cba11d578fc64e9c5c8a761442cc49f31a8f4415eb4f52058de349dee373
MD5 08422a7c35a55e70f33b578ec5d10ce1
BLAKE2b-256 b46d9977f08a724ea062505bbee4bb7ec80b8f70cd1e71409a6041524882eadf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kevlar_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for kevlar_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4ca5a210f84fd9c1be02aa4a858755e77c1d508cb64ce5525adf6d8a3affca7
MD5 349646dc3a9d18c04edff72d2adae3c5
BLAKE2b-256 9ac5874da00c6946d992bfa70e361bd7731d9a94a1a9862dcb1693d8cf74df0e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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