diff options
| author | t <t@tjp.lol> | 2026-06-18 14:15:55 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-18 14:16:24 -0600 |
| commit | 270cd00129551647e7c764a13836e03e0b2dc4e2 (patch) | |
| tree | f939bbf999dd67d996b4025b03dbfe4abd30b9f4 /libpanto-go/panto_test.go | |
| parent | 7c2d8825660f73198149c0b2ce26166b16ba3532 (diff) | |
preserve signature origins across compactions
Diffstat (limited to 'libpanto-go/panto_test.go')
| -rw-r--r-- | libpanto-go/panto_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libpanto-go/panto_test.go b/libpanto-go/panto_test.go index 5cfed01..fd9df70 100644 --- a/libpanto-go/panto_test.go +++ b/libpanto-go/panto_test.go @@ -128,6 +128,47 @@ func TestMessageBuilderRoundTrip(t *testing.T) { } } +// TestMessageBuilderSetIdentity rebuilds a message with a per-message wire +// identity (and no per-block thinking origin), the resumption path that lets +// callers avoid copying the identity onto every thinking block. +func TestMessageBuilderSetIdentity(t *testing.T) { + Init() + defer Deinit() + + conv, err := NewConversation() + if err != nil { + t.Fatalf("NewConversation: %v", err) + } + defer conv.Close() + + ab, err := NewMessageBuilder(RoleAssistant) + if err != nil { + t.Fatalf("NewMessageBuilder(assistant): %v", err) + } + // Thinking block with a signature but NO per-block origin. + if err := ab.AddThinking("reasoned", "sig", OpenAIChat, "", ""); err != nil { + t.Fatalf("AddThinking: %v", err) + } + if err := ab.AddText("answer"); err != nil { + t.Fatalf("AddText: %v", err) + } + // Provenance is carried at the message level instead. + if err := ab.SetIdentity(AnthropicMessages, "https://api.anthropic.com", "claude", ReasoningDefault); err != nil { + t.Fatalf("SetIdentity: %v", err) + } + if err := conv.AddMessage(ab, &Usage{Input: 10, Output: 5}); err != nil { + t.Fatalf("AddMessage: %v", err) + } + + asst := conv.Message(0).Snapshot() + if asst.Role != RoleAssistant || len(asst.Content) != 2 { + t.Fatalf("assistant message: role=%v blocks=%d", asst.Role, len(asst.Content)) + } + if b := asst.Content[0]; b.Tag != BlockThinking || b.Text != "reasoned" { + t.Fatalf("thinking block: %+v", b) + } +} + func testConfig() Config { return Config{ Provider: ProviderConfig{ |
