๐ข Building Enterprise-Ready AI Agents ๐ค - A Practical Field Guide ๐
๐ How to use this guide
Read Parts 0-2 to decide whether and what to build. Most failed agent projects die here.
Read Parts 3-7 for the architecture and reliability engineering.
Read Parts 8-10 for the enterprise gates: security, compliance, multi-tenancy, observability, cost.
Read Parts 11-15 for delivery, scale & rollout: deployment topologies (SaaS/self-hosted/hybrid), how to adopt from pilot to org-wide, how to handle thousands of concurrent requests, the operating model, and a 30/60/90 plan.
Every part ends with an โ Actionable checklist. Skim those for a design review.
๐ Table of Contents
๐งฎ Part 0 - The Core Equation
๐งญ Part 1 - Decide Before You Build: Workflow vs Agent, Build vs Buy
๐๏ธ Part 2 - The Enterprise Tax: What Actually Changes
๐๏ธ Part 3 - Reference Architecture: The Layered Stack
๐ Part 4 - The Reliable Kernel: The Agent Loop
๐ ๏ธ Part 5 - Tools & Enterprise Integration
๐ง Part 6 - Context & Memory: The Cost Center
๐ Part 7 - Reliability Engineering
๐ Part 8 - Security, Compliance & Governance
๐งฑ Part 9 - Multi-Tenancy & Isolation
๐ Part 10 - Observability, Evals & Cost Governance
๐ Part 11 - Deployment & Delivery Models
๐ Part 12 - The Scaling Path: Small to Large
๐ Part 13 - Performance & Horizontal Scale: Thousands of Concurrent Runs
๐ฅ Part 14 - The Operating Model: People & Process
๐ฆ Part 15 - Rollout: A 30/60/90 Plan + Go-Live Checklist
๐ซ Part 16 - Anti-Patterns
๐ Closing
๐บ๏ธ Companion Reads
๐งฎ Part 0 - The Core Equation
The single most important idea in agent engineering:
Reliability โ Model capability ร Harness quality
(mostly fixed) (your job)
The model is roughly fixed for the life of your project. The harness - system prompts, tools, sandboxes, memory, orchestration, guardrails, and observability - is where ~80% of production quality comes from. After hundreds of production sessions the pattern is consistent: It's almost never a model problem. It's a configuration and harness problem.
For enterprise, add a second equation that most teams discover too late:
Enterprise-readiness โ Harness quality ร Trust surface (security + governance + observability)
A brilliant agent that can't prove what it did, can't be scoped to a tenant, and can't be audited will not ship in a regulated company. Budget for the trust surface from day one - it is not a phase 2 feature.
๐งญ Part 1 - Decide Before You Build
1.1 Workflow or Agent?
Anthropic's guidance (Building Effective Agents, 2024) draws the line that matters:
| Workflow | Agent | |
|---|---|---|
| Control flow | Predefined code paths | LLM directs its own steps |
| Best for | Well-defined, decomposable tasks | Open-ended tasks, unknown # of steps |
| Cost/latency | Low, predictable | Higher, variable |
| Failure mode | Predictable | Compounding errors |
Rule: start with the simplest thing that works - a single well-prompted LLM call with retrieval often beats an agent. Add agentic autonomy only when the number of steps is genuinely unpredictable (e.g. coding, research, multi-system triage). Autonomy trades latency and cost for capability; make that trade deliberately.
The common production patterns, in rising order of complexity:
augmented LLM โ prompt chaining โ routing โ parallelization โ orchestrator-workers โ evaluator-optimizer โ autonomous agent.
Reach for the lowest rung that solves the problem.
For fixed business processes, make the control flow deterministic. Expense approvals, employee onboarding, KYC, and refund flows have known steps - encode them as an explicit state machine / durable workflow (e.g. LangGraph for the graph, Temporal for durable execution) and let the LLM be flexible only inside a bounded sub-task ("draft the summary," "classify this ticket"). This is the single most effective cure for the runaway-reasoning-loop failure in corporate settings: the agent literally cannot wander outside the defined transitions. Reserve open-ended autonomy for the genuinely unpredictable work. (Budgets, stuck detection, and circuit breakers in Part 4 and Part 7 back this up - a state machine bounds what can happen, budgets bound how long.)
1.2 Build vs Buy vs Assemble
| Path | When it's right | Watch out for |
|---|---|---|
| Buy a SaaS agent | Commodity use case (support deflection, meeting notes) | Data residency, lock-in, no access to the harness |
| Assemble on a platform/SDK | You want control of the harness but not the kernel | Framework abstraction hiding prompts/tokens - insist you can see them |
| Build the harness on raw LLM APIs | Differentiated workflow, strict data/compliance needs | Cost of the "last mile" to production is large |
Anthropic's advice holds: frameworks help you start but "reduce abstraction layers and build with basic components as you move to production." If a framework hides the prompts and token flow, you can't debug or cost-control it - a dealbreaker at scale.
1.3 Qualify the use case with 5 questions
A use case is a good agent fit when you can answer yes to most of these:
- Verifiable success? Can you check the outcome (tests pass, ticket resolved, invoice matched)?
- Feedback loop? Does the environment give ground truth each step (tool results, errors)?
- High enough value? Agents use ~4ร the tokens of a chat; multi-agent ~15ร (Anthropic). The task must be worth it.
- Tolerable blast radius? What's the worst a wrong action does? Scope permissions to that.
- Human oversight fits naturally? Support, coding, and ops all have obvious review points.
โ Part 1 checklist
- [ ] Chose the lowest rung (workflow before agent) that solves the problem
- [ ] Wrote down the success metric and how it's measured automatically
- [ ] Ran a build/buy/assemble decision with data-residency constraints included
- [ ] Estimated cost-per-task and confirmed the task value exceeds it
๐๏ธ Part 2 - The Enterprise Tax
A consumer demo becomes an enterprise product when it satisfies requirements that have nothing to do with the model. Plan for these before the pilot, because retrofitting them is expensive.
| Requirement | What it means concretely |
|---|---|
| Identity & access | SSO (SAML/OIDC), SCIM provisioning, role-based access to tools and data |
| Multi-tenancy | Hard isolation of data, secrets, workspaces, and cost per company/team |
| Data governance | Data residency/region pinning, retention limits, PII handling, "no-train" guarantees |
| Auditability | Every action attributable to a user + reproducible; immutable audit log |
| Compliance | SOC 2 Type II, ISO 27001, GDPR/CCPA, and sector rules (HIPAA, PCI-DSS, FINRA) |
| Security | Prompt-injection defense, secrets isolation, sandboxing, least privilege |
| Reliability/SLA | Uptime targets, graceful degradation, incident response, RTO/RPO |
| Cost control | Per-tenant budgets, rate limits, chargeback/showback, model routing |
| Observability | Tracing, evals, alerting - without logging sensitive conversation content |
| Change management | Versioned prompts/tools, safe rollout, rollback, user training |
The mindset shift: in traditional software a bug breaks a feature. In an agent, a minor change cascades - one bad step sends the agent down an entirely different trajectory (Anthropic, Multi-Agent Research System). The enterprise tax is what keeps those cascades observable, bounded, and reversible.
โ Part 2 checklist
- [ ] Named the compliance regime(s) you must satisfy and the data classes involved
- [ ] Confirmed a "no-train / data-isolation" path with your model provider
- [ ] Decided the tenancy boundary (company / team / user) up front
- [ ] Made audit logging a P0, not a P2
๐๏ธ Part 3 - Reference Architecture
Every production agent that works is recognizably the same system: a small reliable kernel loop wrapped in a thoughtfully engineered harness, exposed through thin surface adapters. Here is the enterprise-shaped version.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SURFACES (thin adapters) โ
โ Web app ยท Slack/Teams ยท IDE ยท API ยท Email ยท Cron/Webhook โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ authenticated, per-tenant request
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GATEWAY / CONTROL PLANE โ
โ AuthN (SSO) ยท AuthZ (RBAC) ยท rate limit ยท budget check ยท routingโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AGENT RUNTIME (the kernel) โ
โ Loop: Observe โ Think โ Act โ Observe โ
โ Session state (append-only events) ยท iteration/cost budgetsโ
โ Context engine (cache-stable prefix + compaction) โ
โ Sub-agent orchestration (context firewalls) โ
โโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ โ โ โ
โโโโโผโโโโโโ โโโโโโโผโโโโโโ โโโโโโโผโโโโโโโ โโโโโโผโโโโโโโโโโ
โ TOOLS โ โ MEMORY โ โ SANDBOX โ โ MODEL LAYER โ
โ registryโ โ L0/L1/L2 โ โ per-tenant โ โ provider โ
โ + MCP โ โ + files โ โ isolation โ โ abstraction โ
โโโโโฌโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ
โ enterprise connectors (RBAC-scoped, per-tenant secrets)
โโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SYSTEMS OF RECORD: DB ยท CRM ยท ticketing ยท data โ
โ warehouse ยท APIs โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Cross-cutting: OBSERVABILITY (tracing, metrics, evals, cost)
SECURITY (guardrails, secrets, audit)
GOVERNANCE (policy, HITL approvals)
Design principles that make this scale (from OpenHands V1, Hermes, GoClaw):
- One loop, many surfaces. A single agent core powers CLI, chat, API, and cron. Surfaces are thin translators, not forks of the logic.
- Immutable models + append-only state. Agent, tools, and config are immutable; the only mutable thing is
ConversationState, which you append events to, never mutate in place. This makes the system replayable, debuggable, auditable, and safe to parallelize. - The loop is an async generator, not a web of callbacks - you get backpressure, cancellation, and typed terminal states for free.
- Control plane is separate from the runtime. Auth, budgets, and routing live in front of the loop so you can enforce policy without touching agent logic.
โ Part 3 checklist
- [ ] Kernel is one loop; surfaces are adapters
- [ ] State is append-only events (replayable/auditable)
- [ ] Control plane (auth/budget/routing) sits in front of the runtime
- [ ] Provider access goes through one abstraction, never scattered SDK calls
๐ Part 4 - The Reliable Kernel
4.1 The loop
All production agents converge on Observe โ Think โ Act โ Observe - 4-5 phases, not a callback web. Keep the kernel small and boring; put cleverness in the harness.
Three proven shapes:
- Async generator (OpenHands, Claude Code) - yields each step; caller controls backpressure/cancellation.
- Explicit
step()returning a typed union (SWE-agent, GoClaw) - a ~30-lineforward_with_handling()wraps the model call with requery on format errors (max 3). - Per-session FIFO steering queue (nanobot, PicoClaw) - a user can inject a correction mid-loop; queued-but-unrun tools are skipped with a synthetic
"Skipped due to user message"result so the model knows what didn't run.
4.2 The tool_use / tool_result invariant - the #1 correctness bug
Every tool_use must have a paired tool_result before the next model call (API requirement). On cancellation or error, emit a synthetic result ("Cancelled: Bash(mkdir) errored"). OpenHands' runner enforces: drop orphan results, backfill missing ones, and microcompact each iteration. Get this wrong and you get random 400s and corrupted transcripts in production.
4.3 Budgets: stop on cost, not vibes
| Budget | Default | Why |
|---|---|---|
| Max iterations / task | 20-25 | Bound runaway loops |
| Per-task cost cap | e.g. $2-$3 | Cost is the real stop signal - step count varies 5ร across models |
| Max requeries on parse fail | 3 | Don't loop on malformed output |
| Consecutive timeouts | 5 โ hard abort | Escape stalls |
| Context overflow | compact at ~80%, then continue | Never hit a hard 400 |
Anthropic's own finding: token usage alone explains ~80% of task-performance variance on hard browse tasks. Budgets aren't just cost control - they're your primary lever on both quality and spend.
โ Part 4 checklist
- [ ] Loop is 4-5 phases, kernel < a few hundred lines
- [ ] Synthetic
tool_resultemitted on every error/cancel path - [ ] Stop conditions are cost-based, with iteration/timeout backstops
- [ ] Steering queue lets a human correct mid-run
๐ ๏ธ Part 5 - Tools & Enterprise Integration
Tools are the agent's hands - and, per Anthropic, you should spend as much effort on the agent-computer interface (ACI) as on the prompt. On SWE-bench they spent more time optimizing tools than the overall prompt.
5.1 Design tools like a great docstring for a junior engineer
- Poka-yoke (mistake-proof) the inputs. SWE-agent forced absolute file paths after seeing the model fail with relative ones once it changed directories - the fix was flawless thereafter.
- High-signal outputs only. Return
name,image_url(semantic) - notuuid,256px_image_url(noise). - Paginate and cap responses (~25K tokens) by default; steer toward many small searches over one giant dump.
- Consolidate chained calls.
schedule_event(finds availability and books in one call) beatslist_users โ list_events โ create_event. Fewer round-trips = fewer tokens, fewer errors. - Instructive errors. A tool error should tell the model how to fix it, not just fail.
Comments
No comments yet. Start the discussion.