# AgentOps Wraps Agent Code in Session and Operation Spans

> AgentOps is a Python SDK that adds observability, LLM cost tracking, and session replay to AI agents built with CrewAI, AG2, the OpenAI Agents SDK, and other frameworks.

**AgentOps-AI/agentops** — Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI

- Repository: https://github.com/AgentOps-AI/agentops
- Website: https://agentops.ai
- Stars: 5,856 · Forks: 636
- Language: Python
- License: MIT
- Published: 2026-09-09 · Updated: 2026-09-09 · Language: en
- Canonical page: https://hysenlabs.com/projects/agentops-ai-agentops

## Wrapping agent code in session, agent, and operation decorators

AgentOps instruments agent code through four decorators rather than one tracing call. @session, imported from agentops.sdk.decorators, wraps the root of a run and creates the top span everything else nests under. @agent wraps a class whose methods represent an agent's behavior. @operation, aliased @task, marks a specific function such as process_data as a tracked step, and @workflow marks a function that chains several operations together. The decorators nest: a class marked @agent can hold a method marked @operation that calls another @operation method, and the resulting spans keep that parent-child structure inside a single @session. Every decorator carries the same four capabilities: input and output recording, exception handling, support for both async and await functions and for generator functions, and custom attributes and names on each span. The mechanism reads like span nesting applied specifically to agent code, without asking a developer to touch a lower-level tracing API directly.

## Installing the SDK and opening a first session

Getting a first session onto the dashboard is a short sequence. Install the package:

```bash
pip install agentops
```

Get an API key from the AgentOps settings page, then wrap the program:

```python
import agentops

# Beginning of your program (i.e. main.py, __init__.py)
agentops.init( < INSERT YOUR API KEY HERE >)

...

# End of program
agentops.end_session('Success')
```

Calling init starts the session, and end_session closes it with a status string, here 'Success'. Once the program runs, the session appears on the AgentOps dashboard at app.agentops.ai; this one call to start and one call to end is the whole integration for a plain Python script with no framework involved.

## Two lines for CrewAI and AG2, a separate package for the OpenAI Agents SDK

CrewAI and AG2 need only an environment variable and a wrapped install to get monitoring. For CrewAI:

```bash
pip install 'crewai[agentops]'
```

Setting AGENTOPS_API_KEY in the environment is the other half of what the project calls a two-line integration; crews then report automatically to the AgentOps dashboard. AG2, the project formerly known as AutoGen, follows the same pattern: set AGENTOPS_API_KEY and call agentops.init in the agent code. The OpenAI Agents SDK integration works differently, as a separate package per language rather than an extras flag. Python:

```bash
pip install openai-agents
```

TypeScript:

```bash
npm install agentops @openai/agents
```

Three integrations, three different installation shapes: an extras bracket for CrewAI, an environment variable and an init call for AG2, and a second package install for the OpenAI Agents SDK in either language.

## Self-hosting the dashboard instead of using app.agentops.ai

Running the dashboard and API locally instead of the hosted app.agentops.ai is a separate setup path, covered in app/README.md rather than in the main install steps. The main instructions do not reproduce those steps, only pointing to that file and to the open source app directory under app/. Self-hosting is listed as one of four key capabilities in the project's own feature table, alongside replay analytics, LLM cost management, and framework integrations, but pip install agentops on its own only wires up the SDK side; the dashboard and API backend are a second, separate service to run and keep updated, not something the pip package brings along.

## A Python 3.9 floor and a version-gated OpenTelemetry pin

Python 3.9 is the floor: pyproject.toml sets requires-python to >=3.9 and lists classifiers for 3.9 through 3.13. The dependency list carries a python-version-gated pin on OpenTelemetry: opentelemetry-sdk is locked to exactly 1.29.0 for python_version<'3.10', while Python 3.10 and newer get opentelemetry-sdk>1.29.0 instead, an unusual split where the exact otel-sdk version installed depends on which interpreter runs it. Other dependency ranges carry their own reasoning as inline comments: packaging is bounded below at 21.0 for Python 3.9 compatibility, httpx is capped below 0.29.0 for what the comment calls legacy module compatibility, and aiohttp is pinned for its async HTTP client functionality. A project already pinning a different opentelemetry-sdk version for Python 3.9 has a concrete conflict to check before adding agentops, not just a generic version bump.

## Nine named authors, a TOS.md file, and a tag that trails the last push

pyproject.toml lists nine named authors: Alex Reibman, Shawn Qiu, Braelyn Boynton, Howard Gil, Constantin Teodorescu, Pratyush Shukla, Travis Dent, Dwij Patel, and Fenil Faldu. The project is MIT licensed, and the repository carries a separate TOS.md file alongside the LICENSE, a terms-of-service document distinct from the code license that points at the hosted app.agentops.ai product rather than the SDK itself. The version pinned in pyproject.toml, 0.4.21, matches the newest tag, published 2025-08-29; the last push to the repository landed on 2026-06-25, ten months later, so whatever changed on main since that tag has not been given a new release number. Installing from PyPI gets 0.4.21; installing from the main branch gets code the project has not tagged.

## Langfuse as the self-hosted-first alternative

Langfuse is the comparison that comes up most for this category: an open source LLM engineering platform that also logs traces, prompts, and cost, but built around self-hosting through Docker containers as its default deployment story, with a hosted cloud version offered as an alternative rather than the primary path. AgentOps runs the opposite way by default: agentops.init sends session data to the hosted app.agentops.ai dashboard, and self-hosting is the option a team opts into by following the separate app/README.md guide. Neither approach is free of a service to operate. Langfuse's default asks a team to run containers; AgentOps's default asks a team to trust a hosted API key, unless it takes on the self-host path instead.

## Conclusion

AgentOps suits a Python team already committed to CrewAI, AG2, or the OpenAI Agents SDK that wants session-level observability with a two-line integration and is comfortable sending data to app.agentops.ai by default. A team that already pins a specific opentelemetry-sdk version should check the python_version-gated pin in pyproject.toml before installing, since it can collide with an existing OpenTelemetry setup, and a team that cannot use a hosted dashboard should budget separate time for the app/README.md self-host path rather than assume pip install agentops covers it.

## FAQ

### What is AgentOps?

An observability and devtool platform for AI agents that helps developers build, evaluate, and monitor agents from prototype to production, with a Python SDK for monitoring, cost tracking, and benchmarking.

### Is AgentOps open source?

The AgentOps app is open source under the MIT license, with its code in the project's app directory; the Python SDK carries the same MIT license.

### How does AgentOps compare to Langfuse?

AgentOps sends session data to its hosted app.agentops.ai dashboard by default, with self-hosting available as a separate setup, while Langfuse is built around self-hosting through Docker containers by default, with a hosted cloud version as the alternative.

## Sources

- [AgentOps-AI/agentops on GitHub](https://github.com/AgentOps-AI/agentops)
- [License: MIT](https://github.com/AgentOps-AI/agentops/blob/main/LICENSE)
- [Project website](https://agentops.ai)
- [README](https://github.com/AgentOps-AI/agentops/blob/main/README.md)
- [Releases](https://github.com/AgentOps-AI/agentops/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/agentops-ai-agentops
