Preserve native diagnostic evidence

This commit is contained in:
2026-11-23 04:39:00 +00:00
parent c167a5e5ab
commit c477bcc388
9 changed files with 172 additions and 105 deletions

View File

@@ -40,6 +40,7 @@ func (s *sectionInteractions) write(offset int) {
// Earlier snapshots keep their own lengths while additional turns add messages.
type repairHistory struct {
messages []structuredoutput.Message
native any
}
func (h *repairHistory) retain(prepared *structuredoutput.PreparedSnapshot) *structuredoutput.PreparedSnapshot {
@@ -55,6 +56,10 @@ func (h *repairHistory) retain(prepared *structuredoutput.PreparedSnapshot) *str
}
snapshot := *prepared
snapshot.Messages = slices.Clip(h.messages)
if shareable, ok := prepared.PromptKit.(interface{ ShareMessages(any) any }); ok {
snapshot.PromptKit = shareable.ShareMessages(h.native)
}
h.native = snapshot.PromptKit
return &snapshot
}

View File

@@ -260,7 +260,22 @@ func TestLaterRepairArtifactsUseOrderedProposalIndices(t *testing.T) {
}
var request structuredoutput.PreparedSnapshot
readInteraction(t, attempt.Artifacts.RequestPayloadPath, &request)
if !reflect.DeepEqual(&request, captured[i]) {
want, err := json.Marshal(captured[i])
if err != nil {
t.Fatal(err)
}
got, err := json.Marshal(&request)
if err != nil {
t.Fatal(err)
}
var gotValue, wantValue any
if err := json.Unmarshal(got, &gotValue); err != nil {
t.Fatal(err)
}
if err := json.Unmarshal(want, &wantValue); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(gotValue, wantValue) {
t.Fatalf("request %d did not preserve prepared evidence", i+1)
}
}