ProgramArtifact
Models & Types · AiDotNet.Evolution.Programs.ArtifactStore
One named piece of evidence an evaluation produced, held as bytes so binary output survives.
For Beginners
When a candidate program runs, it usually leaves something behind - printed output,
an error message, a file it wrote. This holds one of those, with a short name such as stderr. Use
FromText for anything textual and FromBytes for binary content such as an image.
Feeding an artifact back into the next prompt is by far the fastest way for a model to fix a broken
program.
How It Works
An artifact is what a candidate program actually emitted: standard output, a stack trace, a coverage report, a
generated image, a profiler trace. The reference OpenEvolve evaluator models artifacts as
Dict[str, Union[str, bytes]], and the bytes half matters - a store that keeps only text cannot
hold a profile or a rendered plot, and base64-encoding it into a text field inflates it by a third and loses the
distinction on the way back out. This type keeps bytes and records whether they were supplied as UTF-8 text.
The content is untrusted: it was produced by code a model wrote, running against data the library did not
choose. Nothing here interprets it, executes it, or renders it. IsTruncated is set by a store that
had to cut the content to stay inside its configured limit, so a caller is never shown a partial artifact that
claims to be complete.
Properties
| Property | Summary |
|---|---|
IReadOnlyList<byte> Content { get; } |
Gets a read-only view of the content bytes. |
bool IsText { get; } |
Gets whether the content was supplied as text and can be read back with GetText. |
bool IsTruncated { get; } |
Gets whether the content was cut to fit a configured limit. |
int ByteLength { get; } |
Gets the size of the content in bytes. |
string Name { get; } |
Gets the artifact’s label. |
Methods
| Method | Summary |
|---|---|
ProgramArtifact FromBytes(string name, IReadOnlyList<byte> content, bool isTruncated) |
Creates a binary artifact. |
ProgramArtifact FromText(string name, string text, bool isTruncated) |
Creates a text artifact, encoded as UTF-8 without a byte-order mark. |
ProgramArtifact Truncate(int maxBytes) |
Returns a copy of this artifact whose content is cut to a byte limit. |
string GetText() |
Decodes the content as UTF-8 text. |
string ToString() |
Returns the name and size, never the content. |
void CopyTo(Stream destination) |
Writes the content to a stream. |
Fields
| Field | Summary |
|---|---|
int MaxNameLength |
The longest artifact name accepted, in characters. |