Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix: resolve tool name duplication in streaming tool calls

AndyYangf63c9f6dbef1
diff --git a/internal/models/chat/remote_api.go b/internal/models/chat/remote_api.go
index 9b327a0e6..f8775932c 100644
--- a/internal/models/chat/remote_api.go
+++ b/internal/models/chat/remote_api.go
@@ -780,7 +780,11 @@ func (c *RemoteAPIChat) processToolCallsDelta(ctx context.Context, toolCalls []o
toolCallEntry.Type = string(tc.Type)
}
if tc.Function.Name != "" {
- toolCallEntry.Function.Name += tc.Function.Name
+ // 防御性校验:解决部分供应商(如vLLM Ascend等)在每个流 Chunk 中重复发送完整工具名的问题。
+ // 如果当前已存名字与新收到名字一致,则视为冗余重复,不进行叠加。
+ if toolCallEntry.Function.Name != tc.Function.Name {
+ toolCallEntry.Function.Name += tc.Function.Name
+ }
}
argsUpdated := false