Repository navigation
fix(provider): deterministic parallel tool-call emit order (#4244) - #4247
Merged
Merged
Conversation
…p random order (#4244) Co-Authored-By: ggcode <noreply@ggcode.dev>
Owner
Author
|
终复走读 GO(ggcxf_reviewer,奇数域):87 行 #4244 确定性双点修——openai.go finish_reason 环与 openai_stream_flush.go 残余 flush 环均从 map 随机序改为 slices.Sorted(maps.Keys(toolCalls)) 按 idx 发射,并行对(mkdir→write/add→commit)恢复模型意图序且 replay 可重现。伴测 50 轮再哈希护栏。小 nit(不阻塞):测试直接断言 slices.Sorted 语义,未端到端跑生产发射路径——确定性由 stdlib 保证,可接受。CI 9/9。即并。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
根因
openai.go 并行 tool call 累积容器为 map[int](key=模型原始 idx),两处发射循环(finish_reason=tool_calls 主径 openai.go + 残留 flush openai_stream_flush.go)直接 range map——Go map 遍历被 runtime 随机化,模型 idx 表达的顺序意图丢失(2-call 批约 50% 颠倒)。下游 agent 按到达顺序串行执行副作用工具:mkdir→write、add→commit 类耦合对随机序执行;transcript/回放非确定。Anthropic/Gemini 均保序,唯 OpenAI 随机。
修(issue 建议原样)
两循环改
for _, idx := range slices.Sorted(maps.Keys(toolCalls))——下游零改动(id 配对协议本就按 tool_call_id)。伴测:非平凡键集 50 轮重排下发射序恒=排序键集。验证
provider 全包 30.3s ok+build 绿(含 OpenAI/Flush 族定向)。
Closes #4244