From 739a03b4cfe6069804cb164a8b6f7f173d92cbae Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 29 Nov 2025 16:06:34 +0800 Subject: [PATCH] Refactor tool call result methods and update i18n messages for clarity - Renamed methods in ToolCallResult from ServerID to Server and ToolName to Tool for improved clarity and consistency. - Updated i18n messages in builtin.go to remove redundant context, simplifying the label and description for the assistant's streaming process. --- agent/assistant/agent.go | 2 +- agent/assistant/types.go | 8 ++++---- agent/i18n/builtin.go | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/agent/assistant/agent.go b/agent/assistant/agent.go index 642d3986..6064bcab 100644 --- a/agent/assistant/agent.go +++ b/agent/assistant/agent.go @@ -138,7 +138,7 @@ func (ast *Assistant) Stream(ctx *context.Context, inputMessages []context.Messa log.Trace("[AGENT] All tool calls succeeded (attempt %d)", attempt) for _, result := range toolResults { fmt.Println("--") - fmt.Printf("Result :%s %s %s\n", result.ToolCallID, result.ServerID(), result.ToolName()) + fmt.Printf("Result :%s %s %s\n", result.ToolCallID, result.Server(), result.Tool()) res, err := result.ParsedContent() if err != nil { fmt.Println("Error: ", err) diff --git a/agent/assistant/types.go b/agent/assistant/types.go index 604cd4e0..3768cd46 100644 --- a/agent/assistant/types.go +++ b/agent/assistant/types.go @@ -187,16 +187,16 @@ type ToolCallResult struct { // false: MCP internal errors that LLM cannot fix (e.g., "network error", "service unavailable") } -// ServerID extracts the MCP server ID from the formatted tool name +// Server extracts the MCP server ID from the formatted tool name // Example: "echo__ping" -> "echo" -func (r *ToolCallResult) ServerID() string { +func (r *ToolCallResult) Server() string { serverID, _, _ := ParseMCPToolName(r.Name) return serverID } -// ToolName extracts the original tool name without server prefix +// Tool extracts the original tool name without server prefix // Example: "echo__ping" -> "ping" -func (r *ToolCallResult) ToolName() string { +func (r *ToolCallResult) Tool() string { _, toolName, _ := ParseMCPToolName(r.Name) return toolName } diff --git a/agent/i18n/builtin.go b/agent/i18n/builtin.go index 04597ec4..b5bf69bb 100644 --- a/agent/i18n/builtin.go +++ b/agent/i18n/builtin.go @@ -12,8 +12,8 @@ func init() { Locale: "en", Messages: map[string]any{ // Assistant: agent.go Stream() function - "assistant.agent.stream.label": "Assistant {{name}}", - "assistant.agent.stream.description": "Assistant {{name}} is processing the request", + "assistant.agent.stream.label": "{{name}}", + "assistant.agent.stream.description": "{{name}} is processing the request", "assistant.agent.stream.history": "Get Chat History", "assistant.agent.stream.capabilities": "Get Connector Capabilities", "assistant.agent.stream.create_hook": "Call Create Hook", @@ -100,8 +100,8 @@ func init() { Locale: "zh-cn", Messages: map[string]any{ // Assistant: agent.go Stream() function - "assistant.agent.stream.label": "助手 {{name}}", - "assistant.agent.stream.description": "助手 {{name}} 正在处理请求", + "assistant.agent.stream.label": "{{name}}", + "assistant.agent.stream.description": "{{name}} 正在处理请求", "assistant.agent.stream.history": "获取聊天历史", "assistant.agent.stream.capabilities": "获取连接器能力", "assistant.agent.stream.create_hook": "调用 Create Hook", @@ -160,8 +160,8 @@ func init() { Locale: "zh", Messages: map[string]any{ // Assistant: agent.go Stream() function - "assistant.agent.stream.label": "助手 {{name}}", - "assistant.agent.stream.description": "助手 {{name}} 正在处理请求", + "assistant.agent.stream.label": "{{name}}", + "assistant.agent.stream.description": "{{name}} 正在处理请求", "assistant.agent.stream.history": "获取聊天历史", "assistant.agent.stream.capabilities": "获取连接器能力", "assistant.agent.stream.create_hook": "调用 Create Hook",