21 min
The complete guide to LLM agents architecture, tools, and infrastructure
Learn how LLM agents plan, remember, and use tools, plus the isolation, state, and startup infrastructure production agents need.

LLM agents still have no widely accepted definition. NVIDIA's working version is a system that uses an LLM to reason, plan, and execute with tools. Anthropic defines agents as "LLMs autonomously using tools in a loop." The model plans an action, calls a tool, reads the result, and decides what to do next.
Feedback on that loop measurably improves results. For instance, agents built with Reflexion reached 91% pass@1 on the HumanEval coding benchmark, compared with 80% for GPT-4. The gain comes from feedback, much of which comes from running code the agent just wrote.
For engineering teams, the model is only one layer of a working agent. Production agents also need an isolated place to execute untrusted code and a way to keep state between runs. This guide walks through the architecture behind LLM agents and the infrastructure that keeps them running in production.
Key takeaways
- An LLM agent uses a model to plan, call tools, and act in a loop until it reaches a goal.
- A prompt injection hidden in a README or API response can steer an agent into writing malicious code.
- Agents still fail roughly one in three attempts on structured benchmarks, so production flows need guardrails.
- Baseten Sandboxes run each sandbox in its own Firecracker microVM and resume it from standby in under 25ms.
What are LLM agents?
An LLM agent is a language model that chooses its own next step toward a goal. The labels "AI agent" and "LLM agent" overlap too. AI agents "are often referred to as LLM agents" because an LLM powers them, per IBM.
Standalone models have limits that the surrounding agent architecture addresses:
- No built-in long-term memory: External storage retains information between sessions.
- No autonomous interaction with external tools: Application code exposes and executes tool calls.
- Weak goal pursuit in changing environments: A planning and observation loop lets the system update its next action.
Standard LLM applications follow a predictable, stateless pattern. A user sends a prompt, the model responds, and the interaction ends.
Agents break that pattern:
- Persistent state: Agents keep context across multiple interactions and sessions.
- Autonomous tool use: Agents select and invoke external tools and APIs on their own.
- Runtime code execution: Many agents write and run code based on task requirements. Nobody can fully audit those execution paths before deployment.
Agents are easy to confuse with chatbots and workflow automation:
| Chatbot | Workflow automation | LLM agent | |
|---|---|---|---|
| Who decides the next step | The user, prompt by prompt | An engineer, in code | The model, at runtime |
| State | Usually stateless between sessions | Defined by the workflow | Typically persists across turns and sessions |
| Tool use | None or fixed | Fixed calls at fixed steps | Model selects tools per step |
| Code execution | None | Predefined scripts | Can generate and run new code |
| Pre-run auditability | Full | Full | Partial, since paths change at runtime |
| Infrastructure need | Model API | Orchestrator and APIs | Model API, isolated execution, persistent state |
Per IBM Research, an LLM becomes an agent when the system gives it freedom to choose which tool to apply. Workflows still win for some tasks. Workflows "offer predictability and consistency for well-defined tasks," according to Anthropic's guide to building agents. Agents fit better when tasks require model-driven decisions.
Consider a code generation agent asked to fix a bug in a repository. It retrieves relevant files and reasons about the root cause. Then it generates a fix, runs tests in an isolated environment, and reads the results. It iterates until tests pass, tracking its progress and adapting to feedback. A standard chatbot can't do any of this.
Capabilities and use cases of LLM agents
Gartner's 2026 Hype Cycle article cites a CIO survey: only 17% of organizations have deployed agents. More than 60% expect to deploy them within two years. For your team, that means most peers are still early, and production patterns are forming.
Autonomous coding agents
Code generation agents write and iterate on code without step-by-step human input. They run that code in sandbox environments and read the results. Each edit-and-test cycle is another run, so one session can execute code many times.
Data analysis agents
Natural language analytics agents generate and execute scripts to answer business questions. Users describe what they want in plain language. The agent writes Python or SQL, runs it against data sources, and returns formatted results.
Business users can then answer questions that once required an analyst. Because the agent runs code against your data, it needs the same isolation as a coding agent.
PR review agents
Pull requests arrive sporadically throughout the day, and each one needs review before merging. Review agents run the changed code and its test suites in sandboxes, then suggest improvements. On traditional serverless infrastructure, a request after an idle stretch waits for a fresh environment to boot.
General-purpose and enterprise agents
Coding is only one application. IBM and NVIDIA document a wider range. Their examples include web search, math problem solving, IT incident diagnosis, IT automation, and software design. Others cover code generation, conversational assistance, data curation, and e-commerce recommendations.
Each use follows a simple input-to-output pattern:
| Use case | Input | Tool call or task | Output |
|---|---|---|---|
| Web search | A question needing current information | Query an internet search API | An answer based on retrieved information |
| Math problem solving | A calculation or math question | Invoke a calculation tool or code interpreter | A calculated result |
| Software design | A software task | Decompose the task and retrieve relevant context | A proposed design |
| IT automation | An operational request | Invoke an authorized operational tool | A completed task or proposed next action |
| Code generation | A coding request and repository context | Generate code and execute tests | A tested change or feedback for revision |
| Conversational assistance | A user request and relevant history | Retrieve context and invoke suitable tools | A response or completed action |
| Data curation | Data requiring organization | Retrieve and process the data | Curated data or content |
| E-commerce recommendations | A request and relevant user context | Retrieve relevant product information | Personalized recommendations |
An SRE incident-triage agent illustrates the operational loop:
- Receive an incident alert.
- Gather relevant logs through tools.
- Diagnose the incident and propose a fix.
- Escalate for human review when the action needs approval.
This automated loop ensures rapid triage while routing high-risk actions for human review.
How LLM agents work
LLM agents have four interdependent components: the LLM as reasoning engine, planning and task decomposition, memory systems, and tool integration.
The LLM is the central controller. It decides on actions and interprets their results. In NVIDIA's model, a coordinating "agent core" manages goals, tool access, planning guidance, memory retrieval, and optional persona definitions.
Your model choice affects every one of those functions. Evaluate context window size, reasoning ability, and inference cost before committing to a model.
The component view places the core between the request and the supporting modules:
`[User request]`
`↕`
[Memory module] ↔ [Agent core / LLM] ↔ [Planning module]
↕
[Tools]
Information flows both ways. The core requests memories, plans, and tool actions, then interprets the results.
Planning and task decomposition
Planning modules break complex tasks into manageable subtasks. The ReAct pattern is a widely used starting point. It alternates between reasoning about the current state and taking actions. Each tool result informs the next step, so planning updates as the task unfolds.
Several reasoning patterns sit underneath planning. Chain-of-thought follows one reasoning path. Tree of Thoughts explores multiple paths and compares them. Multi-plan selection generates several candidate plans, scores them, and picks one before any tool runs.
Reflection adds self-correction. Reflexion converts environment feedback into a written self-critique, which the agent reads on its next attempt. With that loop, Reflexion reached 91% pass@1 on the HumanEval coding benchmark, against 80% for GPT-4. The gap matters most for coding agents, which get clear pass-or-fail signals from tests.
Feedback can come from three places: environment observations, human reviewers, or another model acting as a judge. Decide which sources your agent trusts before it ships, since each enters the loop at a different point.
For a generate-check-correct coding task, reflection makes the retry explicit:
- Generate a proposed fix and run the tests.
- Read the test failure as environment feedback.
- Write a short critique of what the attempt missed.
- Use that critique as context for a revised fix, then test again.
Iterative reflection directly bridges the gap between raw code generation and reliable execution.
Memory systems
Memory operates at two levels. Short-term working memory lives in the LLM's context window and holds the current task. Long-term memory sits in vector databases or structured systems, so agents recall information across sessions.
The MemGPT pattern treats the context window as fast, volatile memory, like RAM. Persistent storage acts as the disk. Together they form a virtual context management system.
Retrieval needs more than semantic search once history grows. NVIDIA ranks long-term memories by a composite score of "semantic similarity, importance, recency, and other application-specific metrics." Storage formats vary as well. Teams use natural language logs, embeddings, databases, and structured lists, often in combination.
Some agents also need procedural memory. Agent Workflow Memory, covered in a recent arXiv study, extracts reusable routines from past tasks to guide future ones. Procedural memory stores routines rather than facts, so it changes what your agent should persist between runs.
Tool integration
Tool integration lets agents act on external systems. Function calling is a common way LLMs interact with tools. The model receives tool metadata, including function names and parameters. It proposes which function to call and with what arguments. Your application then executes the call, and the output feeds back into the reasoning loop.
Tools fall into a few categories:
| Tool category | What it does | Example call |
|---|---|---|
| RAG pipeline | Retrieves documents from a knowledge base | Fetch the current refund policy |
| Code interpreter | Runs generated code and returns output | Execute a Python script against a CSV |
| Search API | Queries the web for current information | Look up a library's latest release notes |
| Specialized service | Calls a domain API | Open a ticket or query a CRM |
The Model Context Protocol (MCP) standardizes how agents discover and call tools. The MCP architecture docs define three primitives that servers expose: tools, resources, and prompts. Of these tool categories, code interpreters carry the highest risk because they turn model output into running processes.
How agents execute code
Code execution follows the same tool-call loop. The model writes a script and passes it as the tool's argument. Your application sends that script to a runtime, such as a sandbox. The runtime runs it and returns stdout, stderr, and an exit code.
The result enters the context, and the model picks its next step. The runtime decides isolation, state, and startup latency for each run.
Frameworks and SDKs
Most teams build on a framework rather than writing the loop from scratch.
Several have changed names or APIs recently, so older tutorials often reference retired interfaces:
- OpenAI Agents SDK: The Agents SDK replaces Swarm, per OpenAI's Swarm repository. Its sandbox agents keep the agent definition fixed while you swap the sandbox client.
- Claude Agent SDK: Anthropic renamed the Claude Code SDK. The migration guide lists the new packages as
claude-agent-sdkand@anthropic-ai/claude-agent-sdk. - LangChain and LangGraph: In LangChain v1,
create_agentreplaceslanggraph.prebuilt.create_react_agent. - Microsoft Agent Framework: Version 1.0 reached general availability on April 2, 2026. The framework merges AutoGen and Semantic Kernel, per Microsoft's Build 2026 post.
- Other options: Google ADK, CrewAI, LlamaIndex workflow agents, and Hugging Face smolagents cover similar ground with different orchestration models.
If your codebase still imports create_react_agent or ClaudeCodeOptions, plan a migration before you scale.
The agent trinity: why architectural isolation is mandatory
One useful way to frame agent architecture is the "agent trinity." It has three components:
| Component | Role |
|---|---|
| LLM brain | The reasoning layer |
| Sandbox runtime | The isolated execution environment |
| Persistent state | The store for context and memory |
Isolation is an architectural requirement for agents that run generated code.
Agents often take trusted instructions and untrusted data in one input, which lets prompt injection attacks succeed. NIST calls agent hijacking "a type of indirect prompt injection," where the attacker hides instructions in data the agent ingests.
The agent then takes "unintended, harmful actions," per NIST's hijacking evaluation post. OWASP traces the damage in its Excessive Agency entry to three root causes:
| Root cause | Exposure |
|---|---|
| Too much functionality | Tools can do more than the task requires |
| Too many permissions | Tools can access more data or operations than needed |
| Too much autonomy | Actions proceed without appropriate oversight |
Containers work well for running your own trusted software. AI-generated or untrusted code needs a stronger boundary. Containers share the host kernel so that a kernel exploit can escape to other tenants.
MicroVMs run a separate kernel per workload, which removes kernel-level attack surface between tenants. For agents running untrusted code, the safer pattern is one session per microVM, so customer requests stay separated.
Types of LLM agents
Production deployments usually combine several agent architectures, depending on the use case. Three patterns come up most often.
ReAct agents run a single reasoning-and-action loop. An agent forms a thought about the current state, picks an action, executes it, and observes the result. Coding agents are a familiar example.
Tool-augmented agents learn when and how to invoke external tools and APIs. A narrow agent with carefully chosen tools is often easier to make reliable than a generic one. A PR review agent, for example, gets code analysis tools, test runners, and documentation generators.
Multi-agent systems split complex workflows across specialized agents. A data analysis workflow can use one agent for query generation, another for code execution, and a third for interpretation.
The same arXiv study weighs these trade-offs:
- Benefits: Multi-agent systems offer better modularity and reliability, plus scalability through division of labor.
- Drawbacks: They add coordination overhead, more complex system design, and security risk in agent-to-agent interactions.
Multi-agent systems can also get stuck in endless loops when agents can't agree, IBM Research notes. Start with one agent and split only when a narrower scope measurably improves reliability.
Common production challenges for LLM agents
Moving LLM agents from prototype to production introduces significant operational hurdles. Autonomous agents raise the stakes through multi-step reasoning, external tool execution, and dynamic code generation.
Engineering teams need isolated execution environments, reliable memory management, and strict security guardrails.
Cold start latency
Agents face a dual cold start problem. Serverless initialization and model loading each add startup delay, and the two delays stack. AWS Lambda keeps an idle environment only for a period of time.
After that, the next request waits for a new environment to start. Interactive coding agents feel the delay directly. When a live preview lags behind each edit, users read the agent as broken, even when its output is correct.
State persistence
Production agents need state management that local testing rarely exercises. A long-running coding agent makes many tool calls over a long conversation, and each call can change files on disk. Losing a sandbox mid-session throws that work away. Plan where that state lives before launch.
Memory management
Without a deliberate memory architecture, agents lose goals mid-execution and behave incoherently over time. They also fail to build on earlier decisions. Adding memory has limits, since leaner contexts can improve model reliability.
Simpler agents handling well-scoped tasks may not need vector databases.
Reliability and hallucination
Agents still fail often. On structured benchmarks, agents "still fail roughly one in three attempts," according to the Stanford 2026 AI Index. In the same report, accuracy on OSWorld, a computer-use benchmark, rose from roughly 12% to 66.3%. Capability is climbing fast, but a one-in-three failure rate needs guardrails in any production flow.
Builders who already ship agents see the same quality gap. In LangChain's own survey of agent builders, 57.3% of respondents run agents in production. LangChain surveyed people who already build agents, so its share runs higher than Gartner's 17% of organizations.
One third of respondents name quality as their primary blocker. Agents also ingest outputs from many external components, and conflicting information can lead to hallucination. Behavior can shift after small prompt changes. Add prompt regression tests and validate tool outputs before the agent acts on them.
For a prompt-regression test, fix one question, such as a refund-policy query, and its retrieved text:
- Run the current prompt against the question and tool result.
- Run the changed prompt against the same inputs.
- Compare the final answer and the selected tool calls.
- Check that neither version invents a policy unsupported by the retrieved text.
For prompt sensitivity, the Prompt Engineering Guide offers these mitigations: trial-and-error crafting, automatic tuning, and automatic generation with GPT. Each still needs regression testing. A new prompt alone doesn't prove better reliability.
The same guide still lists prompt reliability, hallucination, long-term planning, and finite context length as open challenges. Benchmark results and survey responses don't guarantee reliability on your workload.
Security requirements
Gartner predicts 40% of enterprises will demote or decommission autonomous agents by 2027 because of governance gaps. If you sell to enterprises, those gaps can surface during procurement reviews.
Put these controls in place before launch:
- Grant each tool only the permissions it needs for its task.
- Require human approval for high-impact, low-reversibility actions.
- Run generated code in a microVM sandbox.
Isolation doesn't address every model risk.
IBM Research also warns that LLMs can reproduce bias, hate speech, and personal data from training data:
| Risk | Control to consider |
|---|---|
| Biased or hateful output | Data filtering and output checks |
| Personal-data disclosure | Limit access to sensitive information and check outputs for unnecessary personal data |
| Prompt-driven unauthorized action | Enforce permissions outside the model and require approval for sensitive operations |
How Baseten Sandboxes power LLM agents for engineering teams
For agents that execute code, the execution layer addresses isolation, runtime state, and startup latency. Teams can manage their own microVM infrastructure or use agent infrastructure platforms like Baseten Sandboxes, the infrastructure foundation for autonomous agents. Blaxel provides that layer with sandboxes on Firecracker microVMs, plus Volumes and Batch Jobs.
MicroVM isolation for untrusted agent code
Your security team will ask one question before approving an agent: what happens when it runs malicious code? A prompt injection hidden in a README or API response can steer an agent into writing that code. If the code runs on a shared kernel, one compromised session can reach other tenants. Without a clear answer, security reviews stall and enterprise sales cycles lengthen.
Baseten Sandboxes run every sandbox in its own Firecracker microVM. In the README case, the injected code runs inside that sandbox's microVM, away from other customers' sessions. Blaxel meets SOC 2 Type II, HIPAA, and ISO 27001 compliance requirements. Your security team can cite the per-sandbox kernel boundary when the malicious-code question comes up.
Sandboxes that resume in under 25ms between tool calls
Coding agents pause constantly while they wait on model responses, user edits, and slow third-party APIs. If your infrastructure keeps compute running through those gaps, you pay for idle time. If it shuts down, the next request waits seconds for a fresh environment to boot. Neither option works for interactive coding sessions.
Baseten Sandboxes move to standby after approximately 15 seconds of network inactivity. In standby, you avoid paying for idle compute. When the next request arrives, the sandbox resumes from standby in under 25ms, with memory and filesystem state intact. New sandboxes from a template start in under a second.
Agent state that outlasts the session, with Volumes and Agent Drive
Long-running agents build up expensive environment state. They clone repositories, install dependencies, and generate intermediate artifacts. Without persistent storage, every new session repeats that setup. Lost state also breaks multi-agent handoffs, where one agent's output becomes another's input.
Standby covers state within one session. Blaxel adds two layers for state that must outlast it:
- Volumes: Each Volume is block storage that a sandbox mounts as a directory. Use Volumes when data must outlive the sandbox that wrote it.
- Agent Drive: A distributed filesystem, in private preview, that multiple sandboxes mount at once with concurrent read-write access. It lets agents share context, tool outputs, and artifacts across sessions.
Attaching a Volume takes one field in the sandbox definition, per the Volumes docs:
Python
from blaxel.core import SandboxInstance
sandbox = await SandboxInstance.create_if_not_exists({
"name": "my-sandbox",
"image": "blaxel/nextjs:latest",
"memory": 4096,
"region": "us-pdx-1",
"volumes": [{
"name": "my-volume", # Must match the name of the created volume
"mount_path": "/app", # Directory inside the sandbox
"read_only": False # Set to True to prevent writes
}],
})
Files the sandbox writes to /app stay on the Volume even after you delete the sandbox.
Match the layer to the workload. A single-session bug fix needs only standby. A research agent passing files between sub-agents needs Agent Drive.
Parallel evaluation and processing runs on Batch Jobs
Slow evaluation runs mean prompt changes reach users with less testing than they need. Some agent work splits cleanly into independent tasks and needs no interactive session. Examples include running a test suite across many configurations, reprocessing a large dataset, or evaluating an agent against a benchmark.
Run them sequentially, and they can take hours. Build your own queue and worker fleet, and you've added infrastructure your team has to maintain.
Blaxel Batch Jobs run many AI tasks in parallel, each in its own sandbox, on scheduled or on-demand triggers. For agent evaluation, you trigger the whole benchmark on demand after each prompt change. You can also schedule the same run, so it repeats without anyone starting it.
Sandboxes that fit the agent framework you already use
Switching frameworks to adopt new infrastructure shouldn't be a cost your team has to pay. Your agents already run on an SDK, and your engineers know its patterns. The execution layer should fit under that SDK.
Blaxel is a first-class sandbox provider in the OpenAI Agents SDK. Agents built with the Claude Agent SDK connect through the MCP server that every Blaxel sandbox exposes. The server gives agents tool calls for files, processes, and code search, per the sandbox MCP docs. Coding agents can also operate Blaxel directly through the CLI skill.
The skill lets them create sandboxes, Agent Drives (in private preview), and Batch Jobs with the bl CLI. Blaxel SDKs cover Python, TypeScript, and Go.
Run LLM agents that execute code on infrastructure built for them
LLM agents differ from chatbots because the model decides what happens next, including which code to run. The choice moves risk into the execution layer, where agents need hardware-enforced isolation and state that survives between turns.
Baseten Sandboxes cover that layer with microVM sandboxes that resume in under 25ms, plus Volumes for persistent state.
FAQs about LLM agents
How do LLM agents differ from chatbots?
A standard chatbot returns a one-shot response to each prompt. An agent chooses its own next step and takes actions that change its environment. Agents combine planning modules, memory systems, and tool integration, so they pursue goals across many steps. Chatbots typically generate text without persistent state or environmental interaction.
What is the difference between an LLM agent and an AI agent?
In practice, the two terms mean nearly the same thing. Because LLMs drive most modern agents, people often call AI agents LLM agents. "AI agent" is the broader term, since some AI agents don't use an LLM.
What security risks do LLM agents introduce?
Agents often mix trusted instructions and untrusted data in one input, so injected text can redirect their reasoning. Attackers hide instructions in documents, web pages, or tool outputs. OWASP also warns about agents with more functionality, permissions, or autonomy than a task needs. Limit each tool's permissions and require approval for sensitive actions.
Why do agents need isolated execution environments?
Many agents write code during execution based on prompts and external data. You can't fully audit that code beforehand because the agent generates it at runtime. A microVM per workload is the safer boundary for untrusted code.
How do production agents handle memory and state?
Production agents keep two kinds of memory. The context window holds the current task, and external storage holds what must outlast it. Execution state is a separate concern. Cloned repositories, installed packages, and generated files live on the runtime's filesystem and need their own persistence plan.
Related articles

Guides
What is a computer use agent? How AI agents automate GUI workflows
Learn how a computer use agent operates software through screenshots, clicks, and keystrokes.
13 min read

Guides
A guide to Bring Your Own Cloud (BYOC) for enterprise leaders
Learn what BYOC is and how Bring Your Own Cloud splits the control and data planes for enterprise workloads.
12 min read

Guides
How gVisor vs Firecracker compare for sandboxing AI agent workloads
Compare gVisor vs Firecracker on isolation, startup, I/O overhead, KVM needs, and Kubernetes fit to choose the right sandbox runtime.
12 min read