Promote and Roll Out Prompts
Prompt versions are served through the same labels, targeting, and rollout system used by managed variables. The Prompts page is where you author and save prompt versions. The Managed Variables page is where you decide which version production traffic receives.
The normal production workflow is:
- Edit and test a prompt draft in Prompt Management.
- Save a new prompt version.
- Open the prompt’s backing managed variable.
- Move a serving label, such as
production, to the new version. - Watch traces, runs, or evaluation results.
- Move the label back if you need to roll back.
The backing variable name follows this pattern:
prompt__<slug_with_underscores>
For example, the prompt slug support-agent maps to
prompt__support_agent.
Suppose support-agent has:
| Version | Template |
|---|---|
| v1 | Current production support prompt |
| v2 | New prompt with clearer escalation instructions |
To promote v2:
- Open Managed Variables.
- Open
prompt__support_agent. - On the Values tab, select the
productionlabel. - Edit from v2 or assign
productionto v2. - Save the label change.
Application code fetching prompt__support_agent with label='production'
receives v2 on the next variable resolution. No redeploy is required.
To canary a prompt version before moving all production traffic:
- Save the new prompt as v2.
- Create or move a
canarylabel to v2. - Keep
productionpointing at v1. - In Targeting, route a small percentage of traffic to
canaryand the rest toproduction.
For example:
| Label | Weight |
|---|---|
production | 90% |
canary | 10% |
Use a stable targeting_key when fetching the prompt so users or tenants keep a
consistent prompt assignment during the test.
from pydantic import BaseModel
import logfire
logfire.configure()
class SupportPromptInputs(BaseModel):
customer_name: str
tier: str
prompt_var = logfire.template_var(
name='prompt__support_agent',
type=str,
default='',
inputs_type=SupportPromptInputs,
)
with prompt_var.get(
SupportPromptInputs(customer_name='Maya Chen', tier='enterprise'),
targeting_key='tenant-123',
) as resolved:
prompt = resolved.value
If you explicitly pass label='production', the SDK bypasses rollout weights and
always requests that label. Omit label when you want rollout percentages and
targeting rules to decide the served version.
Use conditional targeting rules when a prompt should only change for a segment, such as internal users, beta tenants, or enterprise customers.
For example:
| Condition | Routing |
|---|---|
plan equals enterprise | enterprise_support = 100% |
| Default | production = 100% |
Then pass matching attributes from application code:
with prompt_var.get(
SupportPromptInputs(customer_name='Maya Chen', tier='enterprise'),
targeting_key='tenant-123',
attributes={'plan': 'enterprise'},
) as resolved:
prompt = resolved.value
Rollback is a label move:
- Open the prompt’s backing variable.
- Move
productionback to the previous version. - Save.
The next prompt resolution gets the restored version. Existing traces still show which prompt label and version were active for each request, so you can compare behavior before and after the rollback.
Prompt resolution happens inside Logfire’s managed-variable system. When you use the SDK context manager, downstream spans carry baggage that identifies the served variable label and version.
Use that data to compare:
- response quality from online evaluations,
- escalation or task-success rates,
- latency and token usage,
- user or operator feedback,
- error rates by prompt label or version.
If your prompt also composes shared fragments with @{...}@, inspect traces to
see which fragment versions were involved in a resolution.
A prompt version freezes the prompt template text. It does not freeze:
- scenario messages or scenario variables,
- dataset mappings,
- model or tool settings used for UI test runs,
- composed managed-variable fragments,
- labels, rollout weights, or targeting rules.
This is intentional. Prompt versions give you stable template snapshots, while labels and composed fragments let you change serving behavior without creating a new prompt version for every operational adjustment.