feat: add tool execution logging and status display

- Tool server now logs when tools are executed:
  '🔧 TOOL SERVER: Executing read({...})'
  '🔧 TOOL SERVER: read completed (500 chars)'

- LLM server logs remote tool calls:
  '  🔧 Remote tool call: read({...})'
  '   Tool result received (500 chars)'

- Startup now shows tool server status:
  🔧 Tool Server: Remote
     URL: http://192.168.1.5:17616 (auto-detected)
     Mode: Tools executed remotely on tool host

  OR:

  🔧 Tool Server: Local
     Mode: Tools executed on this machine
This commit is contained in:
2026-02-24 14:34:58 +01:00
parent cc66c550e4
commit 9932e34385
3 changed files with 23 additions and 1 deletions
+13
View File
@@ -487,6 +487,19 @@ Examples:
else:
print(f" Peers discovered: 0 (waiting for peers...)")
# Show tool server status
if args.tool_host is not None:
print(f"\n🔧 Tool Server: Remote")
if args.tool_host == "":
local_ip = get_local_ip()
print(f" URL: http://{local_ip}:17616 (auto-detected)")
else:
print(f" URL: {args.tool_host}")
print(f" Mode: Tools executed remotely on tool host")
else:
print(f"\n🔧 Tool Server: Local")
print(f" Mode: Tools executed on this machine")
if args.mcp:
# Start MCP server alongside HTTP API
print("\n🤖 Starting MCP server...")
+4
View File
@@ -333,10 +333,14 @@ async def execute_tool(request: dict):
tool_name = request.get("tool", "")
tool_args = request.get("arguments", {})
print(f"🔧 TOOL SERVER: Executing {tool_name}({tool_args})")
# Create a temporary local executor for this request
executor = ToolExecutor(tool_host_url=None)
result = await executor.execute(tool_name, tool_args)
print(f"🔧 TOOL SERVER: {tool_name} completed ({len(result)} chars)")
return {"result": result}
+6 -1
View File
@@ -52,6 +52,7 @@ class ToolExecutor:
async def _execute_remote(self, tool_name: str, tool_args: dict) -> str:
"""Execute tool on remote tool host."""
try:
print(f" 🔧 Remote tool call: {tool_name}({tool_args})")
session = await self._get_session()
url = f"{self.tool_host_url}/v1/tools/execute"
@@ -63,12 +64,16 @@ class ToolExecutor:
async with session.post(url, json=payload) as resp:
if resp.status == 200:
data = await resp.json()
return data.get("result", "No result from tool host")
result = data.get("result", "No result from tool host")
print(f" ✅ Tool result received ({len(result)} chars)")
return result
else:
error_text = await resp.text()
print(f" ❌ Tool host error: {resp.status}")
return f"Tool host error ({resp.status}): {error_text}"
except Exception as e:
print(f" ❌ Error contacting tool host: {e}")
return f"Error contacting tool host: {str(e)}"
async def _execute_local(self, tool_name: str, tool_args: dict) -> str: