AgentOps
Integrate AgentOps observability with PraisonAI agents
AgentOps Integration
AgentOps provides agent monitoring, debugging, and optimization.
Setup
1. Install Dependencies
pip install agentops2. Set Environment Variables
export AGENTOPS_API_KEY=xxx3. Initialize
from praisonai_tools.observability import obs
obs.init(provider="agentops")How Integration Works
- AgentOps is optional: if
pip install agentopshasn’t been run, PraisonAI silently skips session telemetry. - After every agent execution — on both success and failure paths — the wrapper calls
praisonai.observability.hooks.finalize_observability(adapter_name, status=…)from afinallyblock.statusis"Success"when no exception is propagating and"Failure"otherwise (errors,KeyboardInterrupt, cancellation, rate limits). Failures inside the end-session call are logged atWARNINGlevel and never propagate. - Detection happens once at module import via
importlib.util.find_spec("agentops"). Installingagentopsafter the process started will not be picked up — restart the process. - PraisonAI auto-inits AgentOps for you if
AGENTOPS_API_KEYis set in the environment. The init is centralized inpraisonai.observability.hooks.init_observability(framework_tag, tags=...)and is called automatically by the orchestrator before any adapter runs. You can call it yourself from a custom framework adapter’ssetup()hook if you need control over the tags. - AgentOps is now scoped per
ObservabilityRun, so overlapping runs get separate sessions and cross-finalization between them is impossible — see Observability Hooks → Concurrent runs.
Usage
Auto-Instrumentation (Recommended)
from praisonai_tools.observability import obs
from praisonaiagents import Agent
obs.init(provider="agentops")
# Everything is auto-traced!
agent = Agent(
name="Assistant",
instructions="You are a helpful assistant.",
model="gpt-4o-mini",
)
response = agent.chat("Hello!")
print(response)Explicit Tracing (For Fine Control)
from praisonai_tools.observability import obs
from praisonaiagents import Agent
obs.init(provider="agentops", auto_instrument=False)
agent = Agent(
instructions="You are a helpful assistant.",
model="gpt-4o-mini",
)
with obs.trace("session"):
response = agent.chat("Hello!")
print(response)Configuration Options
| Option | Environment Variable | Description |
|---|---|---|
api_key | AGENTOPS_API_KEY | Your AgentOps API key |
tags | – | Default tags for sessions |
auto_start_session | – | Auto-start session (default: True) |
Dashboard
View your agent sessions at app.agentops.ai