Monitoring Agent Health & Performance in OpenClaw
Monitoring Agent Health & Performance in OpenClaw

Let's be honest about something: most people running AI agents in production have no idea what those agents are actually doing.
They set up an agent, it works great in testing, they ship it, and then two weeks later they get a surprise API bill or a Slack message from an angry user saying the bot told them something completely wrong. Sound familiar? Yeah, you're not alone.
The dirty secret of AI agents is that building them is the easy part. Knowing whether they're working correctly after you deploy themβthat's where most people completely fall apart. And it's not because they're lazy or incompetent. It's because the monitoring story for AI agents has been, frankly, terrible. Fragmented tools, invasive code changes, dashboards that require a PhD to interpret.
OpenClaw changes this, and I want to walk you through exactly how to set up proper agent monitoring so you never get blindsided again.
The Problem Nobody Warns You About
Here's what typically happens. You build an agent in OpenClaw. You test it locally. It handles your five test queries beautifully. You deploy it. Then reality hits.
Real users don't behave like your test cases. They ask weird questions. They send malformed input. They trigger edge cases you never imagined. And your agent? It might handle them fine. Or it might enter an infinite loop burning through tokens at 3 AM. Or it might confidently hallucinate an answer that gets your company in trouble. Or it might silently fail, returning a generic "I can help with that!" message while doing absolutely nothing useful behind the scenes.
The fundamental issue is observability. In traditional software, you've got mature logging, metrics, and tracing. With AI agents, you're dealing with non-deterministic systems that make decisions, call tools, and chain together reasoning steps in ways that are inherently unpredictable. Standard application monitoring doesn't cut it.
I've seen people cobble together four or five different toolsβLangfuse for traces, W&B for experiments, Sentry for errors, a spreadsheet for costsβand still miss critical failures. It's not sustainable.
Setting Up Monitoring in OpenClaw: The Practical Guide
Enough preamble. Let's get into it.
Step 1: Instrument Your Agents
The first thing you need is visibility into what your agent is doing on every single run. OpenClaw makes this almost embarrassingly easy with automatic instrumentation.
pip install openclaw
openclaw init
Then in your agent code:
from openclaw import monitor
monitor.auto_instrument()
# Your existing agent code doesn't change at all
agent = Agent(llm=llm, tools=tools)
result = agent.run("What's the current status of order #4521?")
# ^ This is now fully traced automatically
That's it. No wrapping every function in decorators. No rewriting your architecture. auto_instrument() hooks into the execution layer and captures everything: LLM calls, tool invocations, token counts, latencies, errors, and the full chain of reasoning your agent went through.
If you want more granular control (and you will, eventually), you can use the decorator approach:
from openclaw import monitor_agent
@monitor_agent(name="order_lookup_agent")
async def handle_order_query(query: str):
research = await agent.search_orders(query)
response = await agent.generate_response(research)
return response
This tags everything under a named agent, making it trivial to filter and compare later.
Step 2: Know Your Token Spend in Real Time
This is the one that saves people real money. I cannot tell you how many forum posts I've seen that boil down to "my agent burned $400 overnight and I didn't notice." It's practically a rite of passage at this point.
OpenClaw tracks token consumption per step, per tool, per agent, in real time. Here's what that looks like on the dashboard:
βββββββββββββββββββββββββββββββββββββββ
β Token Usage β order_lookup_agent β
β (Last Hour) β
βββββββββββββββββββββββββββββββββββββββ€
β Step 1: Query Parsing β 245 β
β Step 2: Database Lookup β 112 β
β Step 3: Context Assembly β 1,834 β
β Step 4: Response Gen β 678 β
β β οΈ LOOP: Step 3 repeated 4x β
β β
β Total Tokens: 8,921 β
β Estimated Cost: $0.31 β
βββββββββββββββββββββββββββββββββββββββ
See that loop warning? That's OpenClaw detecting that your agent repeated the same step four times. Maybe it was getting a malformed response from a tool and retrying without any backoff. Maybe the context window was filling up and the agent kept trying to "fix" things. Either way, you know about it now instead of when your invoice arrives.
You can also set up budget caps directly:
from openclaw import budget
budget.set_limit(
agent="order_lookup_agent",
max_tokens_per_run=15000,
max_cost_per_hour=10.00,
on_exceed="halt_and_alert"
)
When the limit hits, the agent stops and you get notified. No more runaway costs.
Step 3: Trace Every Decision Your Agent Makes
This is where things get genuinely powerful, and where OpenClaw separates itself from duct-taping together generic monitoring tools.
Every agent session gets a full trace. Not just "input in, output out," but every intermediate step, decision, tool call, and reasoning chain. When something goes wrong, you don't have to guess. You replay it.
# Pull up any session trace
openclaw.traces.view(session_id="sess_8a3f2b")
And you see something like this:
Trace: sess_8a3f2b
βββββββββββββββββββββββββββββ
β User query received: "Why was I charged twice?"
β Intent classified: billing_dispute (confidence: 0.94)
β Tool: fetch_user_billing(user_id="u_291") β Success (1.2s)
ββ Found 2 charges on 2026-01-15
β Tool: check_refund_status(charge_id="ch_882") β Success (0.8s)
ββ Refund already processed, pending bank clearance
β Agent reasoning: "User has duplicate charge but refund is in progress"
β Response generated: Explained refund timeline
β User feedback: π
Total time: 4.3s | Tokens: 2,104 | Cost: $0.07
Now compare that to a failed session:
Trace: sess_9c4d1e
βββββββββββββββββββββββββββββ
β User query received: "Why was I charged twice?"
β Intent classified: billing_dispute (confidence: 0.91)
β Tool: fetch_user_billing(user_id="u_445") β TIMEOUT (30s)
β Agent retry: fetch_user_billing attempt 2 β TIMEOUT (30s)
β Agent fallback: Generated response without billing data
β οΈ Response: "I apologize for the inconvenience. Let me look into that."
ββ Note: Generic response, no actual resolution provided
β User feedback: π
Total time: 64.2s | Tokens: 1,456 | Cost: $0.05
Now you know exactly what happened. The billing API was timing out, the agent had no good fallback, and the user got a useless non-answer. You can fix the root cause instead of playing whack-a-mole with symptoms.
The replay feature is especially clutch:
openclaw replay sess_9c4d1e --step-by-step
This lets you re-run the exact same session with modified conditions. Swap in a faster API endpoint, change the timeout, adjust the fallback promptβand see if the outcome improves without waiting for the same failure to happen again in production.
Step 4: Set Up Alerts That Actually Matter
Dashboards are great. Dashboards you have to remember to check are useless. You need alerts that come to you.
openclaw.alerts.configure(
channels=["slack", "email"],
rules=[
{
"name": "Cost Anomaly",
"condition": "hourly_cost > 2x rolling_average",
"severity": "high",
"action": "notify_team"
},
{
"name": "Error Spike",
"condition": "error_rate > 5% for 10m",
"severity": "critical",
"action": "page_oncall"
},
{
"name": "Quality Drop",
"condition": "eval_score < 0.85 for 1h",
"severity": "medium",
"action": "create_ticket"
},
{
"name": "Latency Regression",
"condition": "p95_latency > 12s for 5m",
"severity": "high",
"action": "notify_team"
}
]
)
The "2x rolling average" cost alert is particularly important. It catches anomalies relative to your normal usage, so it works whether you're spending $5/day or $500/day. And the quality drop alert ties into the evaluation system, which we'll get to next.
Step 5: Measure Quality, Not Just Uptime
Here's where most people stop. They set up monitoring for errors and costs and call it a day. But the most insidious agent failures aren't errorsβthey're wrong answers delivered confidently.
Your agent can return a 200 OK, use a reasonable number of tokens, respond in under 3 seconds, and still tell a user something completely fabricated. Traditional monitoring won't catch that. You need evaluation.
from openclaw import evaluators
@evaluators.register
def check_factual_accuracy(response: str, context: str) -> float:
"""Scores whether the response is supported by the retrieved context"""
return accuracy_score # 0.0 to 1.0
@evaluators.register
def check_hallucination(response: str, sources: list) -> bool:
"""Flags responses containing claims not in source material"""
return has_unsupported_claims
@evaluators.register
def check_completeness(response: str, query: str) -> float:
"""Did the response actually answer what was asked?"""
return completeness_score
# Run evaluations on sampled production traffic
openclaw.evaluate(
agent="customer_support",
sample_rate=0.1, # Evaluate 10% of responses
evaluators=["factual_accuracy", "hallucination", "completeness"]
)
Running evaluations on 10% of traffic gives you a statistically meaningful picture without doubling your compute costs. The results feed directly into your dashboard:
Quality Metrics β customer_support (7 days)
βββββββββββββββββββββββββββββββββββββββββββ
β Factual Accuracy: 92.3% β (was 94.1%) β π΄
β No Hallucinations: 88.7% β (was 86.2%) β π’
β Response Complete: 91.4% β (was 93.8%) β π‘
β Professional Tone: 96.1% β (stable) β π’
β β
β Flagged Examples: β
β β’ sess_abc123: Claimed refund processed β
β (actually still pending) β
β β’ sess_def456: Recommended a product β
β that's been discontinued β
βββββββββββββββββββββββββββββββββββββββββββ
And those flagged examples link directly to the full session trace, so you can see exactly how the agent arrived at the wrong answer and fix it at the source.
Step 6: Monitor Multi-Agent Workflows
If you're running multiple agents that hand off work to each otherβand increasingly, people areβdebugging gets exponentially harder without proper tooling. When a pipeline of four agents produces a bad result, which agent is at fault?
from openclaw import track_workflow
@track_workflow(name="content_pipeline")
async def create_content(topic: str):
research = await researcher_agent.gather_info(topic)
outline = await planner_agent.create_outline(research)
draft = await writer_agent.write(outline)
final = await editor_agent.review_and_polish(draft)
return final
OpenClaw visualizes the entire flow:
content_pipeline β Run #4,521
ββββββββββββββββββββββββββββ
[Researcher] 3.2s, 1.2k tokens β
ββ web_search: 3 calls
ββ summarize: 1 call
β
[Planner] 2.1s, 0.8k tokens β
ββ Generated 5-section outline
β
[Writer] 8.4s, 4.5k tokens β
ββ 1,200 word draft
β
[Editor] 5.1s, 3.2k tokens β
ββ ERROR: Context window exceeded
ββ Input was 12,000 tokens (limit: 8,192)
Bottleneck: Writer (44% of total time)
Root cause: Writer output too long for Editor's model context
You can see immediately that the writer agent produced output that was too long for the editor's context window. Without this visibility, you'd just see a failed pipeline and start guessing.
The Shortcut: Skip the Setup Grind
Now, everything I've described above? You can configure all of it from scratch. Set up the instrumentation, define your evaluators, configure alerts, build out the dashboards. It works and it's well-documented.
But if I'm being honest, it took me a good weekend to get everything dialed in the first time. The monitoring, the evaluation rules, the alert thresholdsβthere's a lot of config to get right, and the defaults aren't always tuned for common use cases.
If you don't want to set all this up manually, Felix's OpenClaw Starter Pack on Claw Mart includes pre-configured monitoring skills that handle most of what I've covered here. For $29, you get pre-built evaluation templates, alert configurations tuned for common agent patterns, and token budget rules that actually make sense out of the box. I'd have happily paid that to get back my weekend. It's genuinely the fastest way to go from "deployed agent" to "properly monitored deployed agent."
What Good Looks Like
Once you have all of this running, here's what your daily workflow looks like:
Morning: Glance at the OpenClaw dashboard. Green across the board. Move on with your life.
When something breaks: Get a Slack alert with the specific agent, the specific error, and a link to the exact trace showing what happened. Fix it in minutes instead of hours.
Weekly: Review quality metrics. Spot that your agent's accuracy dipped 2% after a prompt change last Tuesday. Roll it back or iterate.
Monthly: Pull cost reports. See that switching one agent from GPT-4 to a tuned smaller model saved $300/month with no quality drop. Feel good about that.
This is the difference between running agents in production and hoping agents work in production.
Next Steps
Here's what I'd do, in order:
- Add
monitor.auto_instrument()to your existing OpenClaw agents. Takes 60 seconds, gives you immediate visibility. - Set up cost alerts. Even basic ones. "Alert me if hourly spend exceeds $X" will save you from the surprise bill scenario.
- Add at least one quality evaluator. Even something simple like checking whether responses are relevant to the query. You'll be shocked at what you find.
- Configure trace retention. Keep at least 7 days of traces so you can investigate issues after the fact.
- Gradually add more evaluators as you learn what failure modes your specific agents have.
You don't have to do everything at once. But you do have to start. Every day your agents run without monitoring is a day you're flying blindβand in my experience, it's only a matter of time before you hit turbulence you didn't see coming.
Stop guessing. Start watching. Your agents (and your wallet) will thank you.