fix: non passare argomenti vuoti a tool senza parametri

This commit is contained in:
opencode committed 2026-03-23 17:36:50 +01:00
1 parent 52925d80ce
commit 7fd3bfd26b
1 file changed
+6 -4
+6 -4
View File
@@ -342,7 +342,12 @@ For other questions, just answer normally without tools."""
try:
tool = self.tools[tool_call.name]
result = tool.invoke(tool_call.arguments)
# Per tool senza argomenti, non passare arguments
if tool_call.arguments:
result = tool.invoke(tool_call.arguments)
else:
result = tool.invoke({})
# Converti result in stringa per il modello
if result is None:
@@ -403,10 +408,8 @@ For other questions, just answer normally without tools."""
# Try to detect intent directly first
detected_tool = self._detect_intent(user_content)
print(f"DEBUG: user_content='{user_content}', detected={detected_tool}")
if detected_tool:
result = self._execute_tool(detected_tool)
print(f"DEBUG: result={result}")
# Format result as a clean response
response_text = ""
@@ -427,7 +430,6 @@ 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"DEBUG: response_text={response_text}")
return {"messages": self.messages, "response": response_text}
# Loop principale: risposta -> parse tools -> esegui -> ripeti