From 2253fbad134e8c4dae3139f2e0b3fab230b9b734 Mon Sep 17 00:00:00 2001 From: opencode Date: Mon, 23 Mar 2026 17:57:16 +0100 Subject: [PATCH] debug: trace full tool execution --- ollama_agent.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ollama_agent.py b/ollama_agent.py index 97b115d..e456290 100644 --- a/ollama_agent.py +++ b/ollama_agent.py @@ -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