Refactor tool execution logic to improve handling of callable tools and None responses

pull/923/head
harshalmore31 6 days ago
parent e5a5eaecea
commit 57eff390a5

@ -1080,25 +1080,24 @@ class Agent:
# Print # Print
self.pretty_print(response, loop_count) self.pretty_print(response, loop_count)
# Handle tools # Check and execute callable tools
if ( if exists(self.tools):
hasattr(self, "tool_struct") if (
and self.tool_struct is not None self.tool_struct is not None
and self.output_raw_json_from_tool_call and self.output_raw_json_from_tool_call is True
is True ):
): response = response
response = response
else:
# Only execute tools if response is not None
if response is not None:
self.execute_tools(
response=response,
loop_count=loop_count,
)
else: else:
logger.warning( # Only execute tools if response is not None
f"LLM returned None response in loop {loop_count}, skipping tool execution" if response is not None:
) self.execute_tools(
response=response,
loop_count=loop_count,
)
else:
logger.warning(
f"LLM returned None response in loop {loop_count}, skipping tool execution"
)
# Handle MCP tools # Handle MCP tools
if ( if (

Loading…
Cancel
Save