fix(qwen): index-order tool emit + strings.Builder accumulation (R7a/R7c)

This commit is contained in:
sausheong committed 2026-06-13 12:42:41 +08:00
1 parent e40733145f
commit 79a69e5dce
2 files changed
+57 -19

No files matched your search

+19
View File
@@ -24,3 +24,22 @@ func TestQwenResolveSystemPromptEmpty(t *testing.T) {
got := qwenResolveSystemPrompt(llm.ChatRequest{})
require.Equal(t, "", got)
}
func TestEmitToolCalls_OrderedByIndex(t *testing.T) {
mk := func(id, name string) *pendingTC {
p := &pendingTC{id: id, name: name}
p.args.WriteString("{}")
return p
}
toolCalls := map[int]*pendingTC{1: mk("b", "second"), 0: mk("a", "first")}
ch := make(chan llm.ChatEvent, 10)
emitToolCalls(ch, toolCalls)
close(ch)
var ids []string
for ev := range ch {
if ev.Type == llm.EventToolCallDone {
ids = append(ids, ev.ToolCall.ID)
}
}
require.Equal(t, []string{"a", "b"}, ids)
}