Agent Layered Architecture: A Practical Guide to Thin Frameworks and Thick Plugins

    This article explains how to build an AI agent using a layered architecture based on a thin runtime framework and thick, replaceable plugins. It covers the core responsibilities of the framework, the four capability layers (model, tools and data, memory, and sandbox), and key mechanisms such as human approval gates and task plans. It also outlines a step-by-step path for implementation, helping teams keep agents maintainable as models and tools evolve.

    1. The Starting Point: Why Agents Need a Thin Framework and Thick Plugins

    A conclusion that keeps proving itself in agent engineering is this: Agent = Model + Harness. The model handles understanding, reasoning, and generation, while the harness (the runtime framework) organizes the model’s capabilities into workflows that are executable, controllable, and continuous. A common mistake many teams make at the beginning is hardcoding large amounts of business logic into the framework itself. The result is a framework that becomes increasingly bloated, requiring major changes whenever the model is upgraded or a tool is replaced, and eventually losing maintainability.

    A more reasonable approach is to keep the framework as thin as possible. A mature runtime framework takes on only three responsibilities:

    1. Scheduling models and tools: Breaking user intent into model calls and tool calls, and managing the context flow between them.
    2. Requesting human approval before high-risk actions: Setting confirmation gates for irreversible actions or actions with a large impact.
    3. Maintaining a task plan: Giving long-running tasks a goal, steps, and state so they can be resumed and audited.

    Everything else—models, retrieval, data, memory, sandboxes, and execution environments—should be built as composable, replaceable, and extensible plugins. The framework only defines slots and contracts, while plugins handle the specific implementations. This way, capability upgrades no longer affect the core, and replacement costs are kept to a minimum.

    2. Layered Design: Separating Execution, Memory, Growth, and Delivery

    A truly usable agent requires four types of capabilities to be in place at the same time. Separating them makes the architecture much clearer.

    2.1 The Brain: Multimodal Model Capabilities

    The model layer should support multimodal capabilities such as text generation, image generation, video generation, and embedding, all accessed through a unified “custom provider” approach. The key design principle is interface abstraction: the framework recognizes only one calling contract, while the underlying model and version are determined by configuration rather than code.

    An illustrative configuration structure (pseudocode):

    1. model_provider:
    2. type: custom
    3. api_key_ref: env://AGENT_API_KEY
    4. capabilities: [text, image, video, embedding]
    5. routing:
    6. chat: default
    7. embedding: default

    The benefit of this approach is that models can be switched on the fly without changing business code, making it easier to run canary releases, optimize costs, and compare results.

    2.2 The Hands and Feet: Tool and Data Integration

    The tool layer addresses the contradiction that “a model’s knowledge has a cutoff date, but tasks do not.” It includes at least two types:

    • Web retrieval capabilities: Allowing the agent to retrieve the latest facts, verify sources, and support filtering by authoritative sources, time ranges, and automatic query rewriting.
    • Specialized datasets: Structured data that general retrieval cannot obtain, such as financial reports of public companies, business registration information, judicial risk records, academic papers, vehicle configurations, and macroeconomic indicators. The system automatically routes to the appropriate vertical database based on query semantics and returns structured results.

    The key design point here is a unified tool contract plus automatic routing: the upper-level model does not need to know where the data comes from and only needs to issue a query, while the routing layer selects the data source, performs permission checks, and normalizes results.

    2.3 Memory: A Cross-Session Context Database

    The memory layer is best built on the idea of a “virtual file system plus semantic retrieval”: memories, resources, and skills are all abstracted as files, loaded in layers and recalled on demand, with long-term memory automatically consolidated after a session ends. This avoids unlimited context growth and makes “growth” an observable process.

    2.4 Sandbox and Execution Environment

    All tool calls and code execution should take place in a controlled sandbox, combined with resource limits, network policies, and audit logging, to ensure the agent can get work done without overstepping boundaries.

    3. Key Mechanisms: Approval Gates and Task Plans

    3.1 High-Risk Action Approval

    The framework should establish clear rules for action classification: read operations can be executed directly; write operations depend on their impact; irreversible actions such as deletion, transfers, external publishing, and permission changes require human confirmation. Approval information should include the target, parameters, impact scope, and rollback plan.

    1. [Approval Request] action=delete_resource
    2. target=prod-bucket-07
    3. impact=irreversible
    4. rollback=not_available
    5. require=human_approval

    3.2 Task Plan Maintenance

    Long-running tasks need an explicit plan: goal, steps, current state, dependencies, and artifacts. A plan offers three benefits: it is resumable (execution can continue after an interruption), auditable (every step is recorded), and collaborative (humans and agents see the same state). It is recommended to separate the plan from the execution log: the plan manages “what to do,” while the log manages “what was done.”

    1. Build the thin framework first, implementing only scheduling, approval, and planning.
    2. Define plugin contracts: four types of slots for models, tools, memory, and sandboxes.
    3. Connect models and retrieval to get a minimal loop running.
    4. Add specialized datasets and memory consolidation to improve task completion rates.
    5. Complete monitoring, alerting, logging services, and cost dashboards to enter sustainable operations.

    5. Conclusion

    The core of agent engineering is not piling on features, but making the volatile parts pluggable and the stable parts part of the framework. When the framework is thin enough and the plugins are well-defined, teams can replace models, extend tools, and consolidate memory at a lower cost, enabling agents to truly get work done, remember things, and grow.