Agent Harness时空 Composability: A Practical Guide to Dynamic Composition

    This article explores how an Agent Harness can support long-running agents through spacetime composability, a design approach that separates dynamic composition into a time dimension and a space dimension. It covers the limits of process- or container-level extension, the plugin abstraction and its required metadata, the key steps for lossless hot updates, transaction-level rollback and fault isolation, and practical adoption advice combined with generic cloud capabilities. Readers will learn how to keep extension predictable, state recoverable, and the agent runtime continuously evolvable.

    1. Why Long-Running Agents Put New Demands on the Harness

    As agents move from single-turn question answering to long-running task execution, multi-tool collaboration, and self-evolution, the Agent Harness is no longer just a shell that calls a model. It becomes a runtime responsible for lifecycle management, resource isolation, and state persistence.

    The traditional approach binds extension units to a process or container granularity. Loading, replacing, or unloading a capability then requires a full restart, which means lost session memory, rebuilt connection caches, and non-negligible startup latency.

    Common intelligent coding tools, plugin-based editors, and microservice orchestration solutions are mature at coarse-grained isolation. However, they struggle to express fine-grained dependencies within the same address space, and they cannot easily keep serving while an update is in progress. The dynamic composition problem therefore needs to be abstracted into a programming paradigm that is provable and implementable, rather than addressed by piling up more restart scripts.

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

    Spacetime composability decomposes the challenge into an orthogonal time dimension and space dimension.

    The time dimension focuses on when change is allowed: whether loading, replacement, and rollback are atomic, and whether a change is visible to tasks already in execution. The space dimension focuses on at what granularity composition happens: how dependencies, scopes, and isolation boundaries between capability units are declared.

    The value of this split is that engineering choices can be made independently. The time dimension can be solved with transactions and versioning; the space dimension can be solved with dependency graphs and scopes. Only when the two intersect can all three requirements be met at once: dynamic extension, in-place hot updates, and failure rollback.

    3. Everything Is a Plugin: Benefits and Costs of a Unified Abstraction

    The “everything is a plugin” philosophy treats tools, model adapters, storage access, and UI capabilities as registrable units. The benefit is a unified extension path: adding a capability requires no changes to the host kernel. The cost is that strict contracts become mandatory; otherwise implicit coupling between plugins turns hot updates into uncontrollable behavior.

    It is recommended to define four kinds of metadata for each plugin: capability identifier, dependency declaration, state ownership, and rollback strategy. Only when state ownership is clear can state be safely migrated or discarded during plugin replacement. Only when the rollback strategy is explicit can the system return to a consistent snapshot on failure.

    1. plugin:
    2. id: tool.web_search
    3. depends_on: [net.pool, cache.session]
    4. owns_state: [conn_pool, quota_counter]
    5. rollback: snapshot

    4. Key Engineering Points for Lossless Hot Updates

    The key to a lossless hot update is not “replacing code” but “maintaining invariants while the replacement happens.” Four steps can be followed: first, build the new version and warm up its dependencies; second, freeze writes or reach a barrier point; third, migrate serializable state; finally, atomically switch the reference and release the old version. If any step fails, fall back to the old version reference.

    The pseudocode below is illustrative. The focus is on the barrier and the atomic switch, not on specific interfaces:

    1. def hot_swap(old, new):
    2. new.warmup()
    3. with barrier(old): # Pause new tasks from entering; wait for in-flight tasks to reach a safe point
    4. state = old.snapshot() # Migrate only state declared as serializable
    5. new.restore(state)
    6. ref.atomically_set(new) # Single-point atomic switch
    7. old.dispose_later() # Deferred release to avoid dangling in-flight references

    Two additional engineering concerns matter. Connection pools and handles cannot be serialized naively; they should use “ownership transfer” or “externalized hosting.” Long-running tasks should expose safe points; otherwise the barrier degrades into a global pause.

    5. Transaction-Level Rollback and Fault Isolation

    When a model autonomously generates extension code, syntax errors, infinite loops, and resource leaks can all occur. The host framework needs database-like atomicity: a change either takes effect in full or is undone in full. In practice, each change can be assigned a transaction identifier, with a snapshot of the dependency graph and a snapshot of state recorded; on failure, plugins are unloaded in reverse order and references are restored.

    For isolation, it is advisable to layer on resource quotas, timeout circuit breaking, and capability allowlists so that a single plugin cannot bring down the host. Rollback does not equal safety; it must be paired with “least privilege” and “observability,” otherwise side effects may remain even after a rollback.

    6. Adoption Advice and Fit with Generic Cloud Capabilities

    Start with hot updates for read-only plugins, then gradually open up stateful plugins. Establish contract tests and change drills, and include the rollback path in routine validation.

    On the cloud, a container platform can host the agent harness processes, object storage can hold snapshots, a message queue can decouple long-running tasks, and logging services plus monitoring alerts can track barrier duration, switch failure rate, and rollback counts.

    Overall, spacetime composability provides a set of design constraints: it confines “mutability” to a provable range. For developers, the real payoff is not the black-box capability of any single tool, but predictable extension, recoverable state, and an agent runtime that can keep evolving.