Skip to article content All articles

The Real Architecture Behind Production AI Agents

An engineer’s guide to the identity, orchestration, durable execution, policy, and observability that turn an agent demo into a trustworthy work system.

Abhishek Choudhury

Abhishek Choudhury

May 5, 2026 · Updated July 29, 2026 · 8 min read

Hands routing colorful cables across an analog orchestration patchboard
On this page8 min left

At a glance

  1. A production agent is an identity-aware work system around a model, not a prompt connected directly to business tools.

  2. Long-running work needs durable state, bounded retries, idempotent actions, and explicit recovery paths.

  3. Autonomy should increase only when an action’s permissions, reversibility, evidence, and business risk are understood.

01The boundary

A demo answers. A production system completes work.

Most agent diagrams show a clean sequence: context, rules, agents, action. It is elegant and easy to explain. But the moment an agent can create a ticket, comment on a pull request, send an email, or change a business record, the model is no longer the whole system. It is one decision-making component inside a backend that must control identity, state, risk, and failure.

A demo can succeed once while a developer watches. A production system must behave predictably across different users, permissions, tools, partial outages, duplicated events, and long pauses. It must also leave enough evidence for an operator to reconstruct what happened.

Three execution shapesChoose an execution model from the duration, coordination, and recovery needs of the work—not from how sophisticated the demo should appear.
DecisionRequest-boundSynchronous agent loopStatefulDurable workflowDecoupledEvent-driven coordination
Best forShort, low-risk tasks that can finish inside one interaction.Multi-step work that must pause, resume, retry, or await approval.Work spanning multiple services, teams, or specialist agents.
You ownPrompt, tool loop, request timeout, and immediate response.Workflow state, checkpoints, retry policy, timeouts, and compensation.Events, schemas, queues, consumers, ordering, and duplicate delivery.
Trade-offSimple to operate, but fragile when work waits on people, webhooks, or slow tools.More infrastructure, but failures and long waits become explicit states.Scales coordination well, but causality and debugging require strong tracing.
ExamplesSummarise a document, draft a reply, classify an incoming ticket.Investigate an incident, prepare a release, review and update a customer case.PR-to-QA handoff, support escalation, cross-system onboarding.

Request-bound

Synchronous agent loop

Best for
Short, low-risk tasks that can finish inside one interaction.
You own
Prompt, tool loop, request timeout, and immediate response.
Trade-off
Simple to operate, but fragile when work waits on people, webhooks, or slow tools.
Examples
Summarise a document, draft a reply, classify an incoming ticket.

Stateful

Durable workflow

Best for
Multi-step work that must pause, resume, retry, or await approval.
You own
Workflow state, checkpoints, retry policy, timeouts, and compensation.
Trade-off
More infrastructure, but failures and long waits become explicit states.
Examples
Investigate an incident, prepare a release, review and update a customer case.

Decoupled

Event-driven coordination

Best for
Work spanning multiple services, teams, or specialist agents.
You own
Events, schemas, queues, consumers, ordering, and duplicate delivery.
Trade-off
Scales coordination well, but causality and debugging require strong tracing.
Examples
PR-to-QA handoff, support escalation, cross-system onboarding.

02The system map

The operating layer around the model

The architecture becomes easier to reason about when it is divided by responsibility. Connectors move data and actions across system boundaries. Identity and context decide what the caller may know. Orchestration coordinates work. Policy limits actions. Durable state and observability make the system recoverable and inspectable.

Loading diagram…

  1. Enterprise systems expose knowledge, events, and actions through connectors.
  2. Identity and access controls establish what the caller may read or change.
  3. The context layer supplies relevant, permission-safe evidence.
  4. The orchestrator routes and coordinates the workflow.
  5. Bounded agents propose work through typed tools.
  6. Policy evaluates every proposed external action.
  7. Low-risk allowed actions execute; higher-risk actions pause for human review.
  8. Durable state records progress so the workflow can pause, retry, and recover.
  9. Observability and evaluation trace the workflow and measure its outcome.
The production-agent operating layer. The model is one component inside a governed work system. Trust, recovery, and control come from the operating layer around it.

These are logical boundaries, not a requirement for ten separate services. A small team can implement several responsibilities in one application. The important part is that the boundaries remain visible in code, data, and traces.

03The trust boundary

Connectors, identity, and context

A connector is not merely an API wrapper. It must handle pagination, webhooks, incremental sync, deletions, rate limits, retries, metadata, and source-specific semantics. It must also distinguish reading data from taking action because those operations rarely deserve the same authority.

  • Propagate the caller. Prefer user-scoped authorization when the action represents a user. Use service identities only for explicitly system-owned work.
  • Minimise capability. Restrict tokens to the resources and actions required for the current task. OAuth security guidance recommends restricting access-token privilege by resource and action.
  • Enforce access before disclosure. Permission checks belong in retrieval and tool execution, before restricted content reaches prompts, traces, or logs.
  • Preserve provenance. Keep source identifiers, revisions, owners, and timestamps so the agent and the reader can judge authority and freshness.

