From cfbce969fa9535b9d83a44e507a33f29418d089e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=8E=AE=20=28Jade=20Lin=29?= Date: Sun, 28 Sep 2025 22:44:25 +0800 Subject: [PATCH] refactor(mcp): simplify tools collection using maps.Collect - Replace manual map construction with maps.Collect for MCP tools - Remove redundant loop that iterated over mcpTools.Seq2() - Maintain same functionality with cleaner, more idiomatic code --- internal/llm/agent/agent.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/llm/agent/agent.go b/internal/llm/agent/agent.go index 08710baba2886f6c6c8421006068c7fecd511511..c8d19cf6da0a312475ca1610371ec462c287d04f 100644 --- a/internal/llm/agent/agent.go +++ b/internal/llm/agent/agent.go @@ -213,11 +213,8 @@ func NewAgent( mcpToolsOnce.Do(func() { doGetMCPTools(ctx, permissions, cfg) }) - result := make(map[string]tools.BaseTool) - for _, mcpTool := range mcpTools.Seq2() { - result[mcpTool.Name()] = mcpTool - } - return result + + return maps.Collect(mcpTools.Seq2()) } a := &agent{