Skip to content

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

check ao version and warn for update (#326)

Braelyn Boynton4fe5b3759634
diff --git a/agentops/__init__.py b/agentops/__init__.py
index 54ca039b..24fd1cc3 100755
--- a/agentops/__init__.py
+++ b/agentops/__init__.py
@@ -5,6 +5,7 @@ from typing import Optional, List, Union
from .client import Client
from .event import Event, ActionEvent, LLMEvent, ToolEvent, ErrorEvent
from .decorators import record_function, track_agent
+from .helpers import check_agentops_update
from .log_config import logger
from .session import Session
@@ -61,6 +62,8 @@ def init(
Attributes:
"""
Client().unsuppress_logs()
+ check_agentops_update()
+
if Client().is_initialized:
return logger.warning("AgentOps has already been initialized")
diff --git a/agentops/helpers.py b/agentops/helpers.py
index 22eece62..bd95e868 100644
--- a/agentops/helpers.py
+++ b/agentops/helpers.py
@@ -8,6 +8,7 @@ from typing import Union
from .log_config import logger
from uuid import UUID
from importlib.metadata import version
+import subprocess
ao_instances = {}
@@ -148,6 +149,19 @@ def get_agentops_version():
return None
+def check_agentops_update():
+ result = subprocess.run(
+ ["pip", "list", "--outdated"], capture_output=True, text=True
+ )
+ lines = result.stdout.splitlines()[2:] # Skip the header lines
+ for line in lines:
+ parts = line.split()
+ if len(parts) > 0 and parts[0] == "agentops":
+ logger.warning(
+ f" WARNING: {parts[0]} is out of date. Please update with the command: 'pip install --upgrade agentops'"
+ )
+
+
# Function decorator that prints function name and its arguments to the console for debug purposes
# Example output:
# <AGENTOPS_DEBUG_OUTPUT>