Self-Evolving Agent Architecture: A Plugin-Based Approach to Spatiotemporal Composability

    This article breaks down how self-evolving AI agents can be built on a plugin-based harness, using spatiotemporal composability as the design principle. It explains the three hard requirements long-running agents place on the host framework, how time and space dimensions are separated for independent verification, and what "everything is a plugin" means in practice. Key capabilities such as dynamic loading, lossless hot updates, and transactional rollback are covered, along with a reference architecture on Baidu AI Cloud and a five-question checklist for evaluating an agent harness.

    1. Background: New Requirements That Long-Running Agents Place on the Host Framework

    Early agent systems mostly stopped at the “single-turn prompt call” stage: receive one input, call the model once, and return one result. As task complexity grows, agents are now expected to handle long-running execution, multi-tool coordination, and self-improvement. The host framework (the Agent Harness) has shifted from an optional shell to the critical infrastructure that determines the system’s upper bound.

    Specifically, long-running agents impose three hard requirements on the host layer.

    Dynamic extensibility and plug-and-play tools. Agents need to generate, load, or unload external tools and third-party services on demand based on the current subtask. The toolset is no longer a static collection fixed at compile time, but a topology that keeps changing at runtime.

    Self-modification with lossless hot updates. During long-running sessions, an agent may write code on its own to extend capabilities or fix tool defects. Such updates must take effect in place without interrupting the current session or losing accumulated context and connection caches. Otherwise, “self-evolution” is just an expensive restart.

    Fault tolerance and transactional rollback. Model-generated code can naturally contain syntax errors and logic exceptions, so the host must provide database-like atomicity guarantees: either a change takes effect in full, or it is withdrawn in full, preventing a single point of failure from bringing down the whole process.

    Common industry approaches (such as editor plugin systems, container orchestration, and process-level isolation) mostly rely on a “coarse-grained restart” workaround: updating one component means restarting the entire process or container. The cost is lost session memory, high startup latency, and the inability to express fine-grained dependencies within the same address space. This is the gap that a new programming paradigm needs to fill.

    2. Theoretical Foundation: Splitting Dynamic Composition into Two Orthogonal Dimensions

    Taking “spatiotemporal composability” as the formal goal, the core idea is to decompose the dynamic composition problem into two dimensions that do not interfere with each other.

    The time dimension focuses on “when things can change”: at which stages of the lifecycle components may be replaced, extended, or withdrawn, how changes take effect atomically, and how to return to a consistent state before the change when a failure occurs.

    The space dimension focuses on “how things are composed structurally”: how dependencies, scopes, and visibility between components are expressed, whether plugins can be nested, isolated, and assembled on demand, and how to avoid mutual contamination within the same address space.

    The benefit of keeping the two dimensions orthogonal is that implementation and verification can be decoupled: the correctness of the spatial topology can be proven independently, and the change atomicity of the time dimension can also be proven independently, while the combination of the two remains reason-able. Compared with implicit coupling designs where “changing one place requires touching everything,” this split gives complex systems provable and testable engineering properties.

    3. Architecture Philosophy: What “Everything Is a Plugin” Means in Engineering

    “Everything is a plugin” is not a marketing slogan but an actionable constraint: the host provides only minimal kernel capabilities (lifecycle management, dependency resolution, event bus, state snapshots), while all other capabilities exist as plugins, including tool invocation, memory management, logging, access control, and even the scheduling policy itself.

    This design brings three direct benefits:

    • Replaceability: any capability can be replaced by an implementation with the same contract, making canary releases and rollbacks easy.
    • Composability: complex behavior is assembled from small plugins, avoiding monolithic implementations.
    • Observability: unified plugin boundaries naturally form a cross-cutting surface for instrumentation and tracing.

    A schematic plugin contract can be abstracted as follows (a general illustration only, not a specific product interface):

    1. class Plugin:
    2. name: str
    3. version: str
    4. def on_load(self, ctx): ... # Wire up dependencies and register capabilities
    5. def on_unload(self, ctx): ... # Release resources and clean up references
    6. def snapshot(self) -> State: ... # Produce a rollback-able state snapshot

    4. Breakdown of Key Capabilities

    4.1 Dynamic Extensibility

    Tools are assembled at runtime according to the task graph, following the principles of least privilege and on-demand loading. It is recommended to declare resource quotas and timeouts for each plugin to prevent a single tool from dragging down overall latency.

    4.2 Lossless Hot Updates

    The update flow can be abstracted as “take a snapshot, assemble the new version, dual-write and verify, switch references, release the old version.” Session context and connection pools are managed by the kernel and are not destroyed when a plugin is unloaded, avoiding context loss and cold starts.

    4.3 Transactional Rollback

    Treat a change as a transaction: preflight (syntax and contract validation), staging, commit, and rollback on failure. Rollback granularity should be refined down to plugins and dependency edges, rather than a full process restart.

    1. Transaction flow: Preflight -> Stage -> Commit -> (Fail) Rollback

    5. Implementation Recommendations on Baidu AI Cloud

    Mapping this paradigm onto general cloud capabilities yields an operable reference architecture:

    • The compute layer uses a container platform to host the stateless kernel and plugin runtime, with elastic scaling to handle fluctuating workloads.
    • The state layer uses object storage to hold plugin packages and versions, and a message queue to decouple long-running tasks from event notifications.
    • The observability layer uses log services and monitoring alerts to collect plugin-level metrics in a unified way, forming a change-audit trail.
    • The governance layer uses a unified identity and access management system to constrain the resource access boundaries of plugins.

    In engineering practice, it is recommended to stick to three bottom lines: changes can be canaried, state can be snapshotted, and failures can be rolled back automatically.

    6. Evaluation Checklist and Conclusion

    To judge whether an agent harness truly has “self-evolution” capability, five questions can be used for self-checking: does it support runtime assembly and unloading; do updates keep sessions and caches lossless; can failures be rolled back atomically; can the dependency topology be reasoned about statically; and do plugin boundaries have unified observability.

    The value of “spatiotemporal composability” is to elevate dynamism from an “ops trick” to a “provable engineering constraint.” For developers building long-running agents on Baidu AI Cloud, this means lower change risk, clearer module boundaries, and a more sustainable evolution path.