Is the extra call worth it?
The hit rates, latencies and tokens are made up to show the calculation. The price is an example: use your provider's. Measure your own numbers.
Recipes to copy: a standalone-question prompt with a reply guard, a multi-query fuser, a router with a safe default, and a checklist with numbers for deciding whether an extra model call earns its place.
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 decide(gain, ms, min_gain, max_ms) returning keep or drop by the rule in the example. Print the decision for (9, 450), (33, 450) and (1, 900) with min_gain = 5 and max_ms = 600.
Write fuse_top(rankings, n) returning the top n ids by reciprocal rank fusion, joined with commas. Print it for [["a", "b"], ["c", "a"]] with n = 2.
Explain it without notes
What does the guard on a rewrite do, and which checks does it make?
How do you decide whether a multi-query step is worth it?
What belongs in the log of a query layer?
Why should a router have a default, and what should it be?
Expected output
rewrite with a model +9 points, +450 ms, 0.024 dollars per 1000 queries -> keep
standalone question +33 points, +450 ms, 0.040 dollars per 1000 queries -> keep
three phrasings fused +1 points, +900 ms, 0.080 dollars per 1000 queries -> drop