ProgramPromptContext

Models & Types · AiDotNet.Evolution.Prompts

Everything one prompt is built from: the parent program, its scores, its history, and its evidence.

For Beginners

This is the packet of information handed to the prompt builder: the program being improved, how well it scored, what it measured, the last few things that were tried, a few other programs worth looking at, and anything the program printed when it last ran. Fill in what you have and leave the rest alone — every part is optional except the program itself, and sections with nothing in them are simply left out of the prompt.

How It Works

This is a plain input record with no engine types in it, which is deliberate. Because the prompt builder reads only this object, prompt construction is a pure function that can be unit tested with a handful of literals — no archive, no engine, no chat client, no clock. It is also what makes a rendered prompt reproducible: the same context, options, and random stream produce the same characters every time, which is the property a benchmark needs and the reference OpenEvolve sampler does not have, since it reads process-global state for its diverse-program sampling and its template variations.

FeatureDimensions, FeatureBins, and FeatureBinCounts travel together and are rendered as name=value [bin 3/10], so the model can see where in the archive grid the parent sits and which direction has room. Upstream renders the value alone, which tells the model a number but not what the number means.

Constructors

Constructor Summary
ProgramPromptContext(ProgramGenome parent) Initializes a prompt context around the program being improved.

Properties

Property Summary
EvolutionOptimizationDirection Direction { get; set; } Gets or sets whether a higher or a lower score is better.
IReadOnlyDictionary<string, double> ParentDescriptors { get; set; } Gets or sets the parent’s archive coordinates, keyed by descriptor name.
IReadOnlyDictionary<string, double> ParentMetrics { get; set; } Gets or sets the parent’s measured values, keyed by name.
IReadOnlyList<EvolutionDiagnostic> Diagnostics { get; set; } Gets or sets the diagnostics the parent’s evaluation reported.
IReadOnlyList<ProgramPromptArtifact> Artifacts { get; set; } Gets or sets the untrusted output the parent’s evaluation produced.
IReadOnlyList<ProgramPromptAttempt> PreviousAttempts { get; set; } Gets or sets the earlier attempts summarized in the history section, oldest first.
IReadOnlyList<ProgramPromptExample> Inspirations { get; set; } Gets or sets the programs offered for their difference rather than their score.
IReadOnlyList<ProgramPromptExample> TopPrograms { get; set; } Gets or sets the high-scoring programs offered as examples, best first.
IReadOnlyList<int> FeatureBinCounts { get; set; } Gets or sets the number of bins along each dimension, aligned with FeatureDimensions.
IReadOnlyList<int> FeatureBins { get; set; } Gets or sets the parent’s bin index along each dimension, aligned with FeatureDimensions.
IReadOnlyList<string> EmptyNeighborCells { get; set; } Gets or sets descriptions of nearby unoccupied archive cells worth reaching.
IReadOnlyList<string> FeatureDimensions { get; set; } Gets or sets the descriptor names the archive keeps diversity across, in grid order.
ProgramGenome Parent { get; } Gets the program the model is asked to improve.
double? ParentQuality { get; set; } Gets or sets the parent’s fitness score, or null when it was never scored.
double? PreviousQuality { get; set; } Gets or sets the score of the immediately preceding attempt, used to say whether fitness moved.
string ChangesDescription { get; set; } Gets or sets the parent’s current change description, used in changes-description mode.

Methods

Method Summary
void Validate() Validates that the aligned feature lists agree and that no collection holds a null element.