FencedCodeExtractionResult

Models & Types · AiDotNet.Evolution.Programs

The code recovered from a model response, together with every fence that was considered.

For Beginners

This is what you get back when you ask for the code out of a chat answer. Check HasCode to see whether anything was found and SelectionSource to see how confident the answer is: code taken from a properly labelled block is trustworthy, whereas code taken from the raw response usually means the model ignored the requested format and is worth retrying.

How It Works

The reference OpenEvolve implementation returns a bare string and falls all the way back to the entire response when no fence matches, so a caller cannot tell whether it received clean code or a paragraph of prose that happens to be non-empty. This result reports the exact rung of the fallback ladder that produced Code in SelectionSource, keeps every Blocks entry it saw, and records a bounded diagnostic whenever it had to settle for something weaker than a language-labelled fence.

Properties

Property Summary
FencedCodeSelectionSource SelectionSource { get; } Gets the fallback rung that produced Code.
IReadOnlyList<FencedCodeBlock> Blocks { get; } Gets every fenced block seen in the response, in the order they appeared.
IReadOnlyList<string> Diagnostics { get; } Gets bounded notes explaining any fallback or malformed fence.
bool HasCode { get; } Gets whether any code was recovered.
bool IsConfident { get; } Gets whether the code came from a fence whose label matched the requested language.
string Code { get; } Gets the selected code, or an empty string when nothing could be recovered.