Joyous Brands

Artificial Intelligence: A Visual Learner's Series

Part 12: AI agents

How a model becomes an agent: a loop that decides, acts and checks, with tools, memory, teammates and guardrails.

The agent loop

In one line: An agent is a model in a loop: decide, act, observe, and repeat until the goal is met or a limit is hit.

An agent loops: decide, act, observeNobody writes the steps in advance; the model picks each one from what it has seen so farReadthe goal + latest resultsDecidethe model picks the next stepStopgoal met, ask for help,or budget spentActcall a toolObserveread the tool's result
  • "Find a time Sam and I are both free": check your calendar, check Sam's, Tuesday fails, try Wednesday, send the invite.

  • A workflow follows steps people wrote in advance; an agent chooses its own. Many systems sit in between.

Watch out: If the steps are known in advance, a fixed workflow is cheaper, faster and easier to test.

Tools

In one line: A tool is a named function with a description and typed inputs; the model asks for it, and the program around the model runs it.

  Model asks:    {"tool": "check_stock", "args": {"item": "mug"}}
  Program:       checks the request against the schema, runs check_stock("mug")
  Model sees:    4
  Model asks:    {"tool": "place_order", "args": {"item": "mug", "qty": 2}}
  • Tools range from read-only (search, look up) to side effects (send, buy, delete), some irreversible.

  • Common tools: web search, running code, files, email, calendars, and computer use (clicking and typing on a screen). Standards like the Model Context Protocol (MCP) let one tool work with many agents.

Watch out: Agents choose tools by their descriptions, so a vague description leads to the wrong call.

Planning and memory

In one line: An agent thinks a step ahead, checks each result, revises its plan, and keeps notes it can find later.

  Thought:       The test fails. Read the error first.
  Action:        run_tests()
  Observation:   error in config file, not in the code
  Thought:       Not what I expected. Update the plan.
  Action:        open_file("config")
  ...
  Action:        run_tests()            ← check the fix, don't assume it
  Action:        save_note("tests need the database running")
  • ReAct alternates thought, action and observation; plan-and-execute plans first and replans when surprised.

  • Short-term memory = the context window (limited); long-term memory = notes and databases outside the model, searched when needed.

Watch out: A plausible plan can still be wrong. Check results against the world, not against the plan.

Many agents

In one line: Split a big job: an orchestrator delegates pieces to workers running in parallel, and a reviewer checks the result.

An orchestrator splits the work; a reviewer checks itEach worker gets a fresh context holding only its own subtaskRequestcompare 5 laptopsOrchestratorsplits and assemblesWorker 1researches laptop AWorker 2researches laptop BWorkers 3–5laptops C, D and EReviewerchecks claims vs sourcessends back 2 unsupported claims to fix
  • Other patterns: parallel attempts (keep the best), generator and evaluator (critique and repeat), handoffs to a specialist agent.

Watch out: More agents cost more, and a reviewer built on the same model can share the writer's blind spots.

Reliable and safe

In one line: Test over many runs, limit what the agent can touch, and make a person approve the actions that matter.

Every action passes guards before it runsA failed check sends an error back to the agent; nothing happens in the worldProposedthe modelasks for a toolSchemaright tool,right inputs?Permissionallowed forthis task?Approvala person OKsrisky stepsSandboxruns walled offfrom the restLogevery actionrecordedBlocked: error returned to the agent

Errors compound: the chance of finishing a task when every step must succeed.

Steps in the taskEach step 95% reliableEach step 99% reliable
195%99%
577%95%
1060%90%
2036%82%
  • Evaluate over many tasks and runs, and inspect the trajectory (every action), not just the final answer.

  • Least privilege: only the tools a task needs. Budgets cap steps, time and spending.

  • Prompt injection: text in a web page or email can try to steer the agent, and for an agent, words can become actions.

Watch out: People shown hundreds of approval requests stop reading them, so save approvals for the actions that matter.

Self-test

  1. Redraw the agent loop for an agent that books a restaurant table, and mark where it should stop and ask you.

  2. Draw the tool-call round trip for a weather tool, labeling which parts the model does and which the program does.

  3. Sketch an orchestrator with workers for planning a three-city trip, then add a reviewer and what it checks.

  4. Draw the guard pipeline for an agent that can send email, and mark which guard stops "email my whole contact list."