From dea381c38567fc242df0f3fd8d64172134712f67 Mon Sep 17 00:00:00 2001 From: yuchou87 Date: Thu, 19 Feb 2026 19:31:13 +0800 Subject: [PATCH] improve(agent): clarify MCP tool registration logging Separate tool counting metrics for better clarity: - unique_tools: number of distinct MCP tools - total_registrations: total tool registrations across all agents - agent_count: number of agents receiving the tools Previously, tool_count was misleading as it showed total registrations, making it appear that more unique tools were registered than actually exist. Addresses Copilot code review feedback. --- pkg/agent/loop.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index e5a1465eb..87b47f4ad 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -162,8 +162,12 @@ func (al *AgentLoop) Run(ctx context.Context) error { // Register MCP tools for all agents servers := mcpManager.GetServers() - toolCount := 0 + uniqueTools := 0 + totalRegistrations := 0 + agentCount := len(al.registry.ListAgentIDs()) + for serverName, conn := range servers { + uniqueTools += len(conn.Tools) for _, tool := range conn.Tools { for _, agentID := range al.registry.ListAgentIDs() { agent, ok := al.registry.GetAgent(agentID) @@ -172,7 +176,7 @@ func (al *AgentLoop) Run(ctx context.Context) error { } mcpTool := tools.NewMCPTool(mcpManager, serverName, tool) agent.Tools.Register(mcpTool) - toolCount++ + totalRegistrations++ logger.DebugCF("agent", "Registered MCP tool", map[string]interface{}{ "agent_id": agentID, @@ -185,8 +189,10 @@ func (al *AgentLoop) Run(ctx context.Context) error { } logger.InfoCF("agent", "MCP tools registered successfully", map[string]interface{}{ - "server_count": len(servers), - "tool_count": toolCount, + "server_count": len(servers), + "unique_tools": uniqueTools, + "total_registrations": totalRegistrations, + "agent_count": agentCount, }) } }