Files
CyberStrikeAI/internal/multiagent/runner_tool_call_id_test.go
T
2026-07-11 10:47:04 +08:00

38 lines
898 B
Go

package multiagent
import (
"testing"
"github.com/cloudwego/eino/schema"
)
func TestEmitToolCallsUsesUniqueFallbackIDsAcrossBatches(t *testing.T) {
index := 0
msg := &schema.Message{ToolCalls: []schema.ToolCall{{
Index: &index,
Function: schema.FunctionCall{
Name: "http-framework-test",
Arguments: `{}`,
},
}}}
var ids []string
progress := func(eventType, _ string, raw interface{}) {
if eventType != "tool_call" {
return
}
data, _ := raw.(map[string]interface{})
if id, _ := data["toolCallId"].(string); id != "" {
ids = append(ids, id)
}
}
for i := 0; i < 2; i++ {
emitToolCallsFromMessage(msg, "agent", "agent", "conversation", "deep", progress, nil, make(map[string]int), nil)
}
if len(ids) != 2 {
t.Fatalf("fallback IDs = %v, want two IDs", ids)
}
if ids[0] == ids[1] {
t.Fatalf("fallback ID was reused across batches: %q", ids[0])
}
}