Agentic AI Architecture: Layers, Loops & Topologies

Agentic AI architecture explained: 6 layers, 5 loops and 5 production topologies, with real token costs and exit conditions. Read the COMPLETE guide.

Quick Answer: Agentic AI architecture is the system you build around a language model so it can pursue a goal without a human driving each step. It has six layers (model, context and memory, tools, environment, control, governance), five loops running at different speeds (tool, context, check, human, trigger), and one of five production topologies that decide how agents are wired together.


The model is the smallest part of an agentic system. Agentic AI architecture is everything else: the memory that carries context between steps, the tools and protocols that let it act, the machine where those actions land, the loop that decides when to stop, and the rules that decide what it may touch. Get those right and a mid-range model ships real work. Get them wrong and the best model in the world burns tokens in a circle.

That gap is where agentic projects die. Gartner predicts that over 40% of agentic AI projects will be canceled by the end of 2027, citing escalating costs, unclear business value and inadequate risk controls. Cost and risk are architecture problems first.

This guide maps the layers, the loops and the topologies, with the measured costs and the exit conditions most diagrams leave out. It's also how cowork.ink is built: AI coworkers that each get their own computer, so the environment layer is solved before the first task.

The short version

Start with one agent, good tools and its own environment. Write an exit condition for every loop before you write the prompt. Add agents only when you can name the failure they fix.

What is agentic AI architecture?

Agentic AI architecture is the design of a system in which a language model directs its own steps toward a goal, plus the infrastructure that keeps those steps bounded, observable and recoverable. The model chooses what to do next; the architecture decides what it can see, what it can touch, how long it can run and who checks the result.

Anthropic's widely cited definition draws the line clearly. In Building Effective Agents, it separates two kinds of agentic systems:

  • Workflows are "systems where LLMs and tools are orchestrated through predefined code paths."
  • Agents are "systems where LLMs dynamically direct their own processes and tool usage."

The same post says agents "are typically just LLMs using tools based on environmental feedback in a loop." That sentence contains the whole architecture. There is a model, there are tools, there is an environment that pushes back, and there is a loop. Everything in this guide is about making those four things work in production.

Agentic architecture vs. AI agent architecture

AI agent architecture describes one agent; agentic architecture describes the system that agent lives in. The first is anatomy: perception, reasoning, memory, tools and orchestration, which we cover in our guide to AI agent architecture components. The second is city planning: how many agents, how they're triggered, where they run, how they hand off and who signs off.

AI agent architectureAgentic AI architecture
Unit of designOne agentThe whole system of agents, tools, triggers and people
Main questionHow does this agent think and act?How does work flow, stop and get checked?
Typical diagramModel + memory + tools in a boxLayers, loops and a topology between boxes
Where it failsBad reasoning, bad tool choiceRunaway loops, cost, conflicting agents, missing approvals

You need both views. Most search results only give you the first.


The six layers of agentic AI architecture

A production agentic system has six layers, and each one fails in its own way. Vendors and analysts split the stack differently (three layers, seven, eight), but the same responsibilities show up every time. Here is the version that maps cleanly to real code.

┌──────────────────────────────────────────────────────────────┐
│ 6. GOVERNANCE & OBSERVABILITY  identity · permissions ·      │
│                                approvals · traces · evals    │
├──────────────────────────────────────────────────────────────┤
│ 5. CONTROL      run loop · exit conditions · triggers ·      │
│                 retries · durable state                      │
├──────────────────────────────────────────────────────────────┤
│ 4. ENVIRONMENT  browser · file system · shell · inbox · VM   │
├──────────────────────────────────────────────────────────────┤
│ 3. TOOLS & PROTOCOLS   function calls · MCP · A2A            │
├──────────────────────────────────────────────────────────────┤
│ 2. CONTEXT & MEMORY    instructions · working context ·      │
│                        compaction · long-term memory         │
├──────────────────────────────────────────────────────────────┤
│ 1. MODEL        reasoning engine · routing between models    │
└──────────────────────────────────────────────────────────────┘
LayerIts jobTypical building blocksWhat breaks without it
1. ModelDecide the next stepFrontier and small models, a routerWrong tool choices, wasted spend on easy steps
2. Context & memoryGive the model the right facts at each stepSystem instructions, compaction, memory files, retrievalContext rot, forgotten corrections
3. Tools & protocolsTurn decisions into actionsFunction calling, MCP servers, A2AAn agent that can only talk
4. EnvironmentWhere actions actually happenBrowser, files, shell, inbox, a VM per agentInstructions instead of finished work; shared blast radius
5. ControlRun, stop, retry and resumeRun loop, exit conditions, scheduler, state storeInfinite loops, duplicate runs, lost progress
6. Governance & observabilityDecide what's allowed and prove what happenedAgent identity, scoped permissions, approval gates, traces, evalsUnauditable actions, credential sprawl

