An agent is a model that can take actions: search, query a database, run code, call an internal API.
The useful version is boring: a loop with a small tool list and a stop condition.
A simple agent loop
- Read the user request
- Decide: answer now, or call a tool
- Run the tool
- Inspect the result
- Repeat until done or a max-step limit hits
max_steps = 5 tools = [search_docs, get_order, create_ticket]
What to constrain
- Which tools exist — fewer is safer
- What arguments are allowed — schemas, not free text
- How many steps — agents love to wander
- What success looks like — validate tool output before sending it back to the model
When you should not use an agent
If one retrieval + one generation answers the question, skip the agent.
Extra tool calls add latency, cost, and new failure modes.
Where agents show up
Use cases I will actually build:
- Look up an order, then answer
- Search docs, then answer with citations
- File a ticket only after the user confirms
I will not build an agent whose job is “figure out the company.” That is a demo.
Prompting the loop
The agent prompt has to say when to stop, which tools exist, and what to do when a tool errors. ReAct prompting is the simple shape: reason about the next step, act with one tool, observe the result, repeat. You do not need the brand name. You need the loop to be visible in logs.
Three ways to build it
- Manual implementation — your own loop. Most control. This is what I want once the feature matters.
- OpenAI functions / tools — the API returns a tool call, your code runs it, you send the result back. The usual production path.
- OpenAI Assistant API — threads, tools, and file search hosted for you. Fine for a prototype. Harder to eval and to version than a loop you own.
Next
When the input is not text — photos, audio, and generated images: