Spatiotemporal Composability for Agent Harnesses: A Practical Guide

    This article explores how long-running AI agents require a new type of host runtime, the Agent Harness, and introduces spatiotemporal composability as a framework for managing dynamic change. It breaks the problem into two orthogonal dimensions—time (when changes happen) and space (at what granularity changes happen)—and explains an "everything is a plugin" architecture built on capability contracts, dependency graphs with reference counting, transactional hot updates, and layered isolation. It also covers key mechanisms such as separating state from code, rollback through idempotent side effects, and contract-first dependencies, along with engineering tradeoffs and common pitfalls. Developers will find three immediate actions: define capability-level contracts, attach idempotency keys to external side effects, and make logging and tracing first-class host capabilities.

    1. Why Long-Running Agents Need a New Host Foundation

    Early agent applications mostly stayed at the “single-turn prompt call” stage. Their runtime behaved like a stateless function call: take in context, produce output, and exit. Once agents began handling long-running tasks, coordinating multiple tools, and evolving themselves, those runtime assumptions broke down completely. The Agent Harness is no longer just a shell that loads prompts. It must be a long-lived environment that holds session memory, connection pools, a tool registry, permission context, and execution traces.

    This creates three hard requirements.

    The first is dynamic extensibility. Agents need to generate, load, or unload external tools and third-party services on demand for the current subtask. The tool set changes with each task phase instead of being fixed at startup.

    The second is self-modification with lossless hot updates. During a long task, an agent may write code on its own to fill a capability gap or fix a defective tool. Such changes must take effect in place: without interrupting the current session, discarding accumulated memory, or rebuilding existing connection caches.

    The third is fault tolerance and transactional rollback. Model-generated code carries inherent risks of syntax errors and out-of-bounds logic. The host needs database-like atomicity guarantees that contain failures within the smallest possible scope, so a single failure does not bring down the entire host process.

    Common industry approaches—plugin systems in AI coding tools, microservice governance in container orchestration platforms, and process-level isolation sandboxes—each offer isolation benefits, but they are generally limited by the stopgap of “coarse-grained restart.” Updating one plugin or replacing one service often requires restarting the whole process or container. The cost is lost in-memory sessions, noticeable cold-start latency, and no way to express fine-grained topology dependencies within the same address space. This is exactly the problem spatiotemporal composability aims to solve.

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

    The value of spatiotemporal composability is that it refuses to treat dynamic composition as one vague engineering problem. Instead, it formalizes the problem into two orthogonal dimensions that can be modeled and solved separately.

    The time dimension focuses on “when change is allowed.” It answers: Can a change be safely inserted at any execution point? How are in-flight call stacks handled while the change takes effect? Can the system return precisely to the pre-change state after a failure? This requires the runtime to provide versioned state, transactional change boundaries, and replayable side-effect records.

    The space dimension focuses on “at what granularity change happens.” It answers: Can dependencies be expressed at the function, module, or tool-call level rather than at the process or container level? During partial unloading, how are reference counts and dependency closures computed? This requires the host to maintain a fine-grained dependency graph within the same address space.

    The orthogonality of the two dimensions matters for engineering composability. The time dimension’s hot-update mechanism does not need to understand the space dimension’s business topology, and the space dimension’s dependency resolution does not need embedded transaction semantics. Orthogonal decomposition turns a complex problem into two independently verifiable subproblems and makes formal proof possible—which is the real meaning of a “provable programming paradigm.”

    3. Architecture Pattern: How “Everything Is a Plugin” Works in Practice

    “Everything is a plugin” is not a slogan but a hard constraint: the host’s own capabilities (session management, tool scheduling, logging, and monitoring integration) also exist as plugins, eliminating the binary privilege structure of “core versus extension.” In practice, this typically involves four building blocks.

    First, plugin descriptors and capability declarations. Each plugin explicitly declares its input/output contracts, required capabilities, and required permissions. The host uses these to build the dependency graph and perform static validation.

    Second, the dependency graph and reference counting. The host maintains fine-grained topology. On unload, it uses reference counts and dependency closures to decide what can be collected, avoiding dangling references.

    Third, the change transaction manager. It opens a transaction for every load, update, and unload, records state snapshots and side-effect logs, and applies both commit and rollback to the same transaction boundary.

    Fourth, isolation and degradation strategies. Within the same address space, soft isolation is implemented through namespaces, capability allowlists, and resource quotas. For high-risk plugins, process-level isolation is added as a fallback.

    Illustrative code (structure only, not a specific product interface):

    1. # Plugin contract: capability declaration + lifecycle hooks
    2. class Plugin:
    3. requires = [] # names of required capabilities
    4. provides = [] # names of exposed capabilities
    5. def on_load(self, ctx): ...
    6. def on_unload(self, ctx): ...
    7. # Transactional hot update: snapshot -> switch -> rollback on failure
    8. def hot_swap(registry, name, new_impl):
    9. tx = registry.begin_tx()
    10. try:
    11. tx.snapshot(name)
    12. registry.replace(name, new_impl)
    13. tx.revalidate_dependents(name)
    14. tx.commit()
    15. except Exception:
    16. tx.rollback() # return to pre-change state; session and memory are unaffected
    17. raise

    4. Key Mechanisms

    Lossless hot updates depend on separating state from code. Long-lived state such as session memory and connection caches is hosted and versioned by the host. Plugin code holds only references to that state, not ownership. When an implementation is replaced, the state does not need to be rebuilt, which avoids cold-start latency.

    Transactional rollback depends on side effects being undoable. Pure computation can be reverted using snapshots. For external side effects (writing files, sending messages, calling external APIs), compensating actions or idempotency keys are needed to turn “irreversible” into “replayable and idempotent.” As an engineering practice, all external calls should be required to carry an idempotency identifier; this is the prerequisite for rollback correctness.

    Fine-grained dependency expression depends on contracts first. Dependencies must be declared at the capability level, not the implementation level, so the host can re-resolve and perform canary switching without understanding business semantics. If dependencies are implicitly scattered inside code, the space dimension’s composability degrades back to coarse-grained restart.

    5. Engineering Tradeoffs and Common Pitfalls

    First, do not pursue “unlimited hot updates.” For changes involving global data structures or incompatible protocols, explicitly choose “dual-write transition plus canary switching” instead of forcing an in-place replacement.

    Second, there is a tradeoff between isolation strength and update latency. Soft isolation updates quickly but isolates weakly; process-level isolation is the opposite. A reasonable approach is to grade by risk: strong isolation for core paths, soft isolation for edge tools.

    Third, observability must come first. Without structured logs, metrics, and call tracing, transactional rollback becomes a blind operation. Logging services and monitoring alerts should be integrated as first-class host capabilities.

    Fourth, formal constraints must become engineering constraints. If contract validation, permission allowlists, and resource quotas exist only in documentation, spatiotemporal composability remains just a concept.

    6. Conclusion

    Competition among long-running agents is shifting from model capability to host runtime capability. Decomposing dynamic composition into two orthogonal dimensions—time and space—using “everything is a plugin” to eliminate a privileged core, and replacing coarse-grained restart with transactional changes and a fine-grained dependency graph is a viable path toward self-evolving agents. For developers, three things can be started immediately: define capability-level contracts, introduce idempotency keys for external side effects, and integrate logging and tracing into the host’s foundational capabilities.