A percentage rollout with a stable hash and a rollback
The same user always gets the same bucket, so a user never flips between versions during the rollout.
Prompts, model names, limits and thresholds change much more often than code. Keep them in versioned configuration, switch features with flags, roll changes out to a percentage of users using a stable hash, watch the metrics, and roll back by changing one value instead of redeploying.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write bucket(text) with the same hash as the example and print the buckets of "anna" and "ben".
Write enabled(user, flag, percent) using bucket(flag + ":" + user) < percent and show that percent 0 enables nobody and 100 enables everybody for ten users.
Explain it without notes
Why treat prompts and model names as configuration?
How does a percentage rollout choose its users, and why must it be stable?
What makes a rollback fast and safe?
What should be logged so that a quality drop can be traced to a change?
Expected output
buckets: u1=57 u2=76 u3=95 u4=14 u5=33 u6=52 u7=71 u8=90 u9=9 u10=70
rollout 30 percent: 2 of 10 users on v2 -> v1 v1 v1 v2 v1 v1 v1 v1 v2 v1
rollout 60 percent: 5 of 10 users on v2 -> v2 v1 v1 v2 v2 v2 v1 v1 v2 v1
rolled back: 0 of 10 users on v2 -> v1 v1 v1 v1 v1 v1 v1 v1 v1 v1