Spatiotemporal Composability for Agent Harnesses: A Practical Guide

    This article explains how agent harnesses can support long-running AI agents through spatiotemporal composability, a framework that separates dynamic changes into two orthogonal dimensions: time and space. It covers the limitations of coarse-grained restarts, the "everything is a plugin" architecture, a four-step method for lossless hot updates, fine-grained dependency management and isolation, and an evaluation checklist with common anti-patterns. Readers will learn the core infrastructure needed to make runtime changes transactional, reversible, and precisely scoped without losing session state.

    1. The Problem: New Constraints from Long-Running Agents

    Early agent invocations were mostly linear flows of “single-turn prompt plus tool calls.” Processes were short-lived, and state rarely persisted across turns. But when tasks require execution over tens of minutes or even hours, coordination across multiple tools, and self-correction while running, the agent harness stops being glue code and becomes a runtime foundation. It must satisfy three demands that pull against each other:

    • Dynamic extensibility: generate, load, or unload external capabilities and third-party services on demand, with the tool set evolving as the task evolves.
    • Self-modification and lossless hot updates: when an agent writes code to extend capabilities or fix tool defects, updates must take effect in place without interrupting the session or discarding accumulated memory and connection caches.
    • Fault tolerance and transactional rollback: model-generated code may contain syntax errors or logic flaws, so the system needs database-like atomicity to prevent a single failure from bringing down the entire host process.

    Common industry approaches—plugin systems in AI coding tools, container orchestration platforms, and process-level isolation—mostly fall back on coarse-grained restarts: updating one capability means restarting the process or container. The cost is lost in-memory sessions, high cold-start latency, and the inability to express fine-grained topology dependencies within the same address space. This is exactly what spatiotemporal composability addresses.

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

    Orthogonal decomposition of a complex problem is the prerequisite for making it provable and engineerable. Spatiotemporal composability splits the dynamic composition challenge into two non-interfering dimensions:

    The temporal dimension focuses on “when changes happen and how they take effect.” It centers on three things: locating the change point (which capability unit is changing), transactionality of the change (all-or-nothing), and reversibility (keeping snapshots to support rollback). In engineering terms, this usually means versioned handles and copy-on-write, so read and write paths see a consistent view at any given moment.

    The spatial dimension focuses on “who depends on whom, and where the boundaries are.” It centers on splitting the system into addressable capability units and explicitly declaring the dependency topology, so unloading one unit allows precise calculation of the affected set instead of a blunt global restart.

    The value of orthogonality is that hot updates do not need to change the dependency topology, and adding or removing plugins does not need to touch time semantics. An implementation can borrow from dependency injection containers plus a meta-framework, using a unified registration and resolution layer to carry both.

    3. Architectural Paradigm: The Benefits and Costs of “Everything Is a Plugin”

    The “everything is a plugin” philosophy shrinks the host kernel to a minimal, stable core, with all other capabilities (tools, memory, policies, connectors) turned into plugins. The benefits are obvious: capabilities become addressable, lifecycles become manageable, and dependencies become statically analyzable. The costs are equally real: longer call chains add overhead, and poorly designed contracts between plugins create implicit coupling.

    Three disciplines are therefore essential in practice:

    1. Keep the kernel minimal: retain only four primitives—registration, resolution, lifecycle, and transactions—and keep business logic out of the kernel.
    2. Make contracts explicit: each plugin declares its input/output schema, resource usage, and concurrency behavior; implicit communication through shared mutable global state is prohibited.
    3. Keep dependencies acyclic: perform topological sorting and cycle detection at load time, treating circular dependencies as load failures rather than runtime warnings.

    An illustrative plugin declaration (pseudocode, expressing only the contract idea):

    1. plugin Tool.A {
    2. version: "1.4.0"
    3. provides: { schema, invoke }
    4. requires: [ Memory.Read, Net.Http ]
    5. transactional: true
    6. snapshot: copy_on_write
    7. }

    4. Temporal Dimension in Practice: A Four-Step Method for Lossless Hot Updates

    The difficulty of lossless hot updates is not “replacing code” but “not breaking in-flight state during replacement.” It can be broken into four steps:

    • Preflight: verify contract compatibility of the new version (backward-compatible schema, no new dependency conflicts).
    • Shadow loading: load the new version in a side path and complete dependency resolution without affecting the active instance.
    • State migration: take copy-on-write snapshots of in-flight sessions and adapt mutable state to the new version; state that cannot be migrated automatically enters a draining queue.
    • Atomic switch and drain: switch routing to the new version, put the old version into a draining period to handle in-flight requests before unloading; if any step fails, roll back entirely to the pre-switch view.

    The key to transaction-level rollback is the concept of a “change set”: a hot update is treated as one transaction containing three types of operations—loading, migration, and switching—combined with snapshots and compensating actions to achieve all-or-nothing. For model-generated code, it is recommended to perform static checks and resource quota limits at load time, shifting risk left.

    5. Spatial Dimension in Practice: Fine-Grained Dependencies and Isolation

    The engineering focus of the spatial dimension is making “unloading” a computable operation. This includes building a reverse dependency index for each capability unit, computing the affected set before unloading, and using reference counting or lease mechanisms for shared resources to avoid dangling references. Isolation levels can be chosen in increasing order of risk: module isolation within the same address space, work-unit-level isolation, and process-level isolation. The higher the risk of autonomously generated code, the higher the isolation level should be, with message passing replacing shared memory.

    6. Evaluation Checklist and Common Anti-Patterns

    To evaluate whether a harness has spatiotemporal composability, use this checklist:

    • Can it replace capabilities without a restart and with zero session state loss?
    • Does it provide change-set-level transactions and rollback?
    • Does it complete dependency cycle detection and contract validation at load time?
    • Does it provide a reverse dependency index to support precise unloading?
    • Does it impose quotas and isolation on autonomously generated code?

    Common anti-patterns include: putting business logic into the kernel, using global mutable state for plugin communication, using “restart as fallback” to mask unclear dependencies, and performing hot updates without snapshots, making rollback impossible.

    7. Conclusion

    Spatiotemporal composability turns “dynamic and self-evolving” from an engineering slogan into a provable programming paradigm: the temporal dimension guarantees transactionality and reversibility of changes, while the spatial dimension guarantees explicit and computable dependencies. For teams building long-running agents, prioritizing three pieces of infrastructure—contracts, snapshots, and dependency indexes—can significantly improve runtime stability and evolution speed. To host plugin artifacts, session snapshots, and runtime logs, teams can use general cloud capabilities such as object storage, message queues, container platforms, and log monitoring, without binding to any specific proprietary interface.