What we are building
What it is
A small Kirana Kart support agent that can resolve a late-delivery complaint. It has:
- three tools: look up an order, read a policy, refund a delivery fee;
- a system prompt stating its job and rules;
- a loop that calls the model, runs the tools it asks for, and feeds back the results;
- stopping rules: a step limit and a token budget;
- error handling: bad inputs, unknown tools, tool failures and model refusals.
It needs Python 3.10 or later, pip install anthropic, and an API key in the ANTHROPIC_API_KEY environment variable.
Why it matters
Building it by hand shows that an agent has no hidden machinery.
- The model only ever returns text and tool requests.
- Everything else is ordinary code that you can read, test and change.
- Once you have seen this, every framework in module 21 is recognisable as these same parts with different names.
In the real world: A team stuck for a week on a framework agent that 'randomly stops' rewrites it as this hundred-line loop in an afternoon and finds a tool returning an empty string.
Visual example
Build orderEach step is one card below. The last card is the whole file.
Starting with a framework 'to save time'. You save an hour and lose the ability to see what is sent to the model. Write the loop once first.