An AI agent is just a prompt loop with a goal, a set of tools, some memory, and the ability to keep going until it decides it is done. Strip the hype and what's left is mostly prompt engineering — the same techniques from the rest of this section, composed into a system that can take multi-step actions on its own.
"Agent" is the most over-loaded word in modern AI. To some people it means a chatbot. To others it means a self-driving piece of software that can book your flights, refactor your codebase, and renegotiate your bills. For this tutorial we will use a tight, useful definition: an agent is a system in which a language model is given a goal, a set of tools, and a memory, and is allowed to autonomously decide what to do next until the goal is achieved or a stop condition is met.
Almost everything in this definition is something you have seen already in this section — function calling, ReAct loops, memory layers, structured outputs. The agent is the composition. The interesting questions are how to compose them so the system is genuinely useful instead of impressively erratic.
A workable agent architecture has six parts. None of them are exotic; the craft is in how carefully each one is designed.
"Just tell the model to figure it out"
System: You are an autonomous AI agent. The user will
give you a goal. Use the tools available to achieve it.
Tools: web_search, file_write, send_email, run_shell,
delete_file, transfer_money, ...
User: Plan my parents' 40th anniversary trip.
This is a demo, not a product. The agent has a sweeping toolset, no step cap, no spending limit, no plan structure, and no checkpoints. On a good day it's charming. On a bad day it sends a real email to the wrong address or burns $40 of tokens looping on a stuck step.
A bounded agent prompt
# Role
You are a trip-research agent. You plan but do not book.
# Goal
Produce a single Markdown itinerary for the user's trip
that includes: 3–5 flight options, 3 hotel options, and
a day-by-day plan for the destination.
# Tools (all read-only)
- web_search(query)
- get_flight_options(origin, destination, dates)
- get_hotels(city, dates, max_price_per_night)
- finish(answer)
# Process
1. Restate the user's goal in your own words.
2. List the sub-tasks you will work through.
3. For each sub-task, call at most 3 tools.
4. When you have enough information, call finish() with
the itinerary as a single Markdown document.
# Hard limits
- Maximum 12 tool calls.
- Maximum 8,000 tokens of total tool output.
- If a tool fails twice, skip that sub-task and continue.
- Never call a tool not in the list above.
- Never claim to have booked anything.
# User goal
{{user_goal}}
The agent now has a tight scope, four read-only tools, an explicit planning step, and clear stopping conditions. It produces a useful itinerary in well under a dollar and never silently does something destructive.
Tip: The single most useful agent design instinct is narrow the scope. A tightly scoped agent that does one job extremely well is dramatically more useful (and safer) than a general-purpose agent that does everything mediocrely. The same applies to humans you hire.
Design a research agent with exactly three read-only tools: web_search, fetch_page, finish. Give it a fact-finding goal with a clear success criterion. Cap it at 10 tool calls. Run it on five different questions. Note which ones succeed and which loop.
Add a planning step to the same agent: it must output a numbered plan before any tool call. Compare the new behaviour to the no-plan version. Plans usually halve wasted calls.
Build an end-to-end evaluation: 10 goals, 10 expected outputs, an LLM judge that scores the agent's final answer on a 1–5 rubric. Use it to compare two versions of the agent's system prompt. This is the kind of harness that turns agent work from art into engineering.
Sign in to join the discussion and post comments.
Sign inPrompt Engineering for Content & Copywriting
Write blogs, ads, emails, and social media content ten times faster with AI. 13 practical tutorials on prompt engineering for content creators and copywriters.
Prompt Engineering for Specific AI Tools
Tool-by-tool mastery — deep dives into ChatGPT, Claude, Gemini, GitHub Copilot, Midjourney, Stable Diffusion, and more. Learn the exact prompting techniques each platform rewards.
Prompt Engineering for Developers
Use AI as your coding co-pilot. 18 tutorials on writing prompts to generate clean code, debug faster, write tests, build APIs, and ship better software.
Foundations of Prompt Engineering
The must-know basics of prompt engineering. Learn what prompts are, how AI models read them, and how to write clear instructions that get great results.
Prompt Engineering for Education & Learning
Use AI as your personal tutor. Learn how to study faster, create lesson plans, generate practice questions, master languages, and prepare for competitive exams with smart prompts.
Prompt Engineering for Business & Productivity
Use AI to work smarter — automate tasks, make better decisions, and communicate professionally. 12 practical business prompt tutorials for professionals.