With OpenClaw installed, it's time to connect your AI agents. OpenClaw uses a trace-based model — every agent action is captured as a span within a trace, similar to distributed tracing in microservices.
For supported frameworks, a single line suffices:
from openclaw import OpenClaw, auto_instrument
oc = OpenClaw(api_key="oc_live_...")
auto_instrument(oc, framework="langchain") # or "crewai", "autogen", "agentos"
Auto-instrumentation automatically captures:
For custom agents or finer control:
with oc.trace("customer-support-agent") as trace:
trace.set_metadata({"customer_id": "12345", "channel": "chat"})
with trace.span("intent-classification") as span:
span.set_input(user_message)
intent = classify_intent(user_message)
span.set_output(intent)
with trace.span("response-generation") as span:
span.set_model("gpt-4o")
response = generate_response(intent, context)
span.set_output(response)
span.set_tokens(input=245, output=189)
An OpenClaw trace maps the complete lifecycle of an agent interaction:
Trace: customer-support-agent (ID: tr_abc123)
├── Span: intent-classification (12ms)
├── Span: knowledge-retrieval (145ms)
│ ├── Span: vector-search (89ms)
│ └── Span: reranking (52ms)
├── Span: response-generation (1,340ms)
│ ├── Span: llm-call (1,200ms)
│ └── Span: guardrail-check (140ms)
└── Span: response-delivery (8ms)
Tags enable precise filtering and grouping:
| Tag Category | Examples | Purpose |
|---|---|---|
| Environment | production, staging, dev | Environment separation |
| Team | support, sales, ops | Cost allocation |
| Agent version | v2.1.0, v2.2.0-beta | Version comparison |
| Customer | customer_id, tenant_id | Multi-tenancy |
| Compliance | risk_level, pii_detected | Governance tracking |
As soon as traces flow in, the live dashboard shows:
Tip: Start with auto-instrumentation and switch to manual spans only where you need deeper insights. Excessive tracing creates noise and increases storage costs.