debug: trace full tool execution
This commit is contained in:
1 parent
658f7cd580
commit
2253fbad13
1 file changed
+6
@@ -333,6 +333,7 @@ For other questions, just answer normally without tools."""
|
||||
|
||||
def _execute_tool(self, tool_call: ToolCall) -> Any:
|
||||
"""Esegui un singolo tool"""
|
||||
print(f"_execute_tool: name={tool_call.name}, args={tool_call.arguments}")
|
||||
if tool_call.name not in self.tools:
|
||||
available = ", ".join(self.tools.keys())
|
||||
return {
|
||||
@@ -349,6 +350,8 @@ For other questions, just answer normally without tools."""
|
||||
else:
|
||||
result = tool.invoke({})
|
||||
|
||||
print(f"_execute_tool: got result type={type(result)}, value={result}")
|
||||
|
||||
# Converti result in stringa per il modello
|
||||
if result is None:
|
||||
return {"result": "Tool executed successfully"}
|
||||
@@ -358,6 +361,7 @@ For other questions, just answer normally without tools."""
|
||||
return {"result": str(result)}
|
||||
|
||||
except Exception as e:
|
||||
print(f"_execute_tool: exception={e}")
|
||||
return {"error": str(e)}
|
||||
|
||||
def _format_tool_result(self, tool_call: ToolCall, result: Any) -> str:
|
||||
@@ -413,6 +417,7 @@ For other questions, just answer normally without tools."""
|
||||
print(f"OLLAMA_AGENT: detected_tool={detected_tool}")
|
||||
if detected_tool:
|
||||
result = self._execute_tool(detected_tool)
|
||||
print(f"OLLAMA_AGENT: result type={type(result)}, value={result}")
|
||||
|
||||
# Format result as a clean response
|
||||
response_text = ""
|
||||
@@ -433,6 +438,7 @@ For other questions, just answer normally without tools."""
|
||||
except Exception as e:
|
||||
response_text = str(result) if not response_text else response_text
|
||||
|
||||
print(f"OLLAMA_AGENT: response_text={response_text}")
|
||||
return {"messages": self.messages, "response": response_text}
|
||||
|
||||
# Loop principale: risposta -> parse tools -> esegui -> ripeti
|
||||
|
||||
Reference in new issue
Block a user