(t *testing.T)
| 663 | } |
| 664 | |
| 665 | func TestEngineIngestAssemblePreservesParts(t *testing.T) { |
| 666 | eng := newTestEngine(t) |
| 667 | ctx := context.Background() |
| 668 | |
| 669 | // Ingest a message with tool_use parts |
| 670 | eng.Ingest(ctx, "agent:parts-roundtrip", []Message{ |
| 671 | {Role: "user", Content: "list files", TokenCount: 3}, |
| 672 | { |
| 673 | Role: "assistant", |
| 674 | Content: "", |
| 675 | TokenCount: 5, |
| 676 | Parts: []MessagePart{ |
| 677 | {Type: "tool_use", Name: "bash", Arguments: `{"cmd":"ls"}`, ToolCallID: "tc_1"}, |
| 678 | {Type: "text", Text: "found 3 files"}, |
| 679 | }, |
| 680 | }, |
| 681 | }) |
| 682 | |
| 683 | // Assemble should return messages with parts intact |
| 684 | result, err := eng.Assemble(ctx, "agent:parts-roundtrip", AssembleInput{Budget: 1000}) |
| 685 | if err != nil { |
| 686 | t.Fatalf("Assemble: %v", err) |
| 687 | } |
| 688 | |
| 689 | if len(result.Messages) != 2 { |
| 690 | t.Fatalf("Assemble returned %d messages, want 2", len(result.Messages)) |
| 691 | } |
| 692 | |
| 693 | // The second message should have Parts populated |
| 694 | assistantMsg := result.Messages[1] |
| 695 | if len(assistantMsg.Parts) != 2 { |
| 696 | t.Fatalf("Assembled assistant message Parts = %d, want 2", len(assistantMsg.Parts)) |
| 697 | } |
| 698 | if assistantMsg.Parts[0].Type != "tool_use" { |
| 699 | t.Errorf("part[0].Type = %q, want tool_use", assistantMsg.Parts[0].Type) |
| 700 | } |
| 701 | if assistantMsg.Parts[0].ToolCallID != "tc_1" { |
| 702 | t.Errorf("part[0].ToolCallID = %q, want tc_1", assistantMsg.Parts[0].ToolCallID) |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | // --- Session Mutex --- |
| 707 |
nothing calls this directly
no test coverage detected