The detailed indexing and retrieval mechanics are covered in the RAG 101 visual guide. Here, the key architectural rule is that enterprise context must remain permission-aware from ingestion through action.

Technical deep dive: identity is part of workflow state

A resumed workflow must not assume that yesterday’s authority is still valid. Store who requested the work and the intended authorization scope, but revalidate credentials and policy before a new tool call. A checkpoint should preserve intent—not turn an expired token into permanent permission.

04Coordination

Orchestration and agent execution

Agents do not coordinate by magic. If a product task leads to implementation, testing, and release, some component must decide what happens next, persist the current stage, route the work, and handle a failed or late response.

  • The orchestrator owns progress. It decomposes or routes work, records transitions, applies timeouts, and decides whether a failure should retry, compensate, escalate, or stop.
  • An agent owns bounded judgment. It interprets context and proposes or performs work through a limited tool set with explicit success criteria.
  • Tools own deterministic effects. Tool adapters validate structured input, enforce authorization, use idempotency keys, and return typed results.
  • Policy owns permission to proceed. The model may recommend an action, but deterministic controls decide whether the action is allowed and whether approval is required.

05Long-running work

Durable state and asynchronous execution

Useful work often spans minutes, hours, or days. Tests run, webhooks arrive, people approve, rate limits reset, and external systems recover. Holding all of that inside a request or model conversation makes the workflow difficult to resume and almost impossible to audit.

Loading diagram…

  1. Receive a request with a stable workflow identifier.
  2. Load an existing checkpoint or create initial workflow state.
  3. Plan or resume the next pending step.
  4. Evaluate the proposed action against identity and policy.
  5. If approval is required, checkpoint the action and pause.
  6. After approval, revalidate authority before continuing.
  7. Execute the tool with an idempotency key and timeout.
  8. Retry transient failures within a bounded policy.
  9. Escalate denied, expired, or repeatedly failing work.
  10. Checkpoint the successful result and continue until complete.
A durable workflow can pause and recover. Every wait and external effect becomes an explicit state. Checkpoints—not conversational memory—allow safe resumption.
  • Checkpoint after meaningful transitions. Persist the plan, completed steps, tool results, pending approval, and the next valid actions.
  • Assume duplicate delivery. Queues and webhooks may deliver an event more than once. Use stable workflow and action identifiers so retries do not duplicate external effects.
  • Bound every wait. Tool calls, approval requests, and callbacks need timeouts with an explicit expiry path.
  • Separate retry from repair. Retry transient failures with limits and backoff. Route invalid input, denied access, and repeated failures to a corrective or human path.

06Governed action

Policy should follow the risk of the action

Rules are best treated as a cross-cutting control plane rather than one prompt or one box between context and the agent. Validate input before planning, enforce permissions during retrieval, constrain tools before execution, and validate output before an external effect.

Loading diagram…

  1. The agent proposes a typed action but does not execute it directly.
  2. The policy gate evaluates caller authority, target, data sensitivity, blast radius, evidence, and reversibility.
  3. A read action may proceed after permission and data-scope checks.
  4. A draft action may proceed after output validation because it has no external effect.
  5. A reversible write requires stronger validation and may need approval above a risk threshold.
  6. An irreversible or high-impact action requires explicit approval or is blocked.
  7. Every decision and resulting action is recorded in the audit trail.
Autonomy follows action risk. The same model output can receive a different decision when the caller, target, evidence, or reversibility changes.

Risk is not a property of the model alone. It depends on the caller, target system, data sensitivity, blast radius, reversibility, and evidence available for the decision. OWASP describes excessive agency as a risk when an LLM system receives unnecessary functionality, permissions, or autonomy.

07Control

Human approval is a workflow state

Human-in-the-loop should not appear only after the system has failed. It should be designed into the workflow wherever judgment, accountability, or irreversible impact requires a person.

  • Give the reviewer context. Show the proposed action, supporting evidence, target, expected effect, and what will happen after approval.
  • Make approval specific. Approval for one email or deployment must not become open-ended permission for later actions.
  • Support correction. Reviewers should be able to edit, reject, or request more evidence—not merely click approve.
  • Handle silence. Define expiry, reminders, reassignment, and cancellation when nobody responds.

The goal is not to make every action slow. Low-risk reads and drafts may proceed automatically. Higher-risk writes should require progressively stronger validation or approval.

08The control plane

Observe the workflow and evaluate the outcome

