Your team is debating which model to pick. The numbers say that is the wrong argument. McKinsey's 2026 state of AI survey puts enterprise-wide AI scaling at 44 percent of organizations, and eight in ten respondents say it has made them more productive. Yet the share reporting any EBIT contribution is stuck at 37 percent. Large firms are scaling agents fastest, at 40 percent, and roughly a fifth of adopters already find running costs a constraint. Most still plan to spend more. The few who see returns rebuild workflows around AI instead of inserting it into old ones. That rebuilding is engineering, and it happens in seven layers around the model. Here is each one.
Agent projects often stall on language before they stall on technology, because teams use one word to mean three things. So before the layers, a quick sort of the vocabulary.
The vocabulary, sorted
Most confusion about agents is vocabulary. These terms fall into four groups, and each group maps to layers below.
1. Control patterns: how the agent decides what to do next
- Agentic loop: call, act, observe, repeat
- ReAct: reason before each action
- Reflection: critique its own output and retry
- Plan-and-execute: draft the full plan, then run the steps
- Multi-agent
- Router: classify the request, dispatch to a specialist
- Orchestrator-workers: a lead agent delegates subtasks
- Workflow: fixed code path, with the model filling steps
- Related: tree of thoughts (explore several reasoning branches), handoffs (one agent passes control to another)
In code:
- Open source, LangGraph:
StateGraph, nodes, edges andadd_conditional_edges;Commandto update state and route in one step;Sendfor fan-out to parallel workers;create_agentfor a prebuilt loop - AWS, Strands Agents:
Agent;GraphBuilderfor deterministic graphs;Swarmfor autonomous handoffs
2. Plumbing: what the agent can touch
- Harness: the code around the model that runs the loop and permissions
- Tool: one function the model can call
- MCP: the protocol that exposes tools, not a tool itself
- Related: function-calling schema (the typed description of a tool's inputs), A2A (a protocol for agents calling other agents)
In code:
- Open source, LangGraph:
ToolNode;MultiServerMCPClientfrom langchain-mcp-adapters, which turns MCP tools intoBaseToolobjects - AWS, Strands Agents:
@tool,MCPClient,ToolRegistry - AWS, AgentCore Gateway: a gateway plus targets (Lambda functions, OpenAPI schemas, Smithy models, MCP servers, API Gateway)
3. Information: what the agent knows
- Context: what the model sees this turn
- Memory: what persists beyond the turn
- Short-term: checkpoints within a run
- Long-term: facts stored across sessions
- Related: RAG (retrieve documents into context on demand), compaction (summarise old context to free space)
In code:
- Open source, LangGraph: checkpointers such as
PostgresSaverfor one thread's state, keyed bythread_id; stores such asInMemoryStorefor memory across threads - AWS, Strands Agents:
SessionManager,AgentState,Snapshot - AWS, AgentCore Memory:
CreateEventwith asessionIdandactorIdfor short-term memory; memory strategies such asSemanticMemoryStrategy, organised by namespace, for long-term memory
4. Limits: when the agent branches or stops
- Conditional boundaries: rules for when to branch, stop or escalate
- Human-in-the-loop: pause for approval before risky actions
- Related: guardrails (filters on inputs and outputs), iteration and budget caps (hard stops on steps or spend)
In code:
- Open source, LangGraph: conditional edges for branching;
interrupt()to pause for a human, withCommandto resume;RetryPolicy - AWS, Strands Agents:
HookRegistry, with interrupts raised inside hooks - AWS, AgentCore: Cedar policies evaluated at the Gateway; Bedrock Guardrails in policy for prompt injection and sensitive data
With the terms sorted, the layers are easier to place. Control patterns live in orchestration, plumbing in tools and the control plane, information in trusted context, and limits in evaluation.
The seven layers
A working agentic system has seven layers, and the model is not one of them. Most companies spend their time debating which model to pick. The model sits inside a larger operating system, and almost every production failure happens in the layers wrapped around it.
Each layer below names the job, an everyday comparison, the frameworks and cloud services that do it, and the traps.
The layers at a glance
Each of the seven layers breaks into five components. Switch between the grid, tree and pill views to see how they nest.
Start where the work starts. Before an agent can do anything useful, something has to tell it there is work to do.
Layer one: experience and trigger
Real business agents fire on an event, not a chat box: a file arrival, an invoice, a ticket status change, a schedule. When the agent needs a human, it routes to an exception queue.
- Think of it like: phone notifications. You don't open every app to check; the app pings you when it needs you.
- Frameworks: event-driven architecture, human-in-the-loop exception queues
- AWS / Azure: Amazon EventBridge · Azure Event Grid with Logic Apps
- What to avoid
- Defaulting to a chat interface for back-office work.
- How it goes wrong
- Escalations land in raw transcripts nobody in operations reads, so exceptions quietly age.
A trigger starts a run. What happens when that run is interrupted halfway is the next layer's job.
Layer two: orchestration and state
An agent definition is a code artifact: versioned, bounded, governed, with rollback. Execution history and checkpoints live in a database such as Postgres, so an interrupted run resumes instead of restarting.
- Think of it like: a video game save point. Crash at the boss and you restart from the save, not level one.
- Frameworks: LangGraph checkpointers and durable execution
- AWS / Azure: Lambda durable functions or Step Functions · Durable Extension for Microsoft Agent Framework
- What to avoid
- Agents run as scripts on someone's laptop, with state held in memory.
- How it goes wrong
- A retry after a crash repeats a side effect, such as paying the same invoice twice.
Saved state keeps a run alive, but it says nothing about whether each step is correct. That depends on what the agent is allowed to call.
Layer three: tools and deterministic logic
The guarantees live in plain, unit-tested code, not in the prompt. Wrap business logic and system-of-record APIs behind one connector service as named tools with stable interfaces. Call the model only where judgment is required.
- Think of it like: splitting a restaurant bill. You decide who owes what; the calculator does the maths.
- Frameworks: Model Context Protocol (MCP), tool calling
- AWS / Azure: Bedrock AgentCore Gateway turns APIs and Lambda functions into MCP tools · Azure API Management exposes a REST API as an MCP server
- What to avoid
- Asking the prompt to do arithmetic, validation or policy rules.
- How it goes wrong
- Each team wires its own connectors; one interface changes and agents break silently.
Tools let the agent act. To act well it also needs facts, and those have to come from a source it can trust.
Layer four: trusted context
Do not dump the whole wiki or repo into a giant prompt. Give each domain a scoped knowledge graph or data catalog that the agent queries mid-run as a tool.
- Think of it like: an open-book exam. You want the right textbook and the chapters you're allowed, not the whole library photocopied.
- Frameworks: GraphRAG, agentic retrieval, data catalogs
- AWS / Azure: Bedrock Knowledge Bases GraphRAG on Neptune Analytics · Foundry IQ on Azure AI Search
- What to avoid
- Treating a longer prompt as the fix for stale documentation.
- How it goes wrong
- Documentation drifts from reality and the agent answers confidently from it.
- Retrieval ignores permissions and shows a user content they should not see.
Good tools and good context still produce wrong answers some of the time, so quality has to be measured before anything reaches a customer.
Layer five: evaluation and human control
Before an agent touches a customer or moves money, build a golden set of real past cases your domain experts agree are right. Run deterministic checks and LLM-as-a-judge evaluations on every change, and keep a human approval gate on any irreversible action.
- Think of it like: a driving test before the licence, plus a bank that still texts you to confirm a large transfer.
- Frameworks: golden datasets, LLM-as-a-judge, NIST AI Risk Management Framework
- AWS / Azure: Amazon Bedrock Evaluations · Microsoft Foundry evaluations
- What to avoid
- Shipping because the demo looked good.
- How it goes wrong
- The judge model is never calibrated against your experts, so its scores mean little.
- The approval gate fires on everything and reviewers start rubber-stamping.
Evaluation tells you whether a change is safe to ship. The next layer governs cost and access once it is running at scale.
Layer six: runtime and control plane
Every model call goes through one LLM gateway inside your own cloud perimeter. Enforce virtual keys per tenant and service, hard spend caps, prompt-injection guardrails, and internal model aliases so swapping providers is a configuration change.
- Think of it like: a company card with a spending limit, instead of everyone borrowing the founder's personal card.
- Frameworks: LiteLLM for virtual keys and budgets
- AWS / Azure: AgentCore Gateway with Bedrock Guardrails · Azure API Management AI gateway with model aliases
- What to avoid
- Direct calls to a vendor API. Treat them as a production defect.
- How it goes wrong
- A looping agent burns the monthly budget overnight.
- A shared key leaks and nobody can trace which team used it.
The control plane limits and routes each model call. Seeing how those calls add up to a finished run takes one more layer.
Layer seven: observability engine
The gateway sees model calls; observability shows the whole run. One trace per run links the trigger, each step, tool call, retrieval, evaluation score and cost, so "why did it do that?" takes minutes to answer.
- Think of it like: parcel tracking. You see every stop the package made, not just "delivered" or "lost".
- Frameworks: OpenTelemetry GenAI conventions, Langfuse
- AWS / Azure: CloudWatch generative AI observability · Foundry tracing into Azure Monitor
- What to avoid
- Logging only final answers, or locking traces into one vendor's format.
- How it goes wrong
- Customers find failures before you do.
- Traces store sensitive prompts unredacted.
- Production failures never make it back into the golden set.
Worked example: where an agent belongs in invoice processing
Not every step needs an agent. Take accounts payable: a mid-size company receives 4,000 supplier invoices a month in mixed formats, clerks key them in and chase exceptions, and cycle time runs to nine days (illustrative figures). Each step in invoice processing takes the first branch that fits.
- Fixed rule, structured input: plain automation. Three-way matching, tax and payment scheduling stay as tested code, and most steps exit here.
- Path known in advance: one scoped model step for the part that needs interpretation, such as reading a scanned invoice or classifying a dispute email.
- Path unknown: an agentic loop. Tracing a mismatch across systems is the only case that justifies its cost.
- Every branch: a human approves irreversible actions, such as releasing payment, whether code or a model proposed them.
Taken together, the layers form a loop: production traces feed the golden set, and the golden set gates the next release.
What lasts
Models and frameworks will keep changing. The durable assets are your workflow rules, evaluation sets, context boundaries, traces and operational ownership. Pick one workflow, name an owner for each layer, and ship that before debating the next model.