The prompt as a versioned artifact: preserving generation conditions

Connect a prompt revision, input, rendered request, response, and criteria. An independent Python exercise verifies synthetic records without calling a model.

Preserved versions make a specific change and its surrounding conditions available for inspection.
Preserved versions make a specific change and its surrounding conditions available for inspection.

A repository contains a prompt and, beside it, a successful response. After several changes, someone needs to understand why the new result differs. The instruction text alone cannot explain which data entered the request, whether the response schema changed, which model was called, or which criteria made the earlier version acceptable.

The unit of preservation should therefore be a bundle of conditions for a particular attempt. A prompt has its own revision, but the result is also linked to the input, rendered request, execution mode, and evaluation. That record restores the basis for comparison. A promise to reproduce the exact same generation requires other conditions.

We will use an independent Python exercise with two revisions of an editorial task. Both responses are handwritten synthetic fixtures. No model is called. This lets us check the relationships between artifacts and the behaviour of the criteria without presenting prepared text as a measurement of AI quality.

What belongs to one attempt

Imagine a card for a fictional workshop. The input contains two facts: there are 12 seats, and booking is required. The task is to return JSON containing a title and facts. The first revision asks for a short card; the second explicitly requires each fact to appear once with its text preserved.

ArtifactQuestion it answers
Prompt template and revisionWhich instruction was selected
Input dataWhich facts were available to this particular attempt
Response schemaWhich structure may be returned
Rendered requestWhich text was actually prepared after inserting the data
Execution mode and parametersWhether a model was called and under which conditions
ResponseWhich result was received or explicitly prepared by hand
Criteria and evaluation codeHow the result was checked

This is a custom application format, not an implementation of a universal provenance standard. A useful general foundation appears in the W3C PROV-DM model: data, activities involving it, and responsible participants are described separately. For our task, that helps distinguish a response file from an action that supposedly produced it.

A link to a changing document is insufficient to reconstruct an input. If search supplied the data, preserve an authorised snapshot of the fragments used and their order, rather than only the index query. Such a snapshot may need restricted access; versioning does not grant permission to copy private data into a public repository.

The execution label must tell the truth

In our example, the descriptor for the second revision looks like this:

{
  "prompt_revision": "r2",
  "execution_mode": "handwritten_fixture",
  "provider": null,
  "model": null,
  "parameters": {}
}

The null values are intentional: no provider call occurred. Revision r1 uses the same descriptor shape. There is no reason to insert a popular model’s name to make the record seem complete. The absence of an actual call is an important property of the exercise.

Real generation needs a different mode with the actual provider, model identifier, parameters, and execution details. These should not be inferred from a prompt name or a route called “default model”. If the exact model revision is unknown, that limitation remains visible.

An attempt log should not indiscriminately copy authorisation headers or keys either. The teaching descriptor accepts only defined fields and rejects an extra credential field. This is a narrow shape check, not a universal secret detector for arbitrary text. Inputs and responses still need their own access rules.

Preserve the request after substitution

A template is not the finished request. Input facts and a schema are inserted into it, and serialization can also change the text. In the exercise, each marker must occur exactly once, and substitutions happen simultaneously. Input text is not processed again as a template.

The record preserves both the original template and the rendered message. During verification, the request is reconstructed from the same stored parts and compared with the archived version. If someone changes the message and recalculates only its checksum, reconstruction still detects the difference.

This checks internal consistency in our format. It does not prove that a remote server received that request: such a claim needs actual execution and corresponding evidence. Avoiding repeated substitution is also not complete protection against instructions embedded in untrusted sources.

Structure and meaning have different criteria

The schema specifies required title and facts properties, value types, length bounds, and a ban on additional properties. In JSON Schema, listing a field in properties does not make it mandatory; that requires required. The additionalProperties rule is specified separately, as explained in the JSON Schema object documentation.

A correctly structured facts array can still omit an important point. A small custom set of criteria is therefore stored alongside the schema:

{
  "required_fact_ids": ["f1", "f2"],
  "copy_text_exactly": true,
  "unique_fact_ids": true
}

The evaluator checks known identifiers, required fact coverage, the absence of duplicates, and an exact match between quoted text and input. This is a deliberately narrow task of copying synthetic facts. It does not assess the quality of an arbitrary paraphrase, the appeal of a title, or the truth of the original source.

Human acceptance remains open even after all automatic checks. A title within the length limit, for example, can still be unsuitable in meaning. A “valid schema” label should not silently become “ready to publish”.

Compare records without inventing a causal conclusion

The synthetic r1 response retains only the fact about seats. The r2 response includes both. Local execution confirmed the expected distinction: both records can be verified as internally consistent bundles, but the first fails the completeness criterion. The second meets the narrow automatic criteria while still requiring an author’s review.

This does not establish that the second prompt revision improves a model. The responses were handwritten and their difference was chosen in advance. The comparison is there to show which conditions were preserved and precisely which criterion reacts.

The template, revision label, and rendered request change between revisions. Input, schema, criteria, and evaluation code remain the same. If the number of seats in the input changes as well, the comparison must show that difference too. Otherwise, a changed task can easily be attributed to a changed instruction. The comparison covers stored artifacts; Python and library versions are recorded separately in the report, so matching files should not be described as an identical execution environment.

A future experiment with a real model needs an agreed task set, unchanged criteria, and actual attempts for both revisions. A single successful response should not become a general conclusion. Our archive helps trace the conditions of such an experiment, but does not replace running it.

A checksum does not certify origin

For the text artifacts, the bundle computes checksums over UTF-8 bytes. Python provides this through the hashlib interface. Even a changed space can mean different bytes; generated JSON parts therefore use one defined serialization method.

Changing an artifact without updating its record is detected. Someone who changes both the text and its checksum, however, can produce a different internally consistent bundle. Trust requires a reference independent of that edit, such as an accepted revision of the entire set with a controlled history. This exercise implements neither a digital signature nor a protected log.

Preserving the evaluator’s version matters too. New criteria may assess an old response differently. The example does not quietly run another code revision in place of the archived one: verification requires an explicit reevaluation. Code from an untrusted archive is never executed automatically.

How to detect changed conditions

The exercise ran on Python 3.12.14 with jsonschema 4.26.0: all 19 scenarios met their stated expectations. They include changed templates, inputs, and responses; an inconsistent request with a recalculated checksum; an extra response field; an unknown or repeated fact; an altered quote; a duplicate JSON key; and a different evaluator revision. The number of provider calls is 0.

An intentionally bad response in such a scenario must be rejected by the appropriate criterion. A successful check means the defect received the correct reaction, not that the response itself is correct. The strict JSON reader also rejects non-numeric values such as NaN and duplicate keys that Python’s standard decoder may accept by default; these behaviours are described in the json documentation.

Preserving conditions and repeating a result remain different tasks. Even the PyTorch reproducibility documentation cautions against guaranteeing identical results across releases, platforms, and different execution environments. This is a useful limit when framing a promise; an individual provider still requires its own verification.

A versioned prompt becomes a useful artifact when its input, exact rendered request, response origin, and evaluation method can be established. That record is where an honest comparison of the next change begins.

  1. Testing Structured AI responses: validation before changing data
  2. Knowledge & AI Context for one task: how to avoid sending the whole platform to a model
  3. Knowledge & AI AI task quality: a small case set instead of one successful run
  4. Testing AI in development: context, action, and checking the result

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article