Promotion, Feature Flags, Rollback and Drift
A release that passed last month can fail today without anyone changing your code.
Promote one tested release through environments with clear entry conditions. Use feature flags to turn capabilities on gradually and off quickly, with owners and expiry dates. Define in advance what triggers rollback. Refresh knowledge and models through the same gates, and watch for drift in requests, data, tools, models and outcomes.
What you will learn: promotion rules, flag design, rollback decisions, safe automated refresh and practical drift detection.
Prerequisites: Versioning, Registries and Evaluation-Driven Development. CI/CD, Infrastructure as Code and Safe Releases covers canary and blue-green releases.
The example runs in November 2026 with Python 3.13 and only the standard library. Its request counts and tool replies are invented.
Promoting a release
Promotion moves the same release from one environment to the next once it has earned it. The artifact does not change; the configuration and the evidence do.
| To enter | Required evidence | Who decides |
|---|---|---|
| Test | Change reviewed, manifest created | Automatic |
| Staging | Tests and evaluation gates pass | Automatic |
| Production canary | End-to-end rehearsal, rollback target named | Owner, plus approver for high risk |
| Wider production | Canary rules satisfied for the set window | Automatic with owner able to stop |
Staging is never identical to production. Data is smaller, users behave differently and some services offer only test versions. List the known differences so that nobody assumes staging proved something it could not.
Emergency changes
Sometimes a fix cannot wait. Define a short path in advance: a second person reviews, the safety set still runs, the change is recorded and the full evaluation follows within a stated time. An emergency path with no follow-up becomes the normal path.
Feature flags
A feature flag is a setting read at run time that turns behavior on or off, or selects a variant, without deploying code. Flags separate deploying from releasing.
| Flag type | Agent example | Lifetime |
|---|---|---|
| Release | New planning prompt for a small share of users | Remove soon after rollout |
| Kill switch | Disable the email tool | Permanent and rehearsed |
| Experiment | Compare two retrieval settings | Until the decision |
| Permission | Allow larger refunds for a pilot team | Reviewed with access rights |
| Operational | Use the smaller model during overload | Permanent, documented |
OpenFeature, a Cloud Native Computing Foundation incubating project, offers a vendor-neutral interface for evaluating flags, which can reduce lock-in to one flag service.
Choosing who sees a change first
A flag's targeting rule decides exposure. Choose groups that limit harm and give quick, honest feedback:
| Group | Value | Caution |
|---|---|---|
| The building team | Fast feedback | Not typical users |
| Internal volunteers | Realistic tasks with forgiving users | Narrow range of requests |
| A small random share | Representative comparison | Must stay stable per user |
| Selected customers | Targeted evidence | Tell them, and respect contracts |
| Low-risk task types | Limits consequences | Says little about high-risk behavior |
Hash a stable identifier to choose the share, so the same user stays in the same group as the percentage grows. Do not put people into higher-risk variants because of personal characteristics, and review targeting rules for unfair effects.
Rules that keep flags safe
- Every flag has an owner, a purpose, a default and an expiry date.
- The default is the safe behavior when the flag service cannot be reached.
- Evaluate once at the start of a task and store the result, so a run does not switch halfway.
- Kill switches are the exception: check them again before each effectful action.
- Record flag values on every trace, since they are part of what ran.
- Test the combinations that can occur; ten independent switches make 1,024 possible states.
- Changing a production flag needs the same permission and audit as a release.
- Delete finished flags and the unused code paths behind them.
If a flag can select an untested prompt or model in production, it is a release path without evaluation. Allow flags to choose only among versions that have already passed.
Deciding to roll back
Agree the triggers before release, so that the decision during trouble is quick and calm.
| Observation | First response |
|---|---|
| Forbidden action or data exposure | Stop the capability immediately, then investigate |
| Large fall in task success | Roll back |
| Cost or latency above limit | Roll back or reduce exposure |
| Small, uncertain difference | Hold exposure and collect more evidence |
| Problem also present in the old release | Look outside your change: provider, tool, data |
The last row saves time. Compare the old and new release over the same period. If both degraded, rolling back will not help.
Roll back the smallest thing that fixes the problem: a flag, then a configuration, then the whole release. But do not mix old and new parts that were never tested together; when in doubt, return the full manifest. After rollback, find affected tasks by release identifier, correct their effects and add cases to the suite. Mechanics such as running tasks and data formats are covered in CI/CD, Infrastructure as Code and Safe Releases.
Automated refresh of knowledge and models
Many agents depend on content that changes constantly. Some teams also retrain or fine-tune small models on new data. Automation is useful only with gates at both ends:
- Check incoming data: counts, schema, duplicates, permissions, sensitive content and suspicious instructions.
- Build the candidate index or model separately from the live one.
- Evaluate it on fixed cases, including cases about recently changed facts.
- Compare with the current version and block meaningful regressions.
- Switch a pointer, gradually where possible.
- Keep the previous version and its manifest for rollback.
Retraining directly on user feedback or on the agent's own outputs lets errors and deliberate manipulation reinforce themselves. Sample, review and filter before anything becomes training data (Supply Chain and Retrieval Poisoning).
Schedule refresh by how quickly facts change and how costly stale answers are. Deletions deserve a faster path than additions: a withdrawn document should stop being retrieved promptly (RAG Security, Freshness and Cost).
Five kinds of drift
| Drift in | Example | Detection |
|---|---|---|
| Requests | A new product brings new questions | Category mix, unmatched topics, reviewed samples |
| Data | Documents age or formats change | Freshness, parse failures, retrieval scores on known cases |
| Tools | A field is renamed or error rates rise | Contract checks and result validation |
| Model | A served version behaves differently or is retired | Fixed canary cases run on a schedule; supplier notices |
| Outcomes | More corrections, escalations or repeat contacts | Business measures over time |
Watch causes and effects together. A shift in requests may be harmless if outcomes hold, while falling outcomes with stable inputs point at the model, a tool or the data.
Measuring a shift
The population stability index summarizes how far today's mix of categories is from a reference mix. The example also checks a tool reply against the expected fields.
"""Watch for shifts in what users ask and in how tools reply (invented counts)."""
from math import log
REFERENCE = {"order status": 500, "returns": 250, "billing": 200, "other": 50}
THIS_WEEK = {"order status": 380, "returns": 240, "billing": 190, "other": 190}
EXPECTED_FIELDS = {"order_id": "str", "status": "str", "eta": "str"}
LATEST_REPLY = {"order_id": "A1", "status": "shipped", "eta_date": "2026-12-02"}
def shares(counts):
total = sum(counts.values())
return {k: v / total for k, v in counts.items()}
def psi(reference, current):
"""Population stability index: a summary of how far two mixes differ."""
r, c = shares(reference), shares(current)
parts = {k: (c[k] - r[k]) * log(c[k] / r[k]) for k in r}
return sum(parts.values()), parts
def schema_drift(expected, reply):
return {"missing": sorted(set(expected) - set(reply)),
"new": sorted(set(reply) - set(expected))}
if __name__ == "__main__":
total, parts = psi(REFERENCE, THIS_WEEK)
r, c = shares(REFERENCE), shares(THIS_WEEK)
for k in sorted(parts, key=parts.get, reverse=True):
print(f"{k:<13}{r[k]:>5.0%} -> {c[k]:>4.0%} contributes {parts[k]:.3f}")
print(f"stability index {total:.3f}",
"-> investigate" if total > 0.1 else "-> within limit")
print("tool reply:", schema_drift(EXPECTED_FIELDS, LATEST_REPLY))
Output:
other 5% -> 19% contributes 0.187
order status 50% -> 38% contributes 0.033
billing 20% -> 19% contributes 0.001
returns 25% -> 24% contributes 0.000
stability index 0.221 -> investigate
tool reply: {'missing': ['eta'], 'new': ['eta_date']}
Most of the index comes from the "other" category growing from 5 to 19 percent: something users ask about does not fit the old categories. A person should read those requests. The tool check shows a renamed field, which could leave the agent with no delivery date while no error is raised.
The 0.1 threshold used here is a common rule of thumb, not a law. The index depends on how categories are chosen, cannot be computed safely when a category has a zero share without smoothing and says nothing about quality. Calibrate the threshold on weeks you already know were normal.
Validate every tool result
Scheduled contract checks find changes between tasks. Run-time validation catches them during tasks. Check each reply against its expected shape and plausible ranges before the model sees it. When validation fails, return a clear error that says the data could not be trusted, count the failure and stop dependent actions. Silently passing along a half-understood reply invites the model to fill the gap with a guess.
Watch values as well as shapes. A price that arrives in cents instead of whole units passes a type check and is wrong by a factor of one hundred. Range checks, unit fields and comparison with recent values catch this class of change.
Fixed canary cases
Run a small unchanging set of cases every day against production configuration. Because inputs are fixed, changes in results point to something that moved underneath you. Keep tool replies simulated so the signal isolates model and prompt behavior, and run a separate check against real read-only tool endpoints. Repeat each case a few times and alert on sustained change, since single runs vary.
Reviewed samples
Numbers say that something moved; reading runs says what. Each week, review a random sample plus a targeted one: new request clusters, runs with many steps, escalations and user complaints. Record a short label for each problem found. Rising labels are an early drift signal that no fixed metric anticipated. Limit access to these transcripts, mask what reviewers do not need and delete samples on schedule.
Turning signals into action
| Signal | Action | Owner |
|---|---|---|
| New request cluster | Review, add cases, decide whether to support it | Business owner |
| Schema mismatch | Disable or adapt the tool | Tool owner |
| Canary case change | Check provider notices and traces | Agent engineer |
| Stale sources | Repair ingestion and warn users if needed | Data owner |
| Outcome decline | Open an incident and compare releases | Operations |
An alert with no owner and no action is noise. Remove or improve any that are repeatedly ignored.
Planned change from suppliers
Some drift is announced. Model retirements, interface version removals and tool deprecations arrive with dates. Anthropic's deprecation page describes at least 60 days' notice for publicly released models and notes that partner platforms keep their own schedules; check the equivalent for every supplier you use.
Keep a calendar fed by your inventory, with an owner for each date. Start evaluating a successor early, because the first attempt often reveals prompt, tool or cost changes that take weeks to resolve. Plan to finish well before the deadline so that a rollback is still possible. After retirement day, the old release can no longer be your safety net, so update the recorded rollback target at the same time.
Review the controls themselves
Once a quarter, look at which alerts led to action, which drift went unnoticed until users reported it, how many flags are past expiry and how long the last rollback took. Adjust thresholds and checks from that evidence rather than adding more of everything.
Putting it together
In an illustrative week, the stability index rises. Review shows many questions about a newly launched subscription. Outcome measures dip only for that group. The team does not roll anything back, since no release caused the change. Instead they add the new documents to the index through the gated refresh, write cases from real questions, enable the improved behavior behind a flag for a small share, compare and then widen it. The alert, the cases and the decision are recorded against the release that resolved it.
What to keep from each decision
For every promotion, flag change, rollback and drift investigation, keep a short entry: what was observed, who decided, which release and flag values were involved, what was done and when it will be checked again. These entries explain later why a threshold has its value, show auditors that changes were controlled and give the next person on call a record of what has already been tried. Link them to the release identifier so they appear beside the traces they describe, and review open follow-ups in the weekly meeting until each is closed.
Common mistakes
| Mistake | Better approach |
|---|---|
| Rebuilding the release per environment | Promote one artifact |
| Flags that never expire | Set owners and dates, then delete |
| Flag changes without audit | Treat them as releases |
| Rolling back when the cause is external | Compare both releases first |
| Refreshing indexes without checks | Gate data as you gate code |
| Alerting on every small shift | Calibrate and tie alerts to action |
Checklist
- Entry conditions exist for each environment.
- The emergency path requires review and follow-up.
- Every flag has owner, default, expiry and audit.
- Kill switches are checked before actions and rehearsed.
- Rollback triggers are written before release.
- Refresh jobs have data checks, evaluation and a previous version.
- Canary cases and tool contract checks run on a schedule.
- Each drift alert has an owner and a next action.
Frequently asked questions
Are feature flags the same as configuration?
They overlap, but flags are meant to change at run time for particular users or conditions and should usually have a limited life.
How often should canary cases run?
Often enough that a change is noticed before it causes much harm, balanced against cost; daily is a reasonable start.
Does drift mean the model got worse?
No; requests, data or tools may have changed, so investigate before replacing anything.
Can rollback fix a bad knowledge update?
Yes for future answers if the previous index is kept, but effects of answers already given need separate review.
References and further reading
- OpenFeature: vendor-neutral feature flagging.
- Martin Fowler's site: feature toggles: types and lifetimes.
- Claude model deprecations: an external change to plan for.
- Google SRE workbook: alerting on SLOs.
Next steps
Agent Fleets and Internal Platforms
Run these controls for a whole fleet.
Continuous Evaluation, Statistics and Scorecards
Sample live runs and compare versions.
Loops, Performance, Incidents and Maturity
Handle the cases rollback does not solve.