heartbeat()
Send a single heartbeat to confirm the agent is alive. Called automatically bystart_heartbeat(), but you can also call it manually.
last_heartbeat timestamp and keeps its status as healthy. If no heartbeat is received for 2 minutes, the agent status changes to degraded. After 5 minutes, it changes to down.
start_heartbeat()
Start a background thread that sends heartbeats at a regular interval.heartbeat_interval constructor parameter (default: 30 seconds). The background thread is a daemon thread — it stops automatically when your process exits.
track_usage()
Report a single LLM usage event — tokens consumed, model used, and optional cost.LLM provider:
openai, anthropic, google, nvidia, bedrockModel identifier (e.g.,
gpt-4o, claude-sonnet-4-20250514)Number of input/prompt tokens
Number of output/completion tokens
Type of request (e.g.,
chat.completions, embeddings)Explicit cost in USD. If omitted, MeshAI calculates cost based on model pricing tables.
Auto-Tracking Wrappers
Instead of callingtrack_usage() manually, use framework wrappers that capture usage automatically:

