ProgramDiffFailure
Models & Types · AiDotNet.Evolution.Programs
Names one SEARCH/REPLACE block that could not be parsed or applied, and why.
For Beginners
When a model’s edit instruction cannot be used, this object explains which instruction failed and what was wrong with it. The excerpt is a short, cleaned-up snippet of the text the model asked to find, trimmed so a huge or unprintable response cannot flood your logs. Feeding these messages back to the model in the next attempt is usually enough for it to correct itself.
How It Works
This type is the concrete answer to the reference implementation’s most damaging silence. OpenEvolve’s
apply_diff loops over blocks, tries a first-window line match, and simply moves on when there is no
match: nothing is logged, the caller sees a program that may be identical to its parent, and the evaluator is
still paid for. Every rejection here instead surfaces a typed Reason, the failing block’s
BlockOrdinal, and a bounded, control-character-sanitized SearchExcerpt that is safe
to place in a retry prompt or a log.
Constructors
| Constructor | Summary |
|---|---|
ProgramDiffFailure(ProgramDiffFailureReason reason, string message, int blockOrdinal, string searchExcerpt) |
Initializes a failure record. |
Properties
| Property | Summary |
|---|---|
ProgramDiffFailureReason Reason { get; } |
Gets the typed reason the block was rejected. |
int BlockOrdinal { get; } |
Gets the zero-based ordinal of the offending block, or -1 when the failure covers the whole response. |
string Message { get; } |
Gets the bounded human-readable explanation. |
string SearchExcerpt { get; } |
Gets a bounded, sanitized excerpt of the search text that failed, or an empty string. |
Methods
| Method | Summary |
|---|---|
EvolutionDiagnostic ToDiagnostic() |
Converts this failure into an engine diagnostic suitable for an evaluation result. |
string ToString() |
Returns the reason, ordinal, and message without echoing raw program text. |