Lesson 02.07 · Phase 02 · Tool Use & Function Calling
Idempotency and side effects
Agents repeat calls: retries, resumed runs, models that call twice. Design write tools so the second call is harmless, and make the dangerous ones ask before they act.
Learning objectives
- Classify tools by effect: read, idempotent write, non-idempotent write, irreversible.
- Implement four tool designs that make repeats harmless: set instead of add, request ids, compare-and-set, and preview-then-commit.
- Simulate at-least-once delivery and measure the wrong outcomes each design produces.
- Replay a real model's calls and see which tool design survives it.
A tool call can be delivered more than once without anyone doing anything wrong:
Loading the full lesson…