Agent Framework Architecture: A Breakdown of Four Design Patterns

    This article breaks down the architecture of four common AI Agent framework types: minimal-kernel, shared-service, memory-evolution, and omni-channel. It explains the model-versus-harness split, maps the minimal harness loop, and shows how each framework makes different trade-offs across context assembly, tool execution, state storage, and entry points. A four-dimension selection method and a production-readiness checklist are included to help you choose and operate an Agent framework.

    1. Why the Same Model Grows into Four Different Agents

    A large language model is essentially a machine that takes text in and puts text out: it reads tokens and emits tokens. It is stateless by itself. It does not remember what happened in the previous turn, and it will not proactively read files, query databases, or call external APIs. To make it actually do work, you need to wrap a runtime around the model, commonly referred to in the industry as a harness. A horse needs a harness to pull a cart, and a model needs a harness to complete tasks.

    As a result, an Agent can be split into two layers:

    • Model layer: weights and reasoning capability, which set the upper bound;
    • Harness layer: prompt assembly, tool registration and execution, session persistence, permissions and guardrails, channel adaptation, and more, which set the lower bound and determine usability.

    The key takeaway is that the harness affects the final result as much as the model does, and in some scenarios even more. The four typical framework types each place their design focus in a different direction: a minimal kernel, shared services, memory accumulation, and channel breadth. They all update quickly, so the analysis below is deliberately fixed on a specific version snapshot for static reading. When you evaluate them for your own selection, you should also lock the version first before reading the source code.

    2. Start with the Skeleton: The Minimal Loop of a Harness

    No matter how complex it gets, the main loop of a harness can be abstracted into the following pseudocode. The differences among the four framework types are essentially additions and subtractions across these stages.

    1. while not done:
    2. ctx = build_context(system_prompt, memory, history, tools_schema)
    3. out = model.generate(ctx) # text in, text out
    4. if out.tool_calls:
    5. results = [execute(tc) for tc in out.tool_calls] # side effects happen here
    6. history.extend(tool_results)
    7. else:
    8. done = True # converge to a natural-language reply

    Four points of modification are clear: how context is assembled (memory and retrieval), how tools are executed (sandbox and permissions), where state is stored (sessions and sharing), and where the entry point is (terminal, multiple clients, or chat channels). The four framework types each go deep on one of these points.

    3. Type One: Minimal-Kernel — Stripping the Harness Down to the Bone

    Implementations of this type are usually only a few hundred lines of code and are common in teaching scenarios, because they must fit within the length of a book. Their value lies not in the number of features but in exposing the “minimum viable loop” at a glance: one main loop, one tool table, and one assembled system prompt.

    Suitable scenarios are learning the principles, serving as a baseline for comparison, and getting the pipeline running on constrained devices. Its shortcomings are equally obvious: no multi-session isolation, no fine-grained permissions, and no memory mechanism. Once concurrency ramps up, you have to fill these gaps yourself.

    Practical advice: treat the minimal kernel as a “reference implementation” and use it to verify whether your prompts and tool descriptions are clear enough. If the model fails to call the right tool when switched to the minimal kernel, the problem most likely lies in the tool descriptions rather than the framework.

    4. Type Two: Shared-Service — One Server, Multiple Clients

    The second type splits the harness into a “server + clients.” The server runs persistently and holds session state, the tool registry, and the execution sandbox. Clients can be a terminal, an editor plugin, or a custom interface, and are only responsible for rendering and input.

    The benefit of this architecture is resource reuse and a consistent experience: the same context and skill configuration are shared across multiple entry points, avoiding a separate copy of state in each client. The cost is that you must directly handle concurrency and isolation.

    Key design points to focus on:

    • Session isolation: partition context by session ID to avoid cross-talk;
    • Concurrency control: serialize tool calls within the same session to prevent write conflicts;
    • State consistency: after reconnection, be able to restore history and pending actions;
    • Permission boundaries: the server validates centrally, and clients cannot bypass it.

    A schematic interface layering is as follows (it only expresses the layering idea and is not the interface of any specific product):

    1. client --(render/input)--> gateway --(auth/rate limit)--> session_manager
    2. |
    3. +-------------+-------------+
    4. tool_runtime memory_store audit_log

    5. Type Three: Memory-Evolution — Writing Learned Skills Back into Memory

    The core proposition of the third type is that an Agent should become more comfortable to use over time. It distills “successful experience” into reusable skill entries and retrieves them in later tasks to inject into the context, forming a loop of “try — summarize — write back — reuse.”

    A practical memory layering scheme:

    1. Working memory: the current session history, which decays when the session ends;
    2. Episodic memory: task-level summaries recording what was done and how it turned out;
    3. Semantic memory: domain knowledge and key points on tool usage;
    4. Skill memory: executable step templates with preconditions and lessons from failures.

    The write-back stage must guard against three things: first, contamination, where wrong experience is reused repeatedly; second, bloat, where too many entries cause retrieval noise; and third, privacy, where sensitive data is written into long-term storage. A common engineering practice is to add confidence scores and hit statistics to memory entries, periodically evict low-confidence entries, and desensitize and minimize the content written in.

    6. Type Four: Omni-Channel — Extending the Entry Point to Dozens of Chat Channels

    The fourth type puts its effort into the “last mile”: adapting to a large number of chat and collaboration channels so the Agent appears where users are already accustomed to being. The difficulty lies not in the model but in channel differences: message formats, rich-text capabilities, authentication methods, callback signature verification, rate limits, idempotency, and deduplication all differ.

    Therefore, this type of framework usually needs a unified message abstraction layer that converges each channel into a three-stage flow of “inbound event → unified intent → outbound reply,” with a separate adapter implemented for each channel. Engineering must handle duplicate replies caused by repeated delivery, chunking and ordering of long replies, and backoff retries caused by channel-side rate limiting.

    7. A Four-Dimension Selection Method: Turning “Which One to Choose” into a Computable Problem

    Do not ask “which framework is the best.” Instead, score along four dimensions:

    • Interaction form: a single terminal, multiple clients sharing, or extending to mass-market chat channels;
    • State strategy: stateless, session-level, or long-term memory across sessions;
    • Tools and permissions: the number of tools, whether a sandbox is needed, and whether audit trails are required;
    • Operational cost: deployment complexity, observability, upgrade frequency, and version-locking strategy.

    A simple scoring table template:

    Dimension Weight Candidate A Candidate B
    Interaction form fit 0.3
    Memory and retrieval needs 0.25
    Permissions and audit 0.25
    Operations and upgrade cost 0.2

    8. Production Checklist: Six Things to Complete Regardless of Which Type You Choose

    1. Observability: link each model call, tool call, token consumption, and latency into a single trace, and collect logs and metrics uniformly into the logging service and the monitoring and alerting system;
    2. Security guardrails: detect prompt injection on the input side, intercept sensitive information and dangerous actions on the output side, and enforce least privilege and human confirmation on the tool side;
    3. Idempotency and retries: attach an idempotency key to tool calls so that failed external write operations can be safely retried;
    4. Cost control: trim context, replace full injection with retrieval, and cache repeated requests;
    5. Evaluation loop: fix a set of tasks and run a regression whenever either the model or the harness changes;
    6. Version strategy: lock dependency versions and compare against the evaluation set before upgrading to avoid “behavior drift caused by framework updates.”

    9. Conclusion

    The four framework types are not four competitors but four engineering trade-offs for combining “model + harness”: the minimal kernel teaches the principles, shared services solve multi-client consistency, the memory mechanism solves the “better with use” problem, and channel adaptation solves reach. What truly determines success or failure is whether you can make clear trade-offs around interaction form, state strategy, permission auditing, and operational cost, and complete the observability and evaluation loop. When deploying on the cloud, you can reuse a container platform to host the runtime, object storage to persist sessions and skill entries, a message queue to decouple asynchronous tasks, and a logging and monitoring system as a safety net, so that the Agent moves from a demo to stable production.