MCPcopy
hub / github.com/sipeed/picoclaw / TestEngineIngestAssemblePreservesParts

Function TestEngineIngestAssemblePreservesParts

pkg/seahorse/short_engine_test.go:665–704  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

663}
664
665func 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

Callers

nothing calls this directly

Calls 5

newTestEngineFunction · 0.85
FatalfMethod · 0.80
ErrorfMethod · 0.80
IngestMethod · 0.65
AssembleMethod · 0.65

Tested by

no test coverage detected