Skip to content

Commit

Permalink
Fixed misordering of create_agent by adding named parameters (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieG authored May 15, 2024
1 parent cf1ca9f commit 5b13f9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions agentops/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def new_init(self, *args, **kwargs):
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")
Expand Down
2 changes: 1 addition & 1 deletion agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def create_agent(self, name: str, agent_id: Optional[str] = None) -> str:
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):
Expand Down

0 comments on commit 5b13f9b

Please sign in to comment.