| 1 | package agent |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "reasonix/internal/provider" |
| 8 | ) |
| 9 | |
| 10 | func TestBatchToolResultCorrespondencePreservesOrderAndCallIDs(t *testing.T) { |
| 11 | calls := []provider.ToolCall{{ID: "first", Name: "pwsh"}, {ID: "second", Name: "pwsh"}} |
| 12 | results := []provider.Message{ |
| 13 | {Role: provider.RoleTool, ToolCallID: "first", Name: "pwsh", Content: "same"}, |
| 14 | {Role: provider.RoleTool, ToolCallID: "second", Name: "pwsh", Content: "same"}, |
| 15 | } |
| 16 | if err := validateBatchToolResultCorrespondence(calls, results, []bool{true, true}); err != nil { |
| 17 | t.Fatal(err) |
| 18 | } |
| 19 | results[1].ToolCallID = "first" |
| 20 | if err := validateBatchToolResultCorrespondence(calls, results, []bool{true, true}); err == nil || !strings.Contains(err.Error(), "second") { |
| 21 | t.Fatalf("expected mismatched call id failure, got %v", err) |
| 22 | } |
| 23 | } |
| 24 |