Traditional observability asks whether the system is available. Agent systems must also answer whether the work was useful, grounded, authorised, and completed. That requires connecting infrastructure telemetry with workflow and quality signals.

  • Trace causality. Correlate the user request, workflow, model calls, retrieval, tool calls, retries, approvals, and external changes under stable identifiers.
  • Protect recorded content. Prompts, tool arguments, and results may contain secrets or personal data. Default to metadata and sampled, redacted content rather than indiscriminate logging.
  • Measure system quality. Track task completion, tool success, policy denials, escalation, correction, abandonment, latency, and cost by workflow step.
  • Evaluate with real tasks. Maintain representative cases and adversarial scenarios. Score the final business outcome as well as intermediate model output.

OpenTelemetry’s semantic conventions provide a common vocabulary for traces, metrics, logs, and events. Its Generative AI conventions are still evolving, so pin the convention version and treat model or tool content as sensitive.

09Implementation sketch

A vendor-neutral orchestration blueprint

The exact framework matters less than the contracts between planning, policy, state, and effect. The following sketch keeps those responsibilities visible.

def run_workflow(workflow_id: str, request: WorkRequest) -> Result:
    state = state_store.load_or_create(
        workflow_id=workflow_id,
        requested_by=request.principal_id,
        objective=request.objective,
    )

    principal = identity.resolve_and_revalidate(state.requested_by)
    plan = planner.create_or_resume(state, request.context)

    for step in plan.pending_steps():
        action = agent.propose(step=step, context=state.safe_context())
        decision = policy.evaluate(
            principal=principal,
            action=action,
            evidence=state.evidence,
        )

        audit.record(workflow_id, action, decision)

        if decision.requires_approval:
            state.checkpoint(status="awaiting_approval", action=action)
            return approvals.request(workflow_id, action, decision.reason)

        if not decision.allowed:
            return state.finish(status="denied", reason=decision.reason)

        result = tools.execute(
            action,
            principal=principal,
            idempotency_key=f"{workflow_id}:{step.id}",
            timeout=step.timeout,
            retry_policy=step.retry_policy,
        )

        state.checkpoint(
            status="step_completed",
            step=step,
            result=result.redacted(),
        )

    return state.finish(status="completed")
What this sketch deliberately keeps outside the model

Identity revalidation, policy decisions, idempotency, timeouts, retry limits, audit recording, and state transitions remain deterministic application responsibilities. The model proposes work within those boundaries; it does not redefine them at runtime.

10Before launch

A production readiness checklist

  1. Map every external effect. Identify the target, required authority, reversibility, blast radius, and approval rule.
  2. Make tool contracts explicit. Validate structured inputs and outputs, distinguish retryable errors, and assign idempotency semantics.
  3. Model the workflow states. Include waiting, denied, expired, cancelled, failed, compensated, and completed—not just running and done.
  4. Test permissions end to end. Verify connector reads, retrieval, prompts, logs, tool calls, and resumed workflows with multiple roles and revoked access.
  5. Exercise failure paths. Simulate timeouts, duplicate events, partial tool success, stale approvals, malformed model output, and unavailable dependencies.
  6. Define the human interface. Reviewers need evidence, scope, editable proposals, expiry, and an audit trail.
  7. Instrument business outcomes. Connect traces and costs to completion, correction, escalation, and user value.
  8. Increase autonomy gradually. Promote workflows only after measured performance and operational review justify a wider action boundary.

11Working vocabulary

Glossary

Agent
A model-driven component that selects or proposes actions toward a bounded objective using an allowed set of tools.
Orchestrator
The component that coordinates workflow transitions, routing, timeouts, retries, and completion.
Durable execution
Persisting workflow progress so work can pause, resume, and recover across process or dependency failures.
Idempotency key
A stable identifier that lets a tool recognise repeated attempts at the same intended effect and avoid duplication.
Compensation
A deliberate action that mitigates or reverses a previously completed workflow step when later work fails.
Least privilege
Granting only the resources and actions required for the current user, tool, and task.
Human-in-the-loop
A workflow state in which a person reviews, edits, approves, rejects, or redirects proposed work.
Control plane
The policies, configuration, evaluation, audit, and observability used to govern and operate agent workflows.

12Sources and further reading

References

  1. The Real Architecture Behind Production AI Agents

    Abhishek Choudhury

    Original article, published May 2026.
  2. RFC 9700: Best Current Practice for OAuth 2.0 Security

    IETF

    Current guidance for token security and privilege restriction.
  3. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile

    National Institute of Standards and Technology

    A cross-sector profile for identifying and managing generative-AI risk.
  4. OWASP Top 10 for Agentic Applications

    OWASP GenAI Security Project

    Agent-specific risks and mitigation guidance.
  5. OpenTelemetry semantic conventions

    OpenTelemetry

    A shared vocabulary for tracing, metrics, logs, and events.
  6. Retrieval-Augmented Generation (RAG 101)

    Abhishek Choudhury

    The companion guide to permission-aware retrieval and context assembly.

From the archive

Keep reading

View all articles