Building my first production AI agent
The demo was easy. A prompt, a couple of tools, and within an afternoon I had something that looked like an agent. Getting it to a place where I'd let it run unattended — that took another three weeks, and almost all of the lessons were about everything around the model, not the model itself.
Here's what actually moved the needle.
Start with the smallest useful loop
My first version tried to do too much in one pass. The rewrite did one thing: read a task, pick a tool, act, observe the result, and decide whether it was done. That plain loop is the whole game:
while not done:
thought = model.plan(context)
action = thought.tool_call
result = tools.run(action)
context += observe(result)
done = thought.is_complete
Everything else — retries, logging, guardrails — hangs off that skeleton. Keeping it visible meant I could actually reason about where things went wrong.
Tools are the product
The model is only as good as what you let it touch. I got the biggest reliability
gains not from a better prompt but from better tool definitions:
- Narrow inputs. A tool that takes one
order_idbeats one that takes a free-form query. - Loud errors. When a tool fails, it returns why, so the agent can correct instead of guessing.
- Idempotency. Running the same action twice should be safe — agents retry more than you expect.
If a junior engineer couldn't use your tool correctly from its description alone, neither can the model.
Guardrails beat cleverness
The version I trust today isn't smarter — it's more constrained. It has a hard step limit, a budget cap, and a short allow-list of actions that can touch anything irreversible. Anything outside that list pauses and asks me. Boring, and exactly why it can run without me watching.
What I'd tell past me
Ship the boring loop first. Spend your time on tools and guardrails, not prompt gymnastics. And log everything — the transcript of a failed run is the most useful debugging artifact you'll have.
Next up I'm turning this one loose on a real backlog and measuring how many hours it gives back. I'll write that up too.