Build and test your first tool call

Replay a model’s tool request, fix a bug in the Python tool, and verify the change with five regression checks. Free, with no API key or packages to install.

Run the baseline

Open a terminal in the folder where you saved first_agent.py. You need Python 3. On Windows, try py -3 in place of python3.

python3 first_agent.py --check

Expect 4/5 passed and exit code 1. The notebook lookup fails even though it exists in the built-in inventory.

Read the trace

python3 first_agent.py --prompt "How many notebooks are in stock?"

In the starter, find the corresponding entry in RESPONSES. The simulated model calls lookup_stock with " Notebook ". Compare that argument with the key in INVENTORY. The trace confirms the model picked the correct tool. The bug is in how the tool handles its argument.

Fix the tool

Edit lookup_stock so it removes surrounding spaces and accepts the same item regardless of letter case. Keep the unknown-item response, zero stock, and direct replies working.

Run python3 first_agent.py --check again. You’re done when it prints 5/5 passed and exits with code 0.

Show a reference solution
def lookup_stock(item):
    return INVENTORY.get(item.strip().casefold(), NOT_FOUND)

Extend the check

Add a recorded response with a different casing for pen, then add an eval expecting zero stock. A real provider can produce many variants, so the next step is to grow your fixture with failures you actually observe.

The starter uses fixed model responses and a read-only fixture. It measures how the program handles a tool call, a result, and a turn without tools.

Keep building

You can share a passing result or blocker on GitHub or send it privately by email. Reporting is optional, and the local checks send no data.