Improve prompt roles and correction repair context

This commit is contained in:
2026-11-11 17:42:30 +00:00
parent cf1fbe5748
commit f42573f8b0
23 changed files with 256 additions and 40 deletions

View File

@@ -57,6 +57,9 @@ func repairCandidates(ctx context.Context, input validateSectionCandidatesInput,
if input.Spec.Settings.LLM.CorrectionRepairAttempts <= 0 {
return initial, nil, nil
}
if input.Section == nil {
input.Section = validators.NewSectionLookup(input.WorkingTranscript)
}
initialFindings := make(map[int][]ValidatorRejectedChange)
for _, decision := range initial.rejected {
initialFindings[decision.ProposalIndex] = append(initialFindings[decision.ProposalIndex], decision)
@@ -100,9 +103,6 @@ func repairCandidates(ctx context.Context, input validateSectionCandidatesInput,
if position < len(references) {
localRef = references[position]
} else {
if input.Section == nil {
input.Section = validators.NewSectionLookup(input.WorkingTranscript)
}
if pos, ok := input.Section.Position(original.TargetSegmentID); ok {
localRef = pos + 1
}
@@ -119,7 +119,20 @@ func repairCandidates(ctx context.Context, input validateSectionCandidatesInput,
findings := safeFindings(rejected)
replay := &structuredoutput.Replay{Exchange: input.Exchange}
for attempt := 0; attempt < input.Spec.Settings.LLM.CorrectionRepairAttempts; attempt++ {
payload, err := (proposal_generation.RepairRequest{ProposalRef: position + 1, Correction: proposal_generation.StructuredCorrectionProposal{SegmentReference: localRef, OriginalText: current.OriginalText, CorrectedText: current.CorrectedText}, Findings: findings}).JSON()
request := proposal_generation.RepairRequest{
ProposalRef: position + 1,
Correction: proposal_generation.StructuredCorrectionProposal{SegmentReference: localRef, OriginalText: current.OriginalText, CorrectedText: current.CorrectedText},
Findings: findings,
}
if pos, ok := input.Section.Position(current.TargetSegmentID); ok {
segment := &input.WorkingTranscript.Segments[pos]
request.OriginalSegmentText = &segment.Text
preview := proposals.PreviewProposalForSegment(segment, current.CorrectionProposal, input.Policy)
if preview.Applicable {
request.CorrectedSegmentText = &preview.CorrectedSegmentText
}
}
payload, err := request.JSON()
if err != nil {
branches = append(branches, branch)
return finish(err)