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

Metadata

Release files for kevlar-agent 0.1.0

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

Source distribution (sdist)

Source distribution for kevlar-agent 0.1.0
File Size Uploaded Provenance Actions
kevlar_agent-0.1.0.tar.gz 15.8 kB Without provenance Details for kevlar_agent-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kevlar-agent 0.1.0
File Interpreter ABI Platform Actions
kevlar_agent-0.1.0-py3-none-any.whl Python 3 none any Details for kevlar_agent-0.1.0-py3-none-any.whl

Total release size: 29.5 kB

Release files / kevlar_agent-0.1.0.tar.gz

Download URL kevlar_agent-0.1.0.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6ab6cba11d578fc64e9c5c8a761442cc49f31a8f4415eb4f52058de349dee373
BLAKE2b-256 checksum
How to use checksums
b46d9977f08a724ea062505bbee4bb7ec80b8f70cd1e71409a6041524882eadf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / kevlar_agent-0.1.0-py3-none-any.whl

Download URL kevlar_agent-0.1.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4ca5a210f84fd9c1be02aa4a858755e77c1d508cb64ce5525adf6d8a3affca7
BLAKE2b-256 checksum
How to use checksums
9ac5874da00c6946d992bfa70e361bd7731d9a94a1a9862dcb1693d8cf74df0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for kevlar-agent 0.1.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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