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

Fixed misordering of create_agent by adding named parameters (#208)

Howard Gil5b13f9b3eeda
diff --git a/agentops/agent.py b/agentops/agent.py
index b0611681..0e070b62 100644
--- a/agentops/agent.py
+++ b/agentops/agent.py
@@ -18,17 +18,17 @@ def track_agent(name: Union[str, None] = None):
try:
original_init(self, *args, **kwargs)
self.agent_ops_agent_id = str(uuid4())
- Client().create_agent(self.agent_ops_agent_id, self.agent_ops_agent_name)
+ Client().create_agent(name=self.agent_ops_agent_name, agent_id=self.agent_ops_agent_id)
except AttributeError as e:
logger.warning("AgentOps failed to track an agent. This often happens if agentops.init() was not "
- "called before initializing an agent with the @track_agent decorator.")
+ "called before initializing an agent with the @track_agent decorator.")
raise e
obj.__init__ = new_init
elif isfunction(obj):
obj.agent_ops_agent_id = str(uuid4())
- Client().create_agent(obj.agent_ops_agent_id, obj.agent_ops_agent_name)
+ Client().create_agent(name=obj.agent_ops_agent_name, agent_id=obj.agent_ops_agent_id)
else:
raise Exception("Invalid input, 'obj' must be a class or a function")
diff --git a/agentops/client.py b/agentops/client.py
index 049b49db..2d8abd96 100644
--- a/agentops/client.py
+++ b/agentops/client.py
@@ -333,7 +333,7 @@ class Client(metaclass=MetaClient):
if agent_id is None:
agent_id = str(uuid.uuid4())
if self._worker:
- self._worker.create_agent(agent_id, name)
+ self._worker.create_agent(name=name, agent_id=agent_id)
return agent_id
def _handle_unclean_exits(self):