fix: 移除 fcIdx -1 偏移,修复并发工具调用撞键问题 (#5095)
当 Claude 直接以多个 tool_use 块起始(无文本前导,index=0)时, -1 偏移导致 index=0 和 index=1 同时映射到 fcIdx=0: - index=0 的工具 args 先流完,发出一次合法调用 ✓ - index=1 的 args 追加到同一 map 槽位,污染后为非法 JSON,该工具丢失 ✗ - index=2 以后的工具各自独占唯一 fcIdx,正常发出 ✓ 结果:每轮并发调用中第 2 个工具必然丢失, 模型收不到对应的工具结果后重试剩余工具, 产生雪球效应(10个→9个→8个...逐轮收缩)。 修复:直接使用 Claude 的 block index 作为 fcIdx,不做偏移。 fcIdx 仅作为本地 map 的 key,只需保证唯一性,无需从 0 开始。
This commit is contained in:
parent
51ca897cf4
commit
ff06067a18
@ -442,10 +442,7 @@ func StreamResponseClaude2OpenAI(claudeResponse *dto.ClaudeResponse) *dto.ChatCo
|
||||
tools := make([]dto.ToolCallResponse, 0)
|
||||
fcIdx := 0
|
||||
if claudeResponse.Index != nil {
|
||||
fcIdx = *claudeResponse.Index - 1
|
||||
if fcIdx < 0 {
|
||||
fcIdx = 0
|
||||
}
|
||||
fcIdx = *claudeResponse.Index
|
||||
}
|
||||
var choice dto.ChatCompletionsStreamResponseChoice
|
||||
if claudeResponse.Type == "message_start" {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user