Agents and Tool Use

Suman SharmaSuman Sharma

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.

Robot hand reaching toward light — agents that take real actions

A simple agent loop

  1. Read the user request
  2. Decide: answer now, or call a tool
  3. Run the tool
  4. Inspect the result
  5. 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:

Contact

Get in Touch

Want to call me? book a call and I'll respond in the available time slot. I will ignore all soliciting.