Define honest execution states and a budget for live requests.
Understand the method
Use explicit idle, running, complete, failed and canceled states. A timeout does not justify filling the result with a fixture. Explain whether the user should retry or change the input. Limit retries for transient failures; do not repeatedly retry invalid input or credentials.
Cost depends on provider, model and measured usage. Set output bounds, per-user quotas and a total budget, then reconcile provider receipts. Verify success, timeout, rate limiting and cancellation. Without live requests, describe your outcome as interface design and offline validation, not a working model integration.
- 1Set budget
- 2Bound execution
- 3Observe state
- 4Check receipts
Included material
Budget exercise: at most 10 daily calls, with at most 800 output tokens each. Leave prices blank until you choose a provider and record its current prices and verification date.
Work through the steps
- Write user messages and next actions for all four paths.
- Define timeout, retry bounds and cancellation behavior.
- Package the contract, validation results, state table and budget.
Worked example
Timeout: no complete result; retry later without a fabricated summary. Rate limit: honor the service retry guidance, at most two retries. Cancel: stop the request, keep input, label partial text incomplete. Success: structure validated; check factual content against the source.
Your exercise
Complete the four deliverables and define the final state after two unsuccessful retries. If you optionally call a live model, keep actual status and usage and exclude credentials from notes.
Check before delivery
- Failure and cancellation never appear as completion.
- The budget distinguishes limits, estimates and actual charges.
Finish the exercise, then view the reference
After bounded retries, mark the request failed, preserve input and the reason, and allow a later user-initiated retry. Do not loop indefinitely or reuse an offline fixture as the result.
An original course with teaching exercises. Reading records, practice outcomes and independent certification are distinct.