From 2a8cf252a7be81784ec647523a3e4353012cafb2 Mon Sep 17 00:00:00 2001 From: Sambhav Dixit <94298612+sambhavnoobcoder@users.noreply.github.com> Date: Sun, 27 Oct 2024 18:53:50 +0530 Subject: [PATCH] Add Update_tool_usage - update tool usage fn to add and account for tool usage metadata. --- swarms/structs/agent.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index 6c8e5fea..4d800673 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -1948,6 +1948,17 @@ class Agent: # Add step to agent output tracking return self.step_pool.append(step_log) + def update_tool_usage(self, step_id: str, tool_name: str, tool_args: dict, tool_response: Any): + """Update tool usage information for a specific step.""" + for step in self.agent_output.steps: + if step.step_id == step_id: + step.response.tool_calls.append({ + "tool": tool_name, + "arguments": tool_args, + "response": str(tool_response) + }) + break + def _serialize_callable( self, attr_value: Callable ) -> Dict[str, Any]: