Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 14.7 — Playbook: The Whole Course on One Page
LLM Engineering · Example 2 of 4

Recipe: the resilient call (jitter, fallback, cache, cost)

Seeded jitter and a simulated clock. Prices are example values in micro-dollars per million tokens.

Every recipe from the course, one per phase, with the topic where you built it, a symptom lookup, and four runnable recipes that are used together most often: typed calls, resilient calls, a safe tool runner and an evaluation gate.

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 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write pick_label(raw, allowed) that returns the one allowed label found (ignoring case) in the model's raw reply, or other when none or more than one is found. Print results for Billing, I think shipping or billing and no idea with the allowed labels billing and shipping.

02

Write tally(events) that counts outcomes such as ok, retry and fallback in a list, and print the counts sorted by name.

Explain it without notes

01

If you had one day to make a prototype production-ready, which recipes would you add first, and in what order?

02

How do you decide whether a new recipe or guard is worth adding?

03

A quality drop is reported a week after a prompt change. Which recipes would have caught it, and how?

Recipe: the resilient call (jitter, fallback, cache, cost)
Sign in to run this example in your browser.

Expected output

q1: answer to q1 [backup] (clock 114 ms, cost so far 60 micro-dollars)
q2: answer to q2 [primary] (clock 139 ms, cost so far 235 micro-dollars)
q1: answer to q1 [cache] (clock 139 ms, cost so far 235 micro-dollars)