Designing a Pluggable Coding Agent Foundation: Architecture, Session Replay, and Plugin Lifecycle

    This article explains why the initial hype around new coding agent frameworks fades quickly and argues that a coding agent foundation should be evaluated by four criteria: replaceable loops, replayable and branchable session logs, plugin-based capabilities, and a business-logic-free kernel. It compares four technical routes, recommends a layered directory structure with clear responsibility boundaries, and shows how a meta-framework handles plugin lifecycle and dependency resolution. It also covers append-only session logs for replay, branching, and resume, loop plugin replacement through configuration, and a practical selection checklist with observability and cost-control recommendations.

    1. The Problem: Why the Hype Around a Foundation Cools Down Fast

    Whenever a new coding agent framework appears, community discussion often peaks within a few days and then quickly fades. A drop in hype does not mean the technical approach lacks value. It usually means most discussions stay at the level of “can it run the demo,” without answering the questions that matter for real engineering adoption: Can the core execution logic be modified? Can session state be replayed? Can capabilities be swapped on demand? Does secondary development require forking the entire project?

    So a coding agent foundation should not be judged by its demo. It should be judged on four dimensions: whether the loop is replaceable, whether session logs can be replayed and branched, whether capabilities are plugin-based, and whether the kernel contains zero business logic.

    2. An Abstract Comparison of Four Technical Routes

    1. Out-of-the-box finished tools: The core loop is built in and fixed, and extension points are concentrated in hooks and external protocol integrations. The advantage is a fast start; the drawback is that changing core logic requires modifying the source code.
    2. Open-source ready-to-use tools: The main loop is fixed, while the sandbox and tools are extensible. Secondary development requires substantial changes. Sessions can be replayed, but components are hard to replace dynamically.
    3. Workflow state runtimes: These focus on state transitions and node orchestration and provide state-persistence checkpoints. They do not include coding capabilities, so you must connect models and tools yourself.
    4. Fully plugin-based, composable foundations: The loop itself is also a plugin, and the session log is an append-only structure that supports replay, branching, and resume from a breakpoint. Replacing a capability only requires a configuration change.

    The conclusion is straightforward: the first two are “finished products,” while the latter two are “chassis.” When you need to change the most core execution logic, the chassis route does not require forking the project.

    1. project/
    2. ├── apps/ # Product entry points: web and CLI
    3. ├── core/ # Sessions, agent loop, tool registry, prompt assembly
    4. ├── boot/ # Kernel startup, config loading, plugin resolution
    5. ├── llm/ # Model adapter layer for compatible interfaces
    6. ├── plugins/ # Files, command sandbox, sub-agents, approval, persistence
    7. ├── vendor/ # Built-in meta-framework source code
    8. ├── examples/ # Config samples and plugin development examples
    9. ├── docs/ # Architecture and plugin development docs
    10. └── sdk/ # Multi-language development packages
    • core: The center of business logic. It defines sessions, single turns and single steps, tool registration, and system prompt assembly.
    • boot and the built-in meta-framework: Responsible only for plugin lifecycle, dependency management, and event dispatch, with no business logic.
    • llm: Uniformly wraps model calls. Adding a model only requires writing an adapter plugin, with no changes to upper layers.
    • Feature plugins: Command execution, file read/write, sandbox isolation, sub-agents, and log persistence can be toggled on demand.

    4. The Meta-Framework Only Schedules: Plugin Lifecycle and Dependency Resolution

    The meta-framework that supports the foundation is not a business library but a plugin scheduler. It handles four things: mounting and unmounting, dependency resolution, event dispatch, and automatic resource cleanup. Example code:

    1. // A plugin declares dependencies and lifecycle
    2. export default definePlugin({
    3. name: 'file-tools',
    4. deps: ['sandbox', 'approval'],
    5. setup(ctx) {
    6. ctx.on('tool:call', async (req) => {
    7. if (!(await ctx.approval.check(req))) return req.deny('Unauthorized');
    8. return ctx.sandbox.run(req);
    9. });
    10. // Release handles, timers, and listeners automatically on dispose
    11. ctx.onDispose(() => ctx.cleanup());
    12. },
    13. });

    The key point is that when a dependency is missing, the kernel should refuse to mount the plugin and give a clear reason, rather than failing randomly at runtime. On unmount, resources must be reclaimed automatically to avoid handle leaks in long sessions.

    5. Session Logs: Replay, Branching, and Resume from an Append-Only Structure

    If session records depend on memory, they are lost when the process ends, and replay capability is limited. A composable foundation uses an append-only log where each record is only appended and never modified, which naturally provides three capabilities:

    • Replay: Replaying the log in order reproduces the complete reasoning and tool-call trace.
    • Branching: Deriving a new branch from any record position to compare different prompts or different loop strategies.
    • Resume: Recording the last completed step number and tool result, then continuing from the interruption after a restart.
    1. [turn-1] user -> prompt
    2. [turn-1][step-1] model -> tool_call(read_file)
    3. [turn-1][step-1] tool -> content
    4. [turn-1][step-2] model -> final

    Engineering practice also needs to account for log redaction, size limits, and archival policies. Object storage and log services can be combined to tier hot and cold data.

    6. Loop Pluginization: Turning “Think-Call-Observe” into Replaceable Components

    A fixed loop makes it hard to customize scenarios such as retry on failure, parallel tool calls, and budget control. After abstracting the loop into a plugin, you can replace only that plugin without touching other capabilities:

    1. // Replace the execution loop strategy with configuration
    2. export const config = {
    3. loop: 'plugins/loop-parallel-v2',
    4. tools: ['file', 'shell', 'subagent'],
    5. llm: 'adapters/compatible-api',
    6. };

    Common replaceable strategies include serial conservative, parallel accelerated, budget-constrained, and plan-then-execute. Because prompt assembly and tool registration are defined uniformly in core, replacing the loop does not break context consistency.

    7. Adoption Advice and a Selection Checklist

    • If you want the fastest launch and do not need to change core logic: choose a finished tool and extend it with hooks and external protocols.
    • If you need state persistence and process orchestration but will build coding capabilities yourself: choose a workflow runtime.
    • If you need long-term evolution and frequent adjustments to execution strategies: choose a fully plugin-based chassis.
    • Regardless of the route, you should add these early: session log persistence, permission approval, sandbox isolation, observability, and cost control.

    For observability, it is recommended to collect call chains, token consumption, and tool success rates in a unified way, and to use monitoring alerts and container platforms to support elastic execution environments. Overall, hype will pass, but the design principles of layered architecture and replayable state will remain. This is also the core standard for judging whether an agent foundation is worth a long-term investment.