Agent Harness Design: Spatiotemporal Composability for Long-Running, Self-Evolving AI Agents
This article explains why traditional plugin systems, container orchestration, and process-level isolation fall short for self-evolving AI agents, and how spatiotemporal composability addresses the problem. It covers the three hard requirements of long-running autonomy, the three costs of coarse-grained restarts, the "everything is a plugin" model with a sample plugin contract, engineering practices such as sandboxing, transactional hot updates, externalized state, observability, least privilege, and gradual rollout, plus cloud deployment guidance and the risk boundaries teams should respect.
1. Background: Agents Are Moving From One-Shot Calls to Long-Term Self-Evolution
Most early LLM applications stayed at the level of single-turn question answering or one-off prompt calls. The host environment only forwarded requests to the model and returned results to the user. Lifecycles were extremely short, and state management was rarely a concern.
Once agents began taking on long-running task execution, multi-tool coordination, and self-improvement, the agent harness shifted from an optional outer shell to the critical infrastructure that determines the ceiling of the whole system.
The harness is the full runtime foundation that carries an agent: session and memory management, tool registration and scheduling, permissions and sandboxing, error handling, observability, and upgrade and release mechanisms. It decides whether an agent can work unattended for hours or even days, and it decides whether the system “gracefully absorbs” new code the model writes itself or collapses entirely.
Long-running self-evolution imposes three coupled hard requirements on the harness:
- Dynamic extensibility and plug-and-play tools: Agents need to generate, load, and unload external tools or third-party services on demand based on the current subtask. The tool set changes with the task phase instead of being fixed at startup.
- Self-modification with lossless hot updates: While running, an agent may write code on its own to extend capabilities or patch known tool defects. Such updates must take effect in place, without interrupting sessions in flight or losing accumulated memory and connection caches.
- Fault tolerance and transactional rollback: Model-generated code is inherently uncertain. Syntax errors, infinite loops, and unauthorized access can all occur. The harness needs database-like atomicity guarantees so a failed change can be reverted as a whole, keeping global state clean.
2. Why Traditional Approaches Fall Short: The Triple Cost of Coarse-Grained Restarts
Common software systems in the industry — the plugin systems of AI coding tools, microservice governance on container orchestration platforms, and process-level isolation schemes — are mature in their own domains. Applied to agent self-evolution, however, they expose structural flaws: they assume “changes are human-reviewed and released infrequently,” while agent changes are “machine-generated and high-frequency.”
The costs show up in three ways:
- State loss: Unloading a plugin or updating a service usually requires restarting a process or container. Session context, accumulated memory, connection pools, and caches are wiped, forcing long tasks to start over and driving costs up linearly.
- High startup latency: Cold starts must reload dependencies, rebuild connections, and warm up model clients. Latency ranging from seconds to tens of seconds directly consumes the task budget under frequent updates.
- Coarse dependency expression: Processes and containers are coarse-grained boundaries. They cannot describe fine-grained topology within a single address space, such as “tool A depends on a specific version of tool B and is visible only in phase two.” The result is either excessive isolation that wastes resources or insufficient isolation that causes interference.
The conclusion: what is needed is a finer-grained composition unit and a weaker restart assumption, not parameter tuning of existing systems.
3. The Paradigm Answer: Everything Is a Plugin and Spatiotemporal Composability
One widely discussed approach is to make the harness itself a composable unit — “everything is a plugin.” Models, tools, memory, retrieval, permission policies, and logging and monitoring integrations are all registered under a unified plugin contract, with a meta-framework orchestrating their lifecycles. On top of this, formal theory usually summarizes the key property as “spatiotemporal composability,” understood along two orthogonal dimensions:
- Spatial composability: Every capability is a replaceable, nestable plugin node. Dependencies are described as declarative topology, with versioned binding and least-privilege grants. Replacing one node requires no knowledge of the implementation details of the others.
- Temporal composability: Plugins have an explicit state machine (registered, activated, suspended, upgraded, rolled back, unloaded). Upgrades switch atomically along the timeline, and old instances are drained with a delay rather than destroyed immediately, so in-flight requests and memory stay intact.
Only when the two are combined does “an agent modifying itself” move from a demo to controllable engineering.
A schematic plugin contract can be abstracted as:
interface Plugin {id: stringversion: stringrequires: Array<{ id: string; range: string }>activate(ctx: RuntimeContext): Promise<Handle>suspend?(h: Handle): Promise<void>upgrade?(h: Handle, next: Plugin): Promise<Handle>rollback?(h: Handle): Promise<void>}
At load time, the host performs dependency resolution and topological sorting. During an upgrade, it activates the new instance first, then removes references to the old one. If any step fails, it invokes the rollback chain.
4. Engineering Implementation Essentials
- Sandboxing and resource quotas: Give model-generated code an isolated execution sandbox with limits on filesystem, network egress, CPU, and memory, plus timeouts and call budgets, so a single plugin cannot take down the host.
- Changes as transactions: Model a hot update as a transaction with four steps: pre-check (syntax and dependency validation), canary activation, health probing, and commit or rollback. Commit only after the health probe passes.
- Externalized state and snapshots: Keep session memory and connection caches in snapshot-capable storage or a message queue as much as possible. Plugin instances should hold only rebuildable handles to reduce restart cost.
- Observability built in: Emit telemetry for every load, upgrade, and rollback, and combine it with logging services and monitoring alerts to form a traceable chain. This makes it easier to identify which self-modification caused a regression.
- Least privilege and auditing: The dependencies a plugin declares are its permission boundary. Log an audit record for every outbound call to prevent the self-evolution process from expanding the attack surface.
- Gradual adoption: Open hot updates first on read-only tools and non-critical paths. Once stability is verified, extend them to write operations and core paths.
5. Cloud Deployment and Selection Guidance
In cloud environments, separate the control plane from the execution plane of the harness. The control plane manages the plugin repository, versions, and policies. The execution plane runs on a container platform, with object storage holding snapshots, a message queue buffering long-task events, and logging and monitoring systems handling observability. When selecting components, focus on four points: support for fine-grained dependency declaration, atomic rollback capability, whether state can be externalized and snapshotted, and whether sandbox isolation strength meets compliance requirements. Smaller teams can start by implementing the two minimal capabilities of “dynamic tool registration + graceful draining,” then gradually add transactional upgrades.
6. Risks and Boundaries
Self-evolution does not mean unrestricted freedom. The correctness of model-generated code cannot be formally guaranteed, so the engineering focus should be on “limiting the blast radius” rather than “pursuing absolute correctness.” Small changes, rollback capability, observability, and auditability are four non-negotiable bottom lines. In addition, fine-grained composition brings dependency governance complexity and requires matching version strategies and compatibility testing; otherwise the problem slides from “restart cost” into “dependency hell.” Overall, a harness centered on pluginization and spatiotemporal composability is becoming the evolution direction for long-running agent infrastructure, and architecture teams would do well to plan for it early.
