A chatbot answers. An agent works.
A chatbot reads your question and writes one reply. That's it.
An agent looks at your request and figures out what steps need to be taken. Then it acts: it runs code and gathers information from different sources. It looks at the results, and then decides what to do next.
A chatbot
An agent
↻ Again, until the job is done
Understand, think, then act.
Every agent runs the same loop. It comes from a 2022 research paper called , short for reasoning and acting.
"ReAct: Synergizing Reasoning and Acting in Language Models", Yao and others, 2022. Instead of answering in one go, the model writes a thought, calls a tool, reads what came back, and repeats until it's done.
# the whole idea, in a few lines history = [goal] while True: thought = model.think(history) # Reason if thought.is_final_answer: return thought.answer # Decide: done result = run_tool(thought.tool, thought.input) # Act history.append(thought, result) # Observe, then loop
What makes it an agent.
Agents are systems with , , and .
The model reads the request and everything it has so far, and writes down what should happen next before it does anything. Writing the thought first makes the next step easier to check.
Breaking a goal into ordered steps, where each step knows what it needs from the one before.
plan = model.plan(goal) # e.g. ["find dates", "pick hotel", "book"]
for step in plan:
result = do(step, context)
context[step] = result
Short-term memory is the conversation and the shared notes for one job. Long-term memory is anything kept between jobs, such as a database or files. The model itself remembers nothing between calls, so memory always lives outside it.
Agents have enough autonomy to make decisions on behalf of the user.
Super Team's agents decide the steps. You decide what goes out.
Three types of agents.
Not all agents behave the same way. Pick the type that fits the problem. Here's each one, with a question from a business owner's week.
- Best for
- Simple, predictable flows.
- Find every invoice 30 days late.
- Skip disputes and anyone chased this week.
- Draft one reminder per client.
Same steps every time. You want no surprises with clients and money.
- Best for
- Dynamic work that changes as it goes.
- Reads this month's payments. They're down.
- Looks by client. One paid nothing.
- Opens that client's invoices. Two are late, one is disputed.
Each answer picks the next step. No one could list them in advance.
- Best for
- Multi-step goals with dependencies.
- Writes the plan: forms, accounts, receipts.
- Gathers the 1099 forms you'll need.
- Checks each account against the bank, then lists missing receipts.
The receipts list depends on the check before it. So it plans first, then works through the list.
Build one: an agent that writes blog posts.
Give it a topic. It plans an outline, checks it, writes the post, checks that too, then suggests other titles. Three agents share the work.
↻ Up to 3 tries
↻ Up to 3 tries
blog_outlineblog_postHere's how to build it, step by step. Tap a blue word to see the code behind it. The code is a sketch: every agent toolkit has the same parts under different names.
-
Set up a project.
Make a project folder and install your AI provider's . Then make one file to hold your agent.
Agent toolkit (SDK)Every agent toolkit gives you the same few parts: a way to call a model, a way to define an agent, a way to hand it tools, and a way to run it. Keep your model name and API key in an environment file, never in the code.
# .env MODEL="your-model-name" API_KEY="..." # agent file from agent_toolkit import Agent, LoopAgent, as_tool, Runner MODEL = read_env("MODEL")
-
Make the planner.
Its only job is to turn a topic into an outline. Give it a name, a model, and an that spells out exactly what to produce. Then save what it writes to , so the next agent can pick it up.
InstructionThe instruction is the agent's job description. The more exactly it names the output, the more reliable the output gets. The description is only a note for people.
planner = Agent( name = "blog_planner", model = MODEL, description = "Turns a topic into an outline", # for people instruction = """Write a markdown outline with: a title, a short introduction, 4 to 6 sections with bullet points, and a conclusion.""", output_key = "blog_outline", # where the result is saved )Shared stateA set of named notes that every agent in one run can read and write. The planner saves to
blog_outline. Any later agent can put{blog_outline}in its instruction and get the outline filled in.state = {} state["blog_outline"] = planner_output # written by the planner writer_prompt = fill("... {blog_outline} ...", state) # read by the writer -
Add a checker for the outline.
This agent writes nothing new. It reads the outline and gives a strict : OK if it has a title, an intro, 4 to 6 sections and a conclusion. Retry, with what's missing, if not.
Validation checkerA second agent with one job: say pass or fail in a fixed word, so code can read the answer without guessing.
outline_checker = Agent( name = "outline_checker", model = MODEL, instruction = """Read {blog_outline}. If it has a title, an introduction, 4 to 6 sections and a conclusion, reply exactly: OK Otherwise reply: RETRY, then say what is missing.""", ) -
Put the planner and checker in a loop.
Run the planner, then the checker. If the checker says OK, you're done. If it says retry, plan again. Stop after 3 tries. This is your safety net: if the model forgets something, it gets another chance.
Loop agentA loop agent isn't powered by a model. It's plain code that runs its agents in order, again and again, until a stop rule is met or it runs out of tries.
robust_planner = LoopAgent( name = "robust_blog_planner", agents = [planner, outline_checker], # run in this order max_iterations = 3, stop_when = lambda state: state.last_reply.startswith("OK"), )Tip: pass the checker's reason back to the planner, so the next try fixes the right thing.
-
Make the writer.
It reads the saved outline and turns it into a . Its instruction says who the readers are, what to skip, what to explain, and to follow the outline's headings. Save the result as the post.
WriterThe same kind of agent as the planner, with a different instruction. It reads the outline from the shared notes and saves its post under a new name.
writer = Agent( name = "blog_writer", model = MODEL, instruction = """Turn {blog_outline} into a full markdown blog post. Readers: [your audience]. Skip the basics. Explain both how and why. Add short examples where they help. Follow the outline's structure, with proper headings.""", output_key = "blog_post", ) -
Check the post, and loop the writer too.
A reads the post. Does it have an introduction, sections that match the outline, a conclusion, and clear explanations? If yes, OK. If not, retry, with the fixes it needs. Put the writer and this checker in their own loop, up to 3 tries.
Post checker and writer loopThe same pattern as the planner: an agent that gives a fixed verdict, and a loop that retries until it passes.
post_checker = Agent( name = "post_checker", model = MODEL, instruction = """Read {blog_post}. Check for an introduction, sections that match {blog_outline}, a conclusion, and clear explanations. Reply exactly OK, or RETRY and list the fixes.""", ) robust_writer = LoopAgent( name = "robust_blog_writer", agents = [writer, post_checker], max_iterations = 3, stop_when = lambda state: state.last_reply.startswith("OK"), ) -
Turn each loop into a tool.
Wrap the planner loop and the writer loop so each one works like a single . The conductor can call them without knowing what happens inside.
Agent as a toolA tool is anything an agent can call by name, with an input and an output. Wrapping a whole loop as one tool hides its steps and retries from the agent that calls it.
planner_tool = as_tool(robust_planner) # input: topic, output: outline writer_tool = as_tool(robust_writer) # input: outline, output: post
-
Make the conductor.
This is the , the one you talk to. When you give it a topic, it calls the planner tool for an outline, then the writer tool for the post. Last, it adds 3 other titles and 2 tweet-length hooks. It gets those 2 tools and nothing else, so what it does stays clear and controlled.
Root agentThe top agent in a team. It takes the request and delegates. Giving it only the tools it needs is what keeps it on track.
conductor = Agent( name = "blogger", model = MODEL, instruction = """When the user gives you a topic: 1. Call the planner tool to make an outline. 2. Call the writer tool to draft the full post. 3. Add 3 alternative titles and 2 tweet-length hooks.""", tools = [planner_tool, writer_tool], # nothing else ) -
Run it, and give it a topic.
Start it from your terminal. Most toolkits also give you a small chat page in your browser. Then for a post, like "the top 10 use cases for AI agents", and watch it plan, check, write and check again.
Running the agentA runner takes your message, starts the root agent, and keeps the shared notes for the run.
runner = Runner(agent=conductor) reply = runner.run("Write a blog on the top 10 use cases for AI agents") print(reply) # the post, 3 titles, 2 hooks