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

@@ -91,6 +91,7 @@ func TestPreparedRunJSONContractRoundTripsAllFields(t *testing.T) {
"input_hashes",
"session_id",
"rendered_prompt_hash",
"message_content_hash",
"messages",
"start_time",
"end_time",
@@ -124,6 +125,13 @@ func TestPreparedRunJSONContractRoundTripsAllFields(t *testing.T) {
t.Fatalf("marshal zero PreparedRun: %v", err)
}
zeroObject := decodeJSONObject(t, zeroPayload)
if string(zeroObject["message_content_hash"]) != `""` {
t.Fatalf("zero message content hash missing or nonempty: %s", zeroPayload)
}
var legacy promptkit.PreparedRun
if err := json.Unmarshal([]byte(`{"messages":[]}`), &legacy); err != nil || legacy.MessageContentHash != "" {
t.Fatalf("legacy prepared run = %+v, %v", legacy, err)
}
for _, field := range []string{
"prompt_version",
"prompt_hash",
@@ -271,6 +279,7 @@ func fullyPopulatedPreparedRun() promptkit.PreparedRun {
InputHashes: map[string]string{"first": "hash-1", "second": "hash-2"},
SessionID: "session-prepared",
RenderedPromptHash: "rendered-hash",
MessageContentHash: "content-hash",
Messages: []promptkit.RenderedMessage{
{
Role: "system",