Building Enterprise AI Agents: A Practical Guide
How to build AI agents that hold up at work: use cases, tool and permission design, context, evals, durable execution, observability and governance.
Building an enterprise AI agent means turning a language model that can call tools into a system a company can trust with real work: one that has narrowly scoped permissions, is measured against realistic tests, survives failures, can be traced after the fact, and fits the organization's risk rules. The model is the easy part. The work that decides success is choosing the right task, designing tools and permissions, managing context, building evaluations, and running the agent like any other production service.
If you need the fundamentals first, see our agentic AI guide and AI agents vs AI assistants. For the risk side in depth, see AI agent security and governance. This guide walks through the build.
Step 1: Pick a task that actually needs an agent
Not every automation should be an agent. Anthropic separates workflows, where "LLMs and tools are orchestrated through predefined code paths," from agents, where "LLMs dynamically direct their own processes and tool usage" [1]. Agents cost more and can compound errors, so they belong where the path can't be scripted in advance [1]. Microsoft's Agent Framework docs are blunter: "If you can write a function to handle the task, do that instead of using an AI agent" [9].
Good first candidates share four traits:
- Variable steps. The path depends on what the agent finds (triaging a ticket, researching a vendor, fixing a failing test).
- Checkable outcomes. You can verify success: a test passes, a record exists, a reviewer approves. Anthropic stresses that agents need "ground truth" from the environment at each step [1].
- Bounded blast radius. Mistakes are recoverable, or a human approves anything that isn't.
- Existing tools. The systems the agent needs already have APIs.
Situation | Build | Why |
|---|---|---|
Fixed, well-understood steps | Plain code or a workflow | Cheaper, predictable [1][9] |
Variable steps, low risk, checkable | Single agent with tools | Flexibility where it pays |
Variable steps, high-impact actions | Agent + human approval gates | Autonomy without unreviewed risk [7] |
Broad, parallel research | Multi-agent (orchestrator-workers) | Parallel exploration, at much higher token cost [5] |
On that last row, be realistic about cost. Anthropic reported that its agents use about four times the tokens of chat, and its multi-agent system about 15 times [5]. Read our multi-agent systems explainer before reaching for one.
Step 2: Design the architecture
A production agent has five layers. Each is a decision, not a default.
- Model. Choose for tool-use reliability and reasoning, not benchmark headlines. Plan to swap models later; keep prompts and tool definitions versioned. (Background: how large language models work.)
- Instructions. The system prompt defines the role, rules and when to stop or escalate.
- Tools. The agent's hands. See Step 3.
- Context and memory. What the agent sees each step and what it remembers. See Step 4.
- Orchestration. The loop, routing, state, limits and approvals. A framework can help here; our orchestration frameworks guide compares the main options.
Decide early how much control the model gets. OpenAI's documentation contrasts orchestrating via the LLM (flexible, for open-ended tasks) with orchestrating via code, which "makes tasks more deterministic and predictable, in terms of speed, cost and performance" [11]. Most enterprise agents end up as hybrids: code-defined stages with an agent inside the stages that need judgment.
Step 3: Build tools for agents, not for programmers
Tools are where agents most often fail, and where most of the security risk sits.
Design for the model. Anthropic's guidance is to build a few purposeful tools aimed at high-impact workflows rather than wrapping every API endpoint, noting that "more tools don't always lead to better outcomes" [3]. Return meaningful, human-readable context instead of raw IDs, namespace related tools, and describe each tool as you would "to a new hire on your team" [3]. Keep outputs lean with pagination, filtering and truncation; Claude Code caps tool responses at 25,000 tokens by default [3]. Anthropic also suggests "poka-yoke" tool design: shape arguments so mistakes are hard to make [1]. The mechanics of tool definitions are covered in AI agent tools and function calling.
Standardize connections. The Model Context Protocol lets you expose internal systems once as MCP servers and reuse them across agents. Its specification is explicit that "tools represent arbitrary code execution and must be treated with appropriate caution," that tool descriptions should be treated as untrusted unless they come from a trusted server, and that hosts must get explicit user consent before invoking any tool [6]. The protocol can't enforce those principles itself; implementers are expected to build the consent and authorization flows [6].
Constrain permissions. OWASP's "Excessive Agency" entry identifies three root causes: excessive functionality, excessive permissions and excessive autonomy [7]. Its prevention list maps directly to enterprise design:
- Give the agent only the tools it needs, with only the operations it needs [7].
- Prefer narrow tools over open-ended ones like a general shell [7].
- Run tools with the requesting user's identity and minimal scopes, for example via OAuth [7].
- Require human approval for high-impact actions [7].
- Enforce authorization in the downstream system, "rather than relying on an LLM to decide if an action is allowed or not" [7].
That last point is the one teams most often miss. The model's judgment is never your access control. Pair this with your existing identity and access management and zero trust policies.
Step 4: Engineer the context
Enterprise agents run long and read a lot, so context management is a reliability issue, not just a cost issue. Anthropic reports that as context grows, the model's recall of it degrades, a problem it calls context rot, and recommends finding "the smallest possible set of high-signal tokens" for each step [2].
Practical techniques from the same guidance [2]:
- Just-in-time retrieval: keep references (file paths, record IDs, saved queries) and load data with tools when needed, instead of stuffing everything into the prompt.
- Compaction: summarize long histories and continue in a fresh window.
- Tool-result clearing: drop raw outputs once they've been used.
- Structured notes: have the agent keep a progress file or to-do list outside the context window.
- Sub-agents: delegate focused work to agents with clean windows that return condensed summaries.
For knowledge lookups, ground the agent in your documents with retrieval-augmented generation or agentic RAG, and treat retrieved text as untrusted (see RAG security). Our agent memory explainer covers short- and long-term memory design.
Step 5: Build evaluations before you scale
Without evals, every prompt change is a gamble. Anthropic's January 2026 guide to agent evals offers a clear vocabulary [4]:
- A task is one test with defined inputs and success criteria.
- A trial is one attempt; you run several because outputs vary.
- A grader scores some aspect of performance: code-based (fast, objective, brittle), model-based (flexible, needs calibration) or human (gold standard, slow).
- The transcript is the full record of a trial; the outcome is the final state of the environment, such as whether a reservation really exists in the database.
Two practical points stand out. First, start small: "20-50 simple tasks drawn from real failures" is enough to begin [4]. Second, choose the right metric. pass@k (at least one success in k tries) suits tasks where one good answer is enough; pass^k (all k tries succeed) suits customer-facing agents where consistency matters. At a 75% per-trial success rate, the chance of passing three trials in a row is about 42% [4].
Keep two suites: capability evals that start with low pass rates and measure progress, and regression evals that should sit near 100% and catch backsliding [4]. Grade outcomes in the real (or sandboxed) system, not just the agent's claims of success. Anthropic recommends extensive testing in sandboxed environments before granting autonomy [1].
Step 6: Engineer for failure and recovery
Agents fail mid-task: an API times out, a model call errors, a deploy restarts the container. In a multi-step task, restarting from scratch is costly and can repeat side effects.
- Durable execution. Save state at each step so a run can resume. LangGraph's checkpointers, for example, save a snapshot at every super-step, keep successful nodes' writes when another node fails, and offer durability modes that trade speed for safety [10]. Anthropic built its research system to resume from where an error occurred rather than restart [5].
- Idempotent side effects. If a step may run twice after a resume, make sure running it twice is harmless.
- Limits. Cap iterations, tokens, time and spend per run. Anthropic lists stopping conditions such as a maximum number of iterations as standard practice [1].
- Safe deploys. Long-running agents can be mid-task during a release. Anthropic uses rainbow deployments, gradually shifting traffic so running agents aren't disrupted [5].
- Approval gates. Pause before irreversible actions and resume after review; see human-in-the-loop AI.
Step 7: Make it observable
You can't fix what you can't see. Trace every run: model calls, tool calls with arguments and results, retrieved context, decisions, token use and latency. Anthropic credits full production tracing with helping it diagnose agent failures, and notes it monitored decision patterns without reading conversation contents, a model worth copying where privacy matters [5]. Feed failed transcripts back into your eval suite [4]. For the broader discipline, see observability vs monitoring.
Step 8: Govern it like any other AI system
Agents act, so governance must cover actions as well as outputs.
- Use a recognized framework. In the US, NIST's AI Risk Management Framework (AI RMF 1.0, released January 2023) is the common voluntary reference, organized around four functions: Govern, Map, Measure and Manage [8]. NIST added a Generative AI Profile (NIST AI 600-1) in July 2024, and as of November 2026 says the AI RMF is being revised under the White House AI Action Plan [8].
- Inventory agents and their permissions. Know which agents exist, what tools each can call, and whose identity they act under.
- Log for audit. Keep tamper-evident records of actions taken and approvals given.
- Plan for cross-company agents. If your agents will talk to partners' agents, the A2A protocol requires authentication on every request and supports schemes including OAuth 2.0, OpenID Connect and mutual TLS [12]. Our agent-to-agent communication explainer covers the details.
Common pitfalls
- Starting with a multi-agent design. Begin with one agent and add more only when evals show the need [1][5].
- Too many tools. Overlapping tools confuse the model; consolidate [3].
- Trusting the model with authorization instead of enforcing it downstream [7].
- No evals until production. Build the first 20 to 50 tasks before launch [4].
- Unbounded loops and spend. Always set limits [1].
- Hidden framework behavior. Anthropic advises understanding the code beneath any framework you adopt [1].
Outlook
Expect enterprise agent work to look more like ordinary software engineering over time: versioned prompts and tools, eval suites in CI, standard protocols (MCP for tools, A2A for agents) and governance aligned with frameworks such as NIST's. Vendors are competing hard for this market; for context, see our coverage of how Google is building its AI agent ecosystem and Anthropic's enterprise push with coding agents. The teams that succeed will be the ones that treat the agent as a system to be measured and constrained, not a model to be trusted.
Frequently asked questions
What is the difference between an enterprise AI agent and a chatbot?
A chatbot answers; an agent acts. An enterprise agent calls tools that read and change business systems, so it needs scoped permissions, approval gates, evaluations and audit logs that a chatbot may not [1][7]. See AI agents vs AI assistants.
How do you evaluate an AI agent?
Define tasks with clear success criteria, run several trials each, and score them with code-based, model-based or human graders, checking the final state of the environment rather than the agent's own report [4]. Anthropic suggests starting with 20 to 50 tasks drawn from real failures [4].
Should we build agents with a framework or directly on model APIs?
Anthropic recommends starting with model APIs directly because many patterns need only a few lines of code [1]. Frameworks help once you need durable state, complex routing, human approvals or multi-agent coordination; compare options in our orchestration frameworks guide.
How do we stop an agent from doing something harmful?
Limit what it can do, not just what it's told. Give it minimal tools and permissions, run tools under the user's identity, enforce authorization in downstream systems, and require human approval for high-impact actions [7]. Add iteration and spend limits [1].
How much do AI agents cost to run?
It depends on the model, task length and design. As a rough guide from one vendor's own systems, Anthropic measured agents using about four times the tokens of chat and multi-agent systems about 15 times [5]. Track tokens per successful task in your evals to see your real cost.
Sources
- Anthropic, "Building effective agents." https://www.anthropic.com/engineering/building-effective-agents
- Anthropic, "Effective context engineering for AI agents." https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
- Anthropic, "Writing effective tools for agents โ with agents." https://www.anthropic.com/engineering/writing-tools-for-agents
- Anthropic, "Demystifying evals for AI agents." https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents
- Anthropic, "How we built our multi-agent research system." https://www.anthropic.com/engineering/multi-agent-research-system
- Model Context Protocol, "Specification" (revision 2026-07-28). https://modelcontextprotocol.io/specification/2026-07-28
- OWASP Gen AI Security Project, "LLM06:2025 Excessive Agency." https://genai.owasp.org/llmrisk/llm062025-excessive-agency/
- NIST, "AI Risk Management Framework." https://www.nist.gov/itl/ai-risk-management-framework
- Microsoft Learn, "Microsoft Agent Framework Overview." https://learn.microsoft.com/en-us/agent-framework/overview/agent-framework-overview
- LangGraph documentation, "Checkpointers." https://docs.langchain.com/oss/python/langgraph/checkpointers
- OpenAI Agents SDK documentation, "Orchestrating multiple agents." https://openai.github.io/openai-agents-python/multi_agent/
- A2A Project, "Agent2Agent (A2A) Protocol Specification." https://a2a-protocol.org/latest/specification/