interactive · 10 min

The Mock LLM

Objective: make the policy a mock LLM — a deterministic prompt -> response you fully control — so you can learn agent mechanics without keys, cost, or flakiness.

A real LLM is just prompt -> text. For learning, a dictionary-backed mock gives the same interface with none of the nondeterminism. Every later module reuses exactly this seam; only the implementation behind it changes when real models arrive.

This is the same policy(observation) -> action seam from the previous lesson, just named for the LLM’s perspective: the observation is the prompt you hand the model, and the action is the response it returns.

Model

Mock is the default and free. Switch the Model toggle above to Real (your key) to run this same code on your own OpenAI-compatible model — a real model may not reply in this exact tool:/answer: shape yet; tightening that is what the next few lessons add.

Here we call the policy one step at a time (agent_step) instead of the full agent_loop from the previous lesson — the loop is unchanged, we’re just isolating the policy call to see the mock respond.

The interface never changes when you go from this mock to a real model — agent_step still just takes a prompt and gets back a string decision. Only the line that produces decision swaps llm(prompt) for a real model call behind the Model toggle. That is the entire point of the seam.

Best practice: write every agent against a policy interface, then develop and test against a deterministic mock. Real-model wiring becomes a one-line swap, and your tests stay fast and reproducible.

Next: Anatomy of an Agent — name the parts you just used.