We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 14f97c8 + 58df74f commit 513e243Copy full SHA for 513e243
2 files changed
pkg/compaction/compaction.go
@@ -65,6 +65,7 @@ func BuildPrompt(messages []chat.Message, additionalPrompt string) []chat.Messag
65
for i, msg := range messages {
66
cloned := msg
67
cloned.Cost = 0
68
+ cloned.CacheControl = false
69
out[i] = cloned
70
}
71
out = append(out, chat.Message{
pkg/compaction/compaction_test.go
@@ -268,6 +268,26 @@ func TestBuildPrompt(t *testing.T) {
268
assert.InDelta(t, 0.05, original[0].Cost, 1e-9)
269
assert.Len(t, original, 1)
270
})
271
+
272
+ t.Run("strips CacheControl from cloned messages", func(t *testing.T) {
273
+ t.Parallel()
274
275
+ input := []chat.Message{
276
+ {Role: chat.MessageRoleSystem, Content: "system", CacheControl: true},
277
+ {Role: chat.MessageRoleSystem, Content: "context", CacheControl: true},
278
+ {Role: chat.MessageRoleUser, Content: "hello"},
279
+ }
280
281
+ out := BuildPrompt(input, "")
282
283
+ // All cloned messages should have CacheControl=false
284
+ for i, msg := range out {
285
+ assert.False(t, msg.CacheControl, "message %d should have CacheControl stripped", i)
286
287
+ // Original should be unchanged
288
+ assert.True(t, input[0].CacheControl)
289
+ assert.True(t, input[1].CacheControl)
290
+ })
291
292
293
func TestPromptsAreEmbedded(t *testing.T) {
0 commit comments