Layer 1: the model layer

The model is the reasoning engine, and in a good architecture it is swappable. Treat it as a component you route to, not a foundation you pour concrete on. Planning steps, tool calls and summaries have different needs, and a cheaper model often handles the routine ones; our guide to model routing for AI agents shows how to split them.

What matters for agentic work is less the benchmark score and more three practical traits: how reliably the model calls tools with valid arguments, how well it holds instructions across a long context, and how much each step costs. Reliability compounds: a model that fumbles one tool call in twenty has only about a 13% chance of getting through a 40-step run without a single bad call.

Layer 2: the context and memory layer

This layer decides what the model sees on every turn. It includes the system instructions, the working context of the current run, the compacted summary of earlier turns, and long-term memory that survives between runs.

Most agent failures that look like "the model got dumb" are context failures. The window fills with tool output, the original instruction drifts out of focus, and the agent starts solving a different problem. Two design rules help:

  • Compact before you overflow. Summarize older turns when the context crosses a threshold, not when the API returns an error.
  • Write corrections to durable memory. A preference the user states once should be on file for the next run, not re-learned every session.

For the details, see our guides to context engineering and AI agent memory.

Layer 3: the tool and protocol layer

Tools are how an agent's decisions become actions, and protocols are how those tools get plugged in without custom glue. The baseline is function calling: the model emits a structured call, your code runs it, the result goes back into context.

Two open protocols now standardize the plumbing:

  • Model Context Protocol (MCP) connects agents to tools and data. Anthropic donated it to the Agentic AI Foundation, a directed fund under the Linux Foundation, on December 9, 2025, reporting over 10,000 active public MCP servers at the time. Start with our Model Context Protocol guide.
  • Agent2Agent (A2A) connects agents to other agents across frameworks. Google donated it to the Linux Foundation in June 2025. MCP is how an agent reaches a tool; A2A is how it reaches another agent.

The design decision here is tool count and overlap. OpenAI's practical guide to building agents notes that some implementations "successfully manage more than 15 well-defined, distinct tools while others struggle with fewer than 10 overlapping tools." Clear names and non-overlapping tools beat a bigger toolbox.

Layer 4: the environment layer

The environment is where the agent's actions land: a browser, a file system, a shell, an inbox, a machine. It is the layer most architecture diagrams leave out, and it is the one that decides whether an agent hands you finished work or a list of instructions.

An agent without an environment can tell you how to download the CSV. An agent with one opens the tab, downloads the file, runs the numbers and attaches the PDF. That's why the 2025–2026 generation of agents made the machine part of the product:

  • Cursor says "each Cloud Agent runs on its own dedicated virtual machine" and opens a pull request when it finishes (Cursor).
  • Microsoft introduced Copilot Autopilot on September 25, 2026 as an agent that "lives in your tenant with its own identity, memory, computer and workspace" (Microsoft).

Three decisions define this layer:

  1. Shared or dedicated? One machine per agent keeps files, sessions and mistakes from leaking between jobs.
  2. Ephemeral or persistent? A fresh container per run is clean but forgets its logins and files; a persistent machine remembers both. Our comparison of persistent vs. ephemeral AI agents walks through the trade.
  3. What's the blast radius? Whatever the agent can reach from its environment is what a bad step can damage. Size it like you'd size a new hire's access.

Layer 5: the control layer

The control layer runs the loop, stops it, retries it and resumes it. It owns exit conditions, timeouts, triggers (schedules and events), concurrency and the state that lets a run survive a crash.

This is where long-running agents differ most from chatbots. Anthropic's write-up of its multi-agent research system puts it bluntly: "Agents are stateful and errors compound." Instead of restarting failed runs from scratch, the team built systems that "can resume from where the agent was when the errors occurred."

In practice the control layer answers five questions for every agent: what starts a run, what ends it, what happens on failure, what happens if a second run starts while the first is still going, and where progress is saved. The next section turns those answers into loops.

Layer 6: the governance and observability layer

Governance decides what an agent may do; observability proves what it did. The building blocks are an identity per agent, scoped permissions, approval gates for risky actions, a trace of every model and tool call, and evaluations that score outcomes over time.

