Why Enterprise AI Agents Need a Layered Architecture

    This article explains why AI agents that work in demos often fail to reach production in enterprises, and how separating runtime execution from application governance solves the problem. It covers the responsibilities of the runtime layer, the capabilities of the governance layer, the limitations of relying on either layer alone, four hard requirements enterprises should set, and practical guidance for deploying a layered architecture.

    1. The Starting Problem: Demos Run, Production Delivery Fails

    Most teams follow a similar curve when validating an AI agent. A prototype can be running in a week or two: connect a model, attach a few tools, write a prompt, and the demo looks great. Once the agent moves into real business use, the problems arrive all at once. Prompts are scattered across personal scripts, updating knowledge requires code changes, there is no way to reconstruct the context after a failure, and business teams that want to adjust a workflow have to queue behind the engineering schedule.

    The root cause is not model capability. It is that enterprises mix runtime capabilities with delivery governance in a single layer. Runtime cares about how an agent executes actions safely. Governance cares about how business users configure, use, audit, and iterate on the agent. Pressing both concerns into the same in-house codebase looks convenient in the short term and inevitably becomes a maintenance black hole over time.

    2. The Two Concerns Must Be Decoupled

    2.1 Runtime Layer: Making the Agent Actually Act

    The core responsibility of the runtime layer is controlled execution. It typically covers four capabilities:

    • Tool invocation and execution: file reads and writes, command execution, API requests;
    • Sandboxing and resource isolation: limiting filesystem scope, network egress, CPU and memory quotas, and execution timeouts;
    • Trace recording and replay: preserving the input, output, tool arguments, and elapsed time of every step;
    • Model access abstraction: hiding differences between models in API protocols, context length, and function-calling formats.

    Illustrative pseudocode for an execution policy:

    1. def run_tool(call, ctx):
    2. assert call.name in ctx.allowed_tools, "tool not allowed"
    3. with sandbox(
    4. workdir=ctx.temp_dir,
    5. net_policy="deny",
    6. timeout_s=30,
    7. memory_mb=512,
    8. ) as box:
    9. result = box.exec(call.name, call.args)
    10. trace.append({
    11. "step": ctx.step, "tool": call.name,
    12. "args": call.args, "output": result, "elapsed": result.elapsed
    13. })
    14. return result

    The criteria for this layer are clear: can it run safely, and can it be fully observed? It is not responsible for business semantics, and it should not own the UI or the permission model.

    2.2 Application and Governance Layer: Making Enterprises Willing to Use It

    The governance layer solves problems for people. Typical capabilities include:

    • Visual orchestration: packaging model and tool capabilities into business nodes by drag and drop, producing conversational or workflow applications;
    • Knowledge base and retrieval augmentation: document upload, chunking, vectorization, and retrieval in one flow, so business users can swap knowledge sources themselves;
    • Multi-model access and switching: choosing models by scenario, cost, or latency without changing business logic;
    • Publishing and integration: exposing capabilities as a conversational application or a standard API;
    • Logs, permissions, and versions: who changed what and when, which document was retrieved, which tool was called, all queryable.

    In one sentence: the runtime makes the agent capable of doing the work, and the governance layer makes enterprises willing to hand the agent to business users.

    3. Where a Single Layer Gets Stuck

    Relying only on runtime capabilities makes the setup too engineering-heavy. Prompts and workflows stay buried in terminals and scripts, so roles such as finance, operations, and internal control cannot participate. The result is that “it runs” does not equal “it can be delivered,” and knowledge disappears when people move on.

    Building the entire application layer in-house instead gets you bogged down in infrastructure: vector storage, document chunking strategies, retrieval and reranking, frontend interaction, authentication, audit logs, canary releases. Each item needs separate design and long-term maintenance, timelines are measured in months, and retrospectives depend on memory.

    Both paths converge on the same conclusion: you need layers.

    4. Four Hard Requirements Enterprises Actually Need

    1. Self-service knowledge updates: business teams upload policy documents and replace the knowledge base on their own, without engineering involvement;
    2. Hot-adjustable prompts and workflows: changing one instruction requires no release and no service restart;
    3. Full-chain traceability: the system can answer which document it read, which tool it called, and why it reached that conclusion;
    4. Controllable data boundaries: private deployment support, with model inference, tool execution, and the application frontend all staying inside the corporate network.

    5. Key Points for Landing a Layered Architecture

    The recommended combination is to use a common model service at the bottom for inference, a controlled runtime in the middle for tool execution and sandboxing, and a low-code orchestration platform on top for business applications and governance. Four points matter during implementation:

    • Keep the orchestration layer as glue only, wrapping the capabilities exposed by the runtime into business nodes, so scenarios such as finance policy Q&A, technical documentation assistants, and expense policy retrieval can produce a prototype in half a day;
    • Reuse the retrieval pipeline out of the box, loading PDFs, Markdown, and policy documents directly, with chunking and retrieval handled by the platform, avoiding a pipeline that only one person understands;
    • Prioritize private deployment, starting services inside the network with one click through containerization, and closing the operations loop with object storage, logging services, and monitoring and alerting;
    • Open runtime logs to business managers, so adjustments change from “file a request and wait for the schedule” to “try it now, change it now.”

    In related practice at Baidu AI Cloud, the same layered approach applies: a general container platform carries the runtime and sandbox, a low-code application orchestration layer carries business and governance, and model capabilities are plugged in flexibly by scenario, moving agents from demo to an auditable, iterable production state at a controlled cost.