{"id":4870,"library":"agentops","title":"AgentOps","description":"AgentOps is an observability and DevTool platform for AI agents, providing tools to trace, debug, and deploy reliable AI agents and LLM applications. It offers features like session replays, LLM cost tracking, failure detection, tool usage statistics, and benchmarking, helping engineers move AI agents from prototype to production by ensuring they operate safely, efficiently, and transparently.","status":"active","version":"0.4.21","language":"en","source_language":"en","source_url":"https://github.com/AgentOps-AI/agentops","tags":["AI","observability","LLM","agentic AI","monitoring","debugging","devtools","cost tracking","production AI"],"install":[{"cmd":"pip install agentops python-dotenv","lang":"bash","label":"Install with dotenv (recommended)"}],"dependencies":[{"reason":"Recommended for managing API keys as environment variables.","package":"python-dotenv","optional":true},{"reason":"Optional dependency for LangChain integration and advanced features.","package":"langchain","optional":true},{"reason":"Optional dependency for LlamaIndex integration and advanced features.","package":"llama-index","optional":true},{"reason":"Required for AG2 (formerly AutoGen) integration.","package":"ag2","optional":true}],"imports":[{"note":"Initializes the AgentOps SDK for auto-instrumentation.","symbol":"init","correct":"from agentops import init"},{"note":"Decorator to track agent logic and group downstream operations.","symbol":"agent","correct":"from agentops.sdk.decorators import agent"},{"note":"Decorator to instrument any function as a tracked operation/span.","symbol":"operation","correct":"from agentops.sdk.decorators import operation"},{"note":"Decorator for creating custom traces, especially in multi-threaded environments.","symbol":"trace","correct":"from agentops.sdk.decorators import trace"},{"note":"Decorator to track multi-operation workflows.","symbol":"workflow","correct":"from agentops.sdk.decorators import workflow"},{"note":"Manually ends the current AgentOps session.","symbol":"end_session","correct":"from agentops import end_session"}],"quickstart":{"code":"import agentops\nimport os\nfrom dotenv import load_dotenv\n\n# Load environment variables (recommended for API keys)\nload_dotenv()\n\n# Initialize AgentOps\n# The API key can be passed directly or set as an environment variable AGENTOPS_API_KEY\n# Get your API key from the AgentOps Dashboard (app.agentops.ai)\nAGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\", \"\")\nagentops.init(AGENTOPS_API_KEY)\n\nprint(\"AgentOps initialized! Any supported LLM or agent framework calls will now be tracked.\")\n\n# Example with an OpenAI call (if openai is installed and configured)\n# from openai import OpenAI\n# client = OpenAI()\n# completion = client.chat.completions.create(\n#     model=\"gpt-3.5-turbo\",\n#     messages=[\n#         {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}, \n#         {\"role\": \"user\", \"content\": \"Hello!\"}\n#     ]\n# )\n# print(completion.choices.message.content)\n\n# It's good practice to explicitly end the session, especially for single-run scripts.\nagentops.end_session('Success')\nprint(\"AgentOps session ended.\")","lang":"python","description":"This quickstart demonstrates the minimal setup for AgentOps. After installation, initialize AgentOps with your API key (preferably from an environment variable). This enables automatic instrumentation of supported LLM and agent framework calls. Remember to call `load_dotenv()` before `agentops.init()` if you're using a `.env` file."},"warnings":[{"fix":"Refer to the official changelog and documentation for each new minor version for specific migration guides and updated integration patterns. Ensure your environment dependencies are compatible with the AgentOps version used.","message":"The AgentOps SDK is in active development (0.x versions), and its API surface, internal architecture, and integration points (e.g., AutoGen to AG2 migration in 0.4.19) can evolve rapidly. This may necessitate updates to your code when upgrading versions.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Set the `AGENTOPS_API_KEY` environment variable (e.g., `export AGENTOPS_API_KEY=\"your_key\"` or in a `.env` file) or pass it directly to `agentops.init(api_key=\"your_key\")`. Always call `load_dotenv()` early in your script if you rely on a `.env` file.","message":"Failing to correctly configure the `AGENTOPS_API_KEY` (either via environment variable or directly in `agentops.init()`) will prevent data from being sent to the AgentOps dashboard. If using a `.env` file, ensure `python-dotenv.load_dotenv()` is called *before* `agentops.init()`.","severity":"gotcha","affected_versions":"All"},{"fix":"For deeper visibility into custom agent logic, specific function calls, or multi-step workflows, import and apply the relevant decorators (e.g., `@operation` on functions, `@agent` on agent classes) to your code. Refer to the 'Beyond Automatic Instrumentation: Decorators' section in the documentation.","message":"While `agentops.init()` provides automatic instrumentation for many popular LLM and agent frameworks, achieving finer-grained control and tracking custom operations, agents, or tools requires explicit use of decorators like `@agent`, `@operation`, `@trace`, and `@tool` from `agentops.sdk.decorators`. Auto-instrumentation provides a good starting point, but detailed insights often need manual tagging.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure `agentops.end_session()` is called at the logical end of your agent's execution path. Consider using `try...finally` blocks or the `@trace` decorator for robust session management.","message":"For comprehensive and accurate trace recording, especially in single-run scripts or when explicit lifecycle management is desired, explicitly calling `agentops.end_session()` is crucial to mark the completion of an agent's run. While `agentops.init()` can auto-start a session, auto-ending might not always capture the full lifecycle details without explicit calls or decorator usage.","severity":"gotcha","affected_versions":"All"},{"fix":"Integrate AgentOps with a broader AgentOps framework that includes robust testing, evaluation harnesses, version control for prompts/configs, and defined policies for agent behavior and tool usage. Use AgentOps metrics to inform these design choices and detect anomalies proactively.","message":"Deploying AI agents introduces unique operational challenges (e.g., non-deterministic behavior, infinite loops, tool hallucinations, agent drift) that extend beyond traditional software or ML monitoring. AgentOps helps address these with observability, but developers must still design agents with robust guardrails, controlled tool access, continuous evaluation, and human oversight in mind for production readiness.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}