Skip to main content
Handbook/Amplify/Chapter 66 · AI Agents

Agents in Your Product

Share

Share this page

Pass it to someone who needs it.

Key takeaway: Use an agent when a call isn't enough

You added an AI feature to your app, and for a while one model call did the job: text in, answer out. Then it needed more: look something up, decide what to do, then act, sometimes several times over. That is the moment a plain call becomes an agent, and not the kind that builds your code, but one you ship inside your product for your users. This chapter gets you knowing when your product needs an agent, and how one works.

7.3.1A call answers; an agent acts

A plain call answers. You send text, the model sends text back, and the exchange is over. An agent acts instead: it runs a loop, deciding and doing and checking until the task is actually done.

Each time around, it decides the next step, calls a tool (a function you let it run to fetch data or take an action), and reads the result before deciding again. The loop, not the wording of any one reply, is what makes it an agent.

A plain call is one shot; an agent loops, calling tools until the task is done.

7.3.2Give it tools, not just words

Words tell the agent what you want; tools are what let it act on the world. A tool is a plain function with a name, a short description so the model knows when to reach for it, and the inputs it takes.

# A tool the agent may call tool lookup_order: description: "Look up one order by its id." input: { order_id: string } access: read-only # The loop that decides when to use it while not done: step = model.decide(context) # think if step.wants_tool: result = run(step.tool, step.args) # call context.add(result) # observe else: answer = step.text # model has it done = true

That loop is the whole engine. The real design work is which tools you expose, and how tightly you scope each one.

7.3.3Reach for a framework when the loop gets real

You can write that loop yourself, and for one or two tools you should: it is a dozen lines and you understand every one. Libraries such as LangChain and LangGraph exist to handle the loop, the state, and the tool wiring once it grows.

Name them as options, not defaults. Reaching for one too early buys complexity you have to learn before you have a problem it solves.

Keep it a simple loopReach for a framework
One or two toolsMany tools to coordinate
A few steps, then doneLong or branching runs
You can read every lineState and retries to manage

7.3.4Keep it on a leash

An agent with tools can do real damage, because a tool is real power and the model decides when to pull it. Give each tool the least privilege that still does the job: read-only over write, a scoped key over a master key, a test target over production.

For anything you cannot undo, deleting data, sending money, emailing users, the agent proposes and a human approves. It is the same discipline the security chapters apply to agents that read untrusted input: the shorter the leash, the less any mistake or attack can reach.

Ready prompt
Act as a senior AI engineer. Look at the feature I describe and answer the honest question first: does it actually need an agent, or is one model call enough? If a plain call does the job, say so and stop there. If it truly needs an agent, design the smallest one that works. List only the tools the task requires, and give each the least privilege that still works: read-only over write, a scoped key over a master key, a non-production target by default. Put a human approval step in front of every irreversible action (delete, send money, email users). Show the tool definitions and the think, call, observe loop. My feature:

Do this now: paste the prompt, and only if your feature truly needs an agent, wire the smallest tool-using loop with least-privilege tools and an approval gate before any action you cannot undo.

Mahmoud Zalt

Mahmoud Zalt

Software engineer, 16+ yrs · built Sistava.com in 3 months, idea to production, using these methods

Resources
Contribute
Donate

Support my work

A small tip keeps the free work coming.

© 2026 Mahmoud Zalt. Free to read, not to republish.
Copyright & license