Expose content hashes on prepared runs

This commit is contained in:
2026-11-20 04:16:50 +00:00
parent e415ad43ce
commit dd40171c01
8 changed files with 41 additions and 2 deletions

View File

@@ -22,9 +22,13 @@ func TestPreparedNotificationSelectionAndOrdering(t *testing.T) {
}
return &promptkit.GenerateResponse{Content: "ok"}, nil
}))
expected, err := engine.Prepare(context.Background(), promptkit.RunRequest{PromptID: "prompt"})
if err != nil || expected.MessageContentHash == "" {
t.Fatalf("preparation = %+v, %v", expected, err)
}
req := promptkit.RunRequest{PromptID: "prompt", OnPrepared: func(_ context.Context, details promptkit.PreparedRun) {
calls++
if details.PromptID != "prompt" || len(details.Messages) == 0 {
if details.PromptID != "prompt" || len(details.Messages) == 0 || details.MessageContentHash != expected.MessageContentHash {
t.Fatalf("details=%+v", details)
}
}}
@@ -36,6 +40,9 @@ func TestPreparedNotificationSelectionAndOrdering(t *testing.T) {
if calls != 0 {
t.Fatal("preparation notified")
}
if handle.Details().MessageContentHash != expected.MessageContentHash {
t.Fatal("prepared handle content hash differs")
}
req.OnPrepared = func(context.Context, promptkit.PreparedRun) { t.Fatal("selection changed") }
_, err = engine.RunPrepared(context.Background(), handle)
if err != nil {