OpenAI's guide frames guardrails as "a layered defense mechanism": no single check is enough, but several specialized ones together make agents resilient. The same thinking applies to the whole layer. Give each agent its own identity rather than a shared key (AI agent identity), put a human gate in front of anything irreversible (human-in-the-loop design), and keep traces you can actually read (AI agent observability).

Governance added after the pilot is governance that stalls the pilot

Identity, permissions and approval gates are cheap to design in and expensive to retrofit. "Inadequate risk controls" is one of the three reasons Gartner gives for canceled agentic projects.


How do agentic loops work?

An agentic system is loops nested inside loops, each running at a different speed and each needing its own exit condition. The tool loop turns in seconds. The trigger loop turns in hours or days. When a system misbehaves, the first diagnostic question is which loop has no guard.

LoopTimescaleCloses whenGuard you needFailure without it
1. Tool loopSecondsFinal answer, no more tool calls, error, or turn limitExit conditions, repeat detectionRunaway spend, circular tool calls
2. Context loopEvery turnContext fits the budget againCompaction thresholdContext rot, overflow errors
3. Check loopPer outputOutput passes a test, rubric or reviewerMax revision countShipping unchecked work, or endless polishing
4. Human loopPer risky action or per runA person approves, edits or rejectsClear gate rulesIrreversible mistakes, or approval fatigue
5. Trigger loopHours to daysThe next schedule or event firesOverlap lock, timeout, backoffDuplicate runs, retry storms

Loop 1: the tool loop

The tool loop is the core agent cycle: the model reasons, calls a tool, reads the result and decides again. It's the ReAct pattern, covered step by step in our guide to the ReAct pattern for AI agents.

The architecture question is how it ends. OpenAI's guide describes every run as "a loop that lets agents operate until an exit condition is reached," and lists the common ones: "tool calls, a certain structured output, errors, or reaching a maximum number of turns." Anthropic adds that it's "common to include stopping conditions (such as a maximum number of iterations) to maintain control." Write these down before you write the prompt.

Loop 2: the context loop

The context loop keeps the working set inside the model's window. After each turn, the system checks how much context is in use; above a threshold, it summarizes older turns and continues with the summary. The same loop can write durable facts to long-term memory so the next run starts informed.

Loop 3: the check loop

The check loop verifies output before it leaves the agent. Anthropic calls the LLM version "evaluator-optimizer": one call produces, another critiques, and the first revises. The cheapest checks are deterministic, though. A test suite, a schema validator or a totals-must-match rule catches more than a second opinion from the same model, and costs nothing per run. Cap revisions, or the agent will polish forever.

Loop 4: the human loop

The human loop puts a person at the points where a wrong action is expensive. Good gates are specific: spending money, contacting a customer, deleting data or anything irreversible waits for approval; everything else runs. The second half of this loop is corrections. When a reviewer fixes something, that fix should flow back into memory (loop 2) so it doesn't need fixing again.

Loop 5: the trigger loop

The trigger loop is what makes an agent work without being asked: a schedule or an event starts a new run. It's the defining loop of background agents, the ones that keep working after you close the tab. It needs guards that a chat never does: what if the previous run is still going, what if the last three runs failed, and how long is a run allowed to take?

What loop guards look like in real code

Here are the actual guards in GoGogot, the open-source (MIT) Go engine underneath cowork.ink. We checked each one against the source:

  • Tool loop: the agent stops iterating when the model returns a response with no tool calls. A repeat detector flags the same tool called 3 times in a row with identical arguments and tells the model to "Stop repeating and explain the situation to the user." A user's /stop cancels the run.
  • Context loop: a compaction hook rewrites the working set when the estimated context passes 80% of the model's window.
  • Trigger loop: the scheduler (built on robfig/cron) skips a task that is already running, gives each scheduled run a 5-minute timeout by default, runs at most 2 tasks at once by default, and after consecutive failures backs off 30s → 1m → 5m → 15m → 60m before trying again.
Different loops, different guards

Notice the chat loop has no fixed turn cap; it relies on repeat detection and a human who can type /stop. The unattended loop gets a hard deadline instead, because nobody is watching it. Guard each loop for who is (or isn't) present.


Production topologies: how agentic systems are wired

Five topologies cover nearly every agentic system in production, and most real systems combine two of them. The topology decides how many agents run, who coordinates them and how context moves between them. It's also the biggest driver of cost.

Topology 1: single agent with tools

One agent, one loop, a well-chosen set of tools. This is the default, and it should be. OpenAI's guide recommends you "maximize a single agent's capabilities first," because more agents "can introduce additional complexity and overhead, so often a single agent with tools is sufficient." It's the easiest to debug, since there's one trace to read.

Topology 2: workflow (fixed pipeline)

Code decides the order of steps; the model fills in each step. Anthropic's workflow patterns live here: prompt chaining, routing, parallelization, orchestrator-workers and evaluator-optimizer. Choose a workflow when you can draw the process on a whiteboard and it doesn't change. It's the cheapest and most predictable topology, and our guide to agentic workflows covers each pattern.

Topology 3: orchestrator–workers

A lead agent plans the job, spawns worker agents for parts of it, and merges their results. OpenAI calls this the "manager" pattern, where specialists are exposed to the lead as tools. Anthropic's research system uses it, and the numbers show both sides of the trade:

  • The multi-agent setup (Claude Opus 4 leading Claude Sonnet 4 subagents) outperformed a single Claude Opus 4 agent by 90.2% on Anthropic's internal research eval.
  • Agents used about 4× the tokens of a chat; the multi-agent system used about 15×.
  • Token usage alone explained 80% of the performance variance on the BrowseComp benchmark.

In other words, much of the gain is paid for in tokens. Anthropic also notes that domains "that require all agents to share the same context" are a poor fit, and that coding has "fewer truly parallelizable tasks than research." For the trade-off in detail, see hierarchical vs. peer-to-peer agents.

Topology 4: handoff network

Peer agents pass control to each other based on specialization, with no central manager. OpenAI calls this the decentralized pattern: "multiple agents operate as peers, handing off tasks to one another." A triage agent that hands a billing question to a billing agent is the classic case. Only one agent is active at a time, so cost stays close to a single agent, but the handoff has to carry enough context for the receiver to continue.

Topology 5: a fleet of persistent agents, one machine each

Several long-lived agents, each with its own role, environment, identity and schedule, coordinated through the same channels people use. This is the coworker topology. Instead of a lead agent spawning short-lived workers inside one run, each agent owns a lane: one pulls the Monday report, another triages the inbox, another watches competitor prices. Each runs its own trigger loop on its own machine and reports where the team already works.

It's the shape agent products have been converging on: Cursor's per-VM Cloud Agents in coding, then Microsoft's Autopilot for office work in September 2026. Its strength is isolation: one agent's bad run can't corrupt another's files or session. Its cost is coordination, since agents share context through artifacts and messages rather than a common window.

Comparing the five topologies

TopologyWho decides the next stepRelative token costBest forMain failure mode
Single agent + toolsThe agent~4× a chat (Anthropic)Most tasks; the defaultTool overload, context rot on long runs
WorkflowYour codeLowest; fixed number of callsStable, well-understood processesBreaks on inputs the pipeline didn't expect
Orchestrator–workersA lead agent~15× a chat (Anthropic)Broad, parallel research and analysisWorkers making conflicting assumptions
Handoff networkWhichever agent holds controlClose to a single agentTriage and routing to specialistsContext lost at the handoff
Persistent fleetEach agent, in its own lanePer agent, per runRecurring operational work across rolesDuplicated or overlapping responsibilities
The case against multi-agent

Cognition, the team behind Devin, argues in Don't Build Multi-Agents that parallel subagents are "very fragile" because each makes its own unstated assumptions. Its two principles: "Share context, and share full agent traces, not just individual messages," and "Actions carry implicit decisions, and conflicting decisions carry bad results." If your subtasks depend on each other, keep them in one agent.


How to choose an agentic AI architecture

Choose the simplest architecture that does the job, then add layers and agents only when you can name the failure they fix. Anthropic's advice is to find "the simplest solution possible, and only increasing complexity when needed." In practice that becomes seven steps:

  1. Check whether you need an agent at all. Google Cloud's guide to agentic AI architecture components points out that tasks like summarization, translation and feedback classification don't need an agentic workflow. A single model call or a fixed pipeline is cheaper and more predictable.
  2. Start with one agent and good tools. Make tool names distinct and descriptions precise before you consider splitting.
  3. Pick the environment before the framework. Decide where actions land (a browser, files, a dedicated machine) and how much the agent can reach from there. Frameworks are easy to swap; blast radius isn't.
  4. Write an exit condition for every loop. Turn limit or repeat detection for the tool loop, a compaction threshold for context, a revision cap for checks, a timeout and overlap lock for triggers.
  5. Design identity and approval gates before go-live. One identity per agent, the minimum permissions for the role, and a human gate in front of money, customers and anything irreversible.
  6. Instrument every model and tool call. If you can't replay a run step by step, you can't fix it.
  7. Split into more agents only on evidence. OpenAI's guide gives two triggers: prompts with many conditional branches that are hard to maintain, and tool overload that better descriptions don't fix.

How do the three reasons projects fail map to layers?

Each of Gartner's three cancellation reasons traces back to a specific part of the architecture.

Gartner's reasonWhere it usually startsArchitectural fix
Escalating costsUnbounded tool loops; multi-agent topology chosen by defaultExit conditions, model routing, single agent first
Unclear business valueAgents that produce advice, not artifactsAn environment layer that delivers finished files and actions
Inadequate risk controlsShared credentials, no gates, no tracesPer-agent identity, approval gates, readable transcripts

What breaks in production?

Most production failures are a missing guard on one specific loop or layer. When an agentic system misbehaves, find the row before you change the prompt.

SymptomLoop or layerFix
Same tool called again and againTool loopRepeat detector, turn limit
Agent forgets the original goal mid-runContext loopCompaction threshold; pin the goal in instructions
Two copies of the same reportTrigger loopSkip-if-running lock
A failing job hammers an API all nightTrigger loopExponential backoff after consecutive errors
Run dies at step 30 and starts overControl layerDurable state; resume from the last step
Subagents produce work that doesn't fit togetherTopologyShare full traces, or merge into one agent
Nobody can say which agent changed a recordGovernance layerOne identity per agent; a trace of every tool call
Costs triple after adding "just one more agent"TopologyMeasure tokens per run; justify every agent

Skip Building the Environment Layer

The hardest layer to build yourself is usually the environment: a machine per agent, with a real browser, files and logins that persist, wired to a scheduler and a transcript. cowork.ink gives you that as a product. You set up as many AI coworkers as you need, in whatever roles you need, and each one has its own cloud computer with a browser, a file system, an inbox and a code runtime. It signs into your tools through its browser, works on the schedule you set, and posts the finished work in Slack or Telegram. Every run leaves a transcript you can read and correct.

Setup takes about three minutes: create a coworker, tell it what it's for, hand it the docs a new hire would get, connect Slack or Telegram and give it the first task in plain language. $25/month billed yearly, or $29 monthly, covers every coworker, their machines and the models they use, with a 15-day money-back guarantee.

Prefer to read the loop before you trust it? The engine underneath is GoGogot, open-source under MIT. The loop guards listed in this guide are in its source, and you can run it on your own server.

Frequently Asked Questions

What is agentic AI architecture?
Agentic AI architecture is the design of the system around a language model that lets it pursue a goal on its own: the model, its context and memory, its tools, the environment where its actions land, the control loop that decides when to stop, and the governance layer that decides what it may do. The model reasons; the architecture makes that reasoning safe, affordable and repeatable.
What are the layers of agentic AI architecture?
Most production systems have six layers: a model layer (the reasoning engine), a context and memory layer, a tool and protocol layer (function calling, MCP, A2A), an environment layer (the browser, files and machine where actions happen), a control layer (loops, triggers, retries and state), and a governance and observability layer (identity, permissions, approvals, traces and evals).
What is the difference between agentic architecture and AI agent architecture?
AI agent architecture usually describes the anatomy of a single agent: perception, reasoning, memory, tools and orchestration. Agentic architecture describes the whole system: how many agents there are, how they are triggered, where they run, how they hand off work and who approves what. Our guide to [AI agent architecture components](/blog/ai-agent-architecture/) covers the single-agent view.
How do you stop an AI agent from looping forever?
Give every loop an explicit exit condition and a guard. Typical exits are a final-output tool call, a response with no tool calls, an error, or a maximum number of turns. Typical guards are a repeat detector for identical tool calls, a hard timeout on unattended runs, and a backoff after consecutive failures.
When should you use a multi-agent architecture?
Only after a single agent with good tools has clearly hit its ceiling. Multi-agent topologies pay off on broad, parallelizable work such as research, but Anthropic measured roughly 15 times the tokens of a chat for its multi-agent system. Tasks where every step depends on shared context, such as most coding, usually do better with one agent. See our guide to [AI agent orchestration](/blog/ai-agent-orchestration/).
Home Blog Company