Skip to main content

Monitor your AI agents. Heartbeat watchdog, loop detection, cost tracking.

Project description

ClevAgent SDK

Monitor your AI agents in 2 lines of code.

Document role:

  • package-level usage guide for the Python SDK
  • focuses on installation and client-side integration
  • broader product policy and accepted cross-system contracts belong in the repo root docs
import clevagent
clevagent.init(api_key=os.environ["CLEVAGENT_API_KEY"], agent="my-agent")

That's it. ClevAgent sends heartbeats every 60 seconds. If your agent goes silent, you get an alert.

Install

pip install clevagent

Features

  • Heartbeat watchdog — detect dead agents automatically
  • Loop detection — catch runaway tool-call loops
  • Cost tracking — auto-capture for OpenAI/Anthropic SDKs; manual log_cost() for others
  • Auto-restart — restart Docker containers when agents die (requires container_id)
  • Crash capture — send last error as an emergency heartbeat on unhandled exceptions

Quick Start

import os
import clevagent

clevagent.init(
    api_key=os.environ["CLEVAGENT_API_KEY"],
    agent="my-trading-bot",        # agent name (auto-created on first ping)
    interval=60,                   # heartbeat interval in seconds
    auto_cost=True,                # auto-capture OpenAI/Anthropic usage
)

# --- your agent code runs here ---

# Optional: manual ping with context
clevagent.ping(
    status="ok",
    message="Processed 42 signals",
    iteration_count=42,
)

# Optional: manual cost logging (for other SDKs)
clevagent.log_cost(tokens=1500, cost_usd=0.0023)

Cost Tracking

Method SDKs
Auto ✅ OpenAI (gpt-4o, gpt-4o-mini, etc.), Anthropic (claude-3, claude-4)
Manual 📝 Any other SDK — use clevagent.log_cost(tokens=N, cost_usd=X)
Not supported ❌ Streaming responses (use manual for those)

Auto-Restart

Auto-restart requires Docker and a container_id configured in the ClevAgent dashboard. For non-Docker deployments (systemd, launchd, process), use clevagent-runner for auto-restart support. See https://clevagent.io/docs#runner

Links

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

clevagent-0.5.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

clevagent-0.5.0-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file clevagent-0.5.0.tar.gz.

File metadata

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

File hashes

Hashes for clevagent-0.5.0.tar.gz
Algorithm Hash digest
SHA256 073846ad2c0c1f54575f8f9b9000a52436a1cc12b4f7cc443ee81a18a3e0beff
MD5 1c450612acdbbd54a69c35556d162982
BLAKE2b-256 6bac140431ee6aab0a6c15135c225f643f0751f67903edf97e816f04dc6e1182

See more details on using hashes here.

File details

Details for the file clevagent-0.5.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for clevagent-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9fad70f998b5821aa95a3c9812b5163686fc1748d7e0a8f5385f5aeb4de0ffe
MD5 640a9df356692f6a2bd28550a63a9964
BLAKE2b-256 75018aa9e0e763209d2af837bdce2c5cc9083ca244d8d2819d3ba641ecc03a52

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