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.
This commit is contained in:
Max 2025-11-29 16:06:34 +08:00
parent a686483f15
commit 739a03b4cf
3 changed files with 11 additions and 11 deletions

View file

@ -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)

View file

@ -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
}

View file

@ -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",