ProgramDiffOptions
Options & Configuration · AiDotNet.Configuration
Configures how SEARCH/REPLACE edit blocks are parsed from a model response and applied to a program.
For Beginners
Language models edit code by sending “find this text, replace it with that text” instructions wrapped in special marker lines. These settings control how forgiving the reader of those instructions is. The defaults accept Windows and Unix line endings, require the text being searched for to actually exist in the file, and refuse an edit that would change nothing. Leave them alone unless you are reproducing another tool’s exact behaviour or your model writes markers in an unusual style.
How It Works
The reference OpenEvolve implementation exposes one regular expression,
<<<<<<< SEARCH\n(.*?)=======\n(.*?)>>>>>>> REPLACE, which requires
bare line feeds and therefore silently matches nothing at all when the model emits Windows line endings or
leaves a trailing space after a marker. These options drive a line-based parser instead, so the marker text is
still configurable but carriage returns, indentation, and trailing spaces no longer decide whether an edit is
seen. AllowCarriageReturns exists to opt back into the strict line-feed-only behaviour when a
pipeline wants byte-for-byte parity with the reference parser.
FuzzyWhitespace and RejectWhenNoBlockApplied address the second reference-parser
weakness: a block whose SEARCH text is absent is skipped without a word, so a child program can be byte
identical to its parent and still consume evaluation budget. With the default settings a run instead learns
that nothing applied and can retry with feedback.
Constructors
| Constructor | Summary |
|---|---|
ProgramDiffOptions() |
Properties
| Property | Summary |
|---|---|
bool AllowCarriageReturns { get; set; } |
Gets or sets whether responses containing carriage returns are accepted. |
bool FuzzyWhitespace { get; set; } |
Gets or sets whether an exact match failure retries with white space normalized per line. |
bool RejectWhenNoBlockApplied { get; set; } |
Gets or sets whether applying zero blocks, or producing an unchanged program, is a failure. |
int MaxBlocks { get; set; } |
Gets or sets the maximum number of edit blocks accepted from one response. |
int MaxFailureExcerptLength { get; set; } |
Gets or sets the maximum number of characters of search text echoed into a failure message. |
string DividerMarker { get; set; } |
Gets or sets the marker line that separates the search text from the replacement text. |
string ReplaceMarker { get; set; } |
Gets or sets the marker line that closes the replacement text. |
string SearchMarker { get; set; } |
Gets or sets the marker line that opens the text to search for. |
Methods
| Method | Summary |
|---|---|
ProgramDiffOptions Clone() |
Creates an independent copy so a running component is unaffected by later mutation. |
void Validate() |
Validates the marker text and numeric bounds. |
Fields
| Field | Summary |
|---|---|
string DefaultDividerMarker |
The marker line that separates the search text from the replacement text. |
string DefaultReplaceMarker |
The marker line that closes the replacement text. |
string DefaultSearchMarker |
The marker line that opens the text to search for. |