Prompt Versioning for LLMs
Learn prompt version control for LLMs with immutable history, testing, promotion, rollback, release notes, and safer production deployments.
Prompt Versioning for LLMs
Prompt versioning is the practice of saving every LLM prompt change as an immutable release that can be tested, compared, promoted, and rolled back. In API v2 a prompt version is content-only — it captures the system and user prompt text, the input schema, and release notes. Model, sampling, output schema, and caching are versioned separately on the agent version that links to the prompt, so a production result can always be traced back to the exact prompt and the exact runtime config that generated it.
Use prompt version control when a prompt is shared by agents, changed by multiple teammates, deployed through CI, or measured with evaluations. Draft edits do not have to become production behavior: create a version, test it against representative inputs, promote the content candidate, then promote the linked agent version to current.
Why Version LLM Prompts?
Changing a production prompt can alter output quality, latency, cost, safety, and downstream JSON compatibility at the same time. An immutable version history gives teams a controlled release boundary:
- Reproducibility — each execution records the prompt version that produced it.
- Safe rollout — a candidate can be previewed and tested through an agent draft before it becomes current.
- Fast rollback — promote or re-promote a known agent version that already pins the desired prompt content.
- Collaboration — release messages explain what changed and why.
- Evaluation — compare candidate and current versions against the same dataset and judges.
- Auditability — trace customer-facing output to the exact prompt, model, schema, and settings.
Prompt Versioning Workflow
- Create one focused candidate version and write a descriptive release message.
- Preview the candidate’s rendering, then test it through an agent draft or playground with normal, edge-case, and adversarial inputs.
- Compare it with the current version using evaluations, trace output, latency, and cost.
- Promote the prompt only after the candidate meets the content criteria.
- Promote an agent version to current so it pins the promoted prompt together with its model, tools, schemas, budget, and policies.
- Monitor production traces and re-promote a known-good agent version if quality regresses.
Prompt Versioning vs. Git
| Concern | Git | PromptRails prompt versions |
|---|---|---|
| Prompt text history | Stored when prompts live in the repository | Stored as immutable platform versions |
| Model and generation settings | Usually spread across code or configuration | Versioned on the linked agent version |
| Input schema | Separate application files | Versioned with the prompt |
| Active content candidate | Determined by deployment state | Explicit prompt is_current promotion |
| Execution provenance | Requires custom logging | Recorded in PromptRails traces |
| Production rollout | Revert and redeploy | Promote an agent version to current so it pins the intended prompt version |
Git remains useful for application code and infrastructure. PromptRails versioning adds a runtime release record for prompt content, while promoting an agent version to current remains the production release boundary.
How It Works
Each prompt has one or more versions. A version captures:
- System prompt text
- User prompt template
- Input schema
- Version message (release notes)
Model and sampling, output schema, and caching are captured on the agent version, not the prompt version.
Exactly one version per prompt is marked as is_current. Agent drafts with an unpinned prompt link follow that version while you iterate. When an agent version is created with set_current=True or promoted with promote_version, PromptRails stamps the exact prompt version on the link so production behavior remains immutable. There is no separate publish API.
Technical detailsVersion field reference
Version Fields
| Field | Type | Description |
|---|---|---|
id | KSUID | Unique version identifier |
prompt_id | KSUID | Parent prompt ID |
version | string | Version label (e.g., v1, v2) |
system_prompt | string | System instructions for the LLM |
user_prompt | string | User message template (Jinja2) |
input_schema | JSON | Input validation schema |
is_current | boolean | Whether this is the active version |
message | string | Version message / release notes |
created_at | timestamp | Creation timestamp |
Model (model_id, fallback_model_id), sampling (temperature, max_tokens, top_p), output_schema, and cache_timeout are fields on the agent version.
Creating a Version
Create prompt versions from Studio when you are editing instructions or the input schema with teammates. Model choice is edited on the linked agent version. Use SDK calls when prompt versioning is part of a release workflow.
Technical detailsCreate, promote, and roll back prompt versions with SDKs
version = client.prompts.create_version(
prompt_id="your-prompt-id",
system_prompt="You are a concise technical writer.",
user_prompt="Summarize the following text in {{ max_sentences }} sentences:\n\n{{ text }}",
input_schema={
"type": "object",
"properties": {
"text": {"type": "string"},
"max_sentences": {"type": "integer", "default": 3}
},
"required": ["text"]
},
message="Tightened the summary instructions"
)Promoting a Version
Promotion sets a version as the current active version. The previously current version is automatically demoted.
client.prompts.promote_version(
prompt_id="your-prompt-id",
version_id="version-id-to-promote"
)After promotion:
- Agent drafts with unpinned links resolve to the newly promoted prompt version
- Agent versions that have previously been current keep their pinned prompt version
- Previous executions retain their original prompt version in the trace for reproducibility
Viewing Version History
versions = client.prompts.list_versions(prompt_id="your-prompt-id")
for v in versions:
current_marker = " *" if v.is_current else ""
print(f"{v.version}{current_marker} | {v.message} | {v.created_at}")Rolling Back
Rolling back is simply promoting a previous version:
# Find the version you want to restore
versions = client.prompts.list_versions(prompt_id="your-prompt-id")
target = versions[1] # previous version
# Promote it
client.prompts.promote_version(
prompt_id="your-prompt-id",
version_id=target.id
)Prompt versions are immutable, so changing the prompt’s current version is instant and keeps the newer version in history. To roll production behavior back, promote or re-promote an agent version that is pinned to the known-good prompt version.
Version Messages
Always include a descriptive message when creating a version. This serves as release notes and makes the version history meaningful:
# Good version messages
"Initial prompt for customer support agent"
"Tightened summary instructions for more consistent output"
"Updated system prompt to handle refund requests"
"Added few-shot examples for edge-case tickets"
"Clarified the required output format in the user template"Best Practices
- One change per version — Make focused changes so you can isolate the impact of each modification
- Test before promoting — Preview the rendered template, then run it through an agent draft or playground before making it current
- Document changes — Use version messages to explain what changed and why
- Coordinate with agent versions — Model, sampling, and caching live on the agent version; cut a new agent version when a prompt change needs a matching runtime change
- Promote deliberately — An agent version pins the prompt version it resolved when it becomes current, giving production runs deterministic behavior
Production Release Checklist
- Define the expected output and failure conditions before editing the prompt.
- Keep one behavioral change per version so evaluation results are explainable.
- Include inputs that represent production traffic, edge cases, and policy-sensitive requests.
- Validate output schemas and downstream parsers, not only subjective response quality.
- Compare quality, latency, token use, and cost against the current version.
- Review traces for unexpected tool calls, fallback-model use, and guardrail failures.
- Record the reason for promotion in the version message.
- Keep the previous version available as the immediate rollback target.
Prompt Versioning Questions
What should a prompt version include?
A useful version captures the system and user prompt text, the input schema, and a message describing the change. Model, sampling, output schema, and caching are versioned on the agent version, so coordinate the two when a change spans both prompt content and runtime config.
Does promoting a prompt change an agent version that has been current?
No. Promotion moves the prompt’s current pointer for drafts and future agent releases, but an agent version that has previously been current keeps its pinned prompt version. Promote a new agent version to current when the prompt change is ready for production.
How do I test a prompt version before production?
Preview the candidate with representative template inputs, then test it through an agent draft or playground. Use evaluations to compare the resulting agent behavior against the current release, including schema validity, latency, token consumption, cost, and guardrail outcomes.
How does prompt rollback work?
Promote the last known-good prompt version, then promote an agent version that pins it. Rollback does not delete the newer prompt version, so its release history remains available for investigation and later improvement.
Related Topics
- Prompts — Content-only templates and input schemas
- Evaluations — Compare versions against datasets and judges
- Tracing — Verify the exact prompt version used by an execution
- Agent Versioning — Coordinate agent configuration with prompt releases
- Go SDK, Python SDK, and JavaScript SDK — Automate version creation and promotion