COURSE LAB

The Model Call You Pay For Twice

A weather agent on Restate is killed in the middle of a durable pause. When it comes back, Restate replays the journal: the tool result is recorded, but a model call made outside ctx.run is not, so the replay pays for it again. Let the model answer differently and the replay fails with RT0016; let it stay different and every retry pays again until the invocation pauses. One line — ctx.run_typed around the model call — fixes the replay bug behind all three. The last experiment kills the fixed agent mid-call and finds the window that line cannot close: until Restate records a result, the call can run again.

Run it on your computer

Start each experiment from this page

  1. Read the exercise
  2. Predict the outcome
  3. Run it here
  4. Watch it break
  5. Inspect the evidence
How local execution works
  • agent-runtime is open source and runs on your computer. This page reaches it only at 127.0.0.1; nothing runs on SciMigo's servers.
  • Connecting asks in your terminal whether this site may run lab actions. With that access the page cannot send code to run; it can only start commands you have approved.
  • Setting up a lab downloads its repository at a pinned commit and lists every command it can run. You approve that list once, in your terminal. A new commit needs a new approval.
  • It is not a sandbox. Approved commands run as you, with your normal access to files, the network and processes, exactly as if you had typed them. Read the lab repository before you approve it, as you would before running it yourself.
  • Stop it at any time with Ctrl-C in its terminal. The security notes describe exactly what pairing and approval do.

With agent-runtime running on your machine, this page can start the lab's scenarios and show their output here. It runs only the commands listed in the lab repository, after you approve them in your own terminal.

The Model Call You Pay For Twice · Lab