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
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
Implementation Bugs (#115)
Braelyn Boynton6894dfc3e778
diff --git a/agentops/agent.py b/agentops/agent.pyindex 44f0f9cd..043c81e6 100644--- a/agentops/agent.py+++ b/agentops/agent.py@@ -3,25 +3,26 @@ from agentops import Clientfrom inspect import isclass, isfunction-def track_agent(name: str | None):+def track_agent(name: str | None = None):def decorator(obj):- obj._agent_ops_agent_name = name or obj.__name__+ if name:+ obj.agent_ops_agent_name = nameif isclass(obj):original_init = obj.__init__def new_init(self, *args, **kwargs):- self._agent_ops_agent_id = uuid4()- ao_client = Client()- ao_client.create_agent(self._agent_ops_agent_id, self._agent_ops_agent_name)original_init(self, *args, **kwargs)+ self.agent_ops_agent_id = uuid4()+ ao_client = Client()+ ao_client.create_agent(self.agent_ops_agent_id, self.agent_ops_agent_name)obj.__init__ = new_initelif isfunction(obj):- obj._agent_ops_agent_id = uuid4()+ obj.agent_ops_agent_id = uuid4()ao_client = Client()- ao_client.create_agent(obj._agent_ops_agent_id, obj._agent_ops_agent_name)+ ao_client.create_agent(obj.agent_ops_agent_id, obj.agent_ops_agent_name)else:raise Exception("Invalid input, 'obj' must be a class or a function")diff --git a/agentops/client.py b/agentops/client.pyindex dd95ff78..abde272d 100644--- a/agentops/client.py+++ b/agentops/client.py@@ -224,7 +224,7 @@ class Client(metaclass=MetaClient):video (str, optional): The video screen recording of the session"""if self._session is None or self._session.has_ended:- return logging.warn("AgentOps: Cannot end session - no current session")+ return logging.warning("AgentOps: Cannot end session - no current session")self._session.video = videoself._session.end_session(end_state, end_state_reason)diff --git a/agentops/event.py b/agentops/event.pyindex 6688b4c8..98ce259d 100644--- a/agentops/event.py+++ b/agentops/event.py@@ -10,7 +10,6 @@ from typing import List, Optionalfrom .helpers import get_ISO_timefrom .enums import EventType, Models, LLMMessageFormatfrom uuid import UUID, uuid4-import logging@dataclassdiff --git a/agentops/helpers.py b/agentops/helpers.pyindex 282bd2fa..409889f2 100644--- a/agentops/helpers.py+++ b/agentops/helpers.py@@ -84,12 +84,21 @@ def check_call_stack_for_agent_id() -> str | None:# We stop looking up the stack at main because after that we see global variablesif var == "__main__":return- if hasattr(var, '_agent_ops_agent_id') and getattr(var, '_agent_ops_agent_id'):- logging.debug('LLM call from agent named: ' + getattr(var, '_agent_ops_agent_name'))- return getattr(var, '_agent_ops_agent_id')+ if hasattr(var, 'agent_ops_agent_id') and getattr(var, 'agent_ops_agent_id'):+ logging.debug('LLM call from agent named: ' + getattr(var, 'agent_ops_agent_name'))+ return getattr(var, 'agent_ops_agent_id')return None-++def get_agentops_version():+ try:+ pkg_version = version("agentops")+ return pkg_version+ except Exception as e:+ logging.warning(f"Error reading package version: {e}")+ return None++# Function decorator that prints function name and its arguments to the console for debug purposes# Example output:# <AGENTOPS_DEBUG_OUTPUT>@@ -127,13 +136,3 @@ def debug_print_function_params(func):return func(self, *args, **kwargs)return wrapper---def get_agentops_version():- try:- pkg_version = version("agentops")- return pkg_version- except Exception as e:- print(f"Error reading package version: {e}")- return None-diff --git a/agentops/host_env.py b/agentops/host_env.pyindex 92afbcff..42974a43 100644--- a/agentops/host_env.py+++ b/agentops/host_env.py@@ -3,6 +3,7 @@ import psutilimport socketfrom .helpers import get_agentops_version+def get_sdk_details():return {"AgentOps SDK Version": get_agentops_version(),@@ -61,12 +62,3 @@ def get_host_env():"RAM": get_ram_details(),"Disk": get_disk_details(),}---if __name__ == "__main__":- print("Gathering system information...")- print("SDK Details:", get_sdk_details())- print("OS Details:", get_os_details())- print("CPU Details:", get_cpu_details())- print("RAM Details:", get_ram_details())- print("Disk Details:", get_disk_details())diff --git a/agentops/http_client.py b/agentops/http_client.pyindex b6bacac4..323e0d47 100644--- a/agentops/http_client.py+++ b/agentops/http_client.py@@ -78,7 +78,7 @@ class HttpClient:except requests.exceptions.Timeout:result.code = 408result.status = HttpStatus.TIMEOUT- logging.warn(+ logging.warning('AgentOps: Could not post data - connection timed out')except requests.exceptions.HTTPError as e:try: