An AI agent is not magic, even when it acts like it. The mechanism underneath is straightforward enough that a non-developer can hold the whole picture in their head. This explainer walks through the picture without jargon, with one concrete example, and with a clear-eyed view of where the picture breaks. The companion definitional post is at AI agent vs chatbot vs assistant; the workflow contrast is at describe outcome, not workflow.

After three startups in this space, the framework that survived for explaining agents to non-technical buyers is a four-line story: perceive, reason, act, observe. Repeat. The loop runs until the goal is done or something breaks. Everything else, the model choice, the prompt engineering, the tool catalog, the memory layer, is technique. The story is the loop.

The core loop

The core loop is four steps. Perceive: the agent looks at the situation. That can mean reading new emails, checking a calendar, polling an API, watching a webhook, or receiving a user message. Reason: the agent decides what to do next. Reasoning is where the language model earns its keep, considering the goal, the situation, and the available tools. Act: the agent calls a tool, sends a message, updates a database, or schedules a follow-up. Observe: the agent looks at the result of the action and updates its understanding of the world.

Then the loop repeats. The agent perceives the new state, reasons about whether the goal is closer, decides whether to act again or stop, and so on. The loop continues until one of three things happens: the goal is met, a budget is exhausted, or the agent escalates because it cannot make progress. This stopping logic is where most amateur agent implementations fail; getting it right is harder than it looks.

The brain inside the loop

The brain is a language model. In 2026, that usually means GPT-4-class, Claude-class, or Gemini-class systems. The brain takes a prompt that describes the goal, the current situation, the previous actions, and the available tools. The brain produces a response that says either "do this next" or "I am done" or "I need help".

The model itself is stateless from one call to the next. Everything the model knows about the world during a particular call has to be in the prompt. The orchestration layer's job is to maintain the state across calls, format the prompt with the relevant pieces, and parse the model's output into something actionable. This is the architectural fact that distinguishes an agent from a chatbot: the chatbot just calls the model; the agent maintains state and feeds the model a prompt that lets it act consistently across many calls.

Tools the agent uses

Tools are how the agent acts on the world. A "tool" is anything the agent can call: a Gmail API, a calendar API, a database, a custom function the developer wrote, even a simple calculator. Without tools, the agent can only generate text, which makes it a chatbot. With tools, the agent can do things: send messages, schedule meetings, update records, run scripts.

Modern model APIs from OpenAI, Anthropic, and Google support tool use directly. The model returns a structured object that says "call this tool with these arguments" instead of returning prose. The orchestration layer executes the tool and feeds the result back to the model on the next loop iteration. The mechanics of this are explained in the OWASP LLM Top 10 documentation and the Anthropic engineering posts on building effective agents.

Memory and state

Memory is what turns the loop into something useful over time. Three kinds of memory matter. Short-term memory is the working state inside a single task: the recent steps, the recent observations, the current plan. Long-term memory is what the agent knows about the user and the world from prior runs: preferences, patterns, configurations. Episodic memory is the record of past tasks: what was tried, what worked, what failed.

A chatbot has only short-term memory, and only within a session. An assistant carries some long-term memory tied to the user. An autonomous agent carries all three, and the persistence of long-term and episodic memory is what makes the agent feel like a worker rather than a tool. Anthropic's "Engineering Reliable Agents" guidance and OpenAI's Assistants API documentation both walk through the memory architecture in implementation terms.

The agent loop Perceive read inputs, check state Reason model decides next step Act call tool, send message Observe read result, update state Loop continues until goal is met, budget exhausted, or escalation triggered.
The four-step loop runs until one of three stopping conditions fires. The model is the brain; the loop is the agent.

A walkthrough: inbox triage at 7am

A concrete example. The agent's goal is "clear my inbox before 9am, replying to anything that needs a reply, archiving newsletters, flagging anything that mentions Q2." The agent is configured to run every weekday at 7am.

Loop one. The agent perceives by listing unread emails. It reasons: there are forty-three unread emails; the plan is to triage them in batches. It acts by reading the first batch of ten. It observes the content. Loop two: the agent reasons about each email in the batch. Some are newsletters, some need replies, one mentions Q2 budgets. It acts by archiving the newsletters, drafting replies for the ones that need them, and flagging the Q2 mention for review. It observes the results, updates its progress count, and starts the next batch.

Loop continues until the inbox is at the target state, the budget is hit, or the agent encounters something it cannot handle (a sender it does not recognise asking a sensitive question, for example). The non-developer never sees the loop. The non-developer sees a clean inbox at 9am with three flagged items and a one-line summary of what was done. That is the user model for an agent.

Where agents fail

Agents can fail at any of the four loop steps. Perception failures: the agent does not see the right input, or it misreads it. Reasoning failures: the model picks the wrong plan, or it hallucinates a step that does not exist. Action failures: the tool call breaks, returns unexpected data, hits a rate limit. Observation failures: the agent does not realise the action did not work and proceeds as if it did.

The 80-test methodology in how we test AI agents covers eight specific failure categories that map onto these loop-step failures: input variation, tool failure, partial results, hostile input, rate limits, schema drift, refusal correctness, idempotency. Reliability for an agent is the systematic coverage of those categories. NIST's AI Risk Management Framework and the OWASP LLM Top 10 cover the security-and-safety dimension of the same problem.

Supervision is the human-side answer to agent failure. Run logs, escalation queues, budget caps, and health metrics. Buyers should ask vendors what their supervision surface looks like before they buy. The future hub at what is an autonomous AI agent walks through the supervision pattern in more depth.

Gravity is the implementation of this picture. Outcome description in, agent loop running, supervision surface for the user. The economics post at economics of bootstrapped AI agents covers per-task costs.

Frequently asked questions

How does an AI agent actually work?

An AI agent runs a loop: perceive the situation, reason about what to do next, take an action, and observe the result. Repeat until the goal is met or escalation is required. The loop is the core; the language model is the brain inside the loop. Without the loop, you have a chatbot. Without the model, you have a script.

What is the difference between an AI agent and a language model?

A language model is a component; an AI agent is a system. The model takes text in and produces text out. The agent wraps the model in a loop with memory, tools, and goal-tracking, and uses the model to make the next-step decision. Most agents in 2026 are GPT-style or Claude-style models inside an orchestration layer that handles everything the model itself does not do.

Why do agents fail?

Agents fail at the perception step (missed or misread input), the reasoning step (wrong plan), the action step (tool call breaks or returns unexpected data), or the loop control step (no stopping rule, infinite cost). The 80-test methodology covers eight specific failure categories that agents face. Reliability comes from systematic testing of those categories.

Do AI agents need internet access?

Most production agents do, because most useful tools live behind APIs that require network calls. An agent without tools is essentially a chatbot in a costume. Agents with tools need network access, authentication credentials, and rate-limit awareness. Self-hosted local-only agents exist for sensitive workloads but trade capability breadth for security posture.

How do I supervise an AI agent that runs without me?

Supervision is a separate product layer. Good agent platforms expose a run log, an escalation queue, a budget cap, and a live health metric. The user reviews escalations and audits the log on a cadence. The mistake non-developer buyers make is assuming the agent will just work; the audit cadence is part of the deployment, not an afterthought.

Three takeaways before you close this tab

Sources