Manuscript Offprint

arXiv:2609.35366

Planarian: Managing Agent State with Statepoints

Jinnan Guo, Hao Mark Chen, Kapil Vaswani, Andrew Paverd, Peter Pietzuch

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

LLM agents solve complex tasks by iteratively changing files, invoking local tools, and interacting with remote services, which modifies state across their local environment and remote services. Today, agents and users must manage these changes explicitly, whether reverting exploratory actions or recovering from erroneous ones. Doing so safely requires coordinated actions, yet current agent harnesses lack unified abstractions and mechanisms for managing local and remote state consistently and efficiently.

We describe PLANARIAN, an agent runtime with state management that enables agents and users to recover from erroneous actions and explore alternative executions over consistent local and remote environment state. PLANARIAN introduces the abstraction of agent statepoints, which are consistent, restorable point-in-time versions of the environment state. PLANARIAN exposes three state-management primitives to agents and users: (i) snapshot creates a new statepoint spanning local and remote state without requiring external services to support checkpoints: it relies on efficient incremental process and file system snapshotting to capture local sandboxed state, and transparently records compensating actions to undo remote state changes; (ii) rollback restores the environment to a previous statepoint by reverting to a prior local checkpoint and replaying compensating actions for remote state changes; and (iii) fork creates multiple isolated branches from a statepoint, enabling the agent to explore alternatives in parallel. We show that PLANARIAN enables agents to undo mistakes and explore alternatives in parallel, improving task quality by up to 15×, and allows users to recover from erroneous actions with only 3% overhead.

1 Introduction

Agents perform tasks that require repeated interaction with a host machine, from modifying software to administering services [3, 4, 15]. An agent harness invokes a large language model (LLM) with context comprising instructions, prior actions, and tool results. It uses the model's output to invoke tools and incorporates their results into subsequent context. Tool calls request commands or service operations that act on environment state: local files and processes, and state held by external services, such as database state. Local tools can execute directly on the host or within a sandbox that

Peter Pietzuch

Imperial College London

isolates their execution. The harness can invoke remote tools through the model context protocol (MCP) [2].

When an agent fails to complete a task, it may have to undo earlier actions before trying different steps. A user may also want to reverse an unwanted change, such as the deletion of files or incorrect updates to a remote calendar service. For the agent, reconstructing state requires extra tool calls, which may be costly or impossible if data was lost. We observe that explicit state management would let agents and users recover from mistakes without manually having to repair the affected state. Agents could also explore the effect of alternative actions on the environment efficiently without repeating successful work or carrying over unwanted effects.

Supporting such state management alongside existing agent harnesses, however, raises three challenges:

(1) Consistency across local and remote state. State management requires environment consistency, i.e., it must restore both local and remote state consistently. Local files and processes can be checkpointed, but MCP endpoints of remote network services may provide neither snapshots nor undo operations. Recovering only local state can result in inconsistencies though: for example, a data-cleaning agent may update database records through an MCP endpoint and write a local report of its changes. Reverting only the local report leaves it inconsistent with the updated remote database.

(2) Integration with agent execution. Users and agents must be able to perform state management through existing agent harnesses. In addition, state management must guarantee context consistency, i.e., the agent must be aware of the changes to the environment state. After the environment state is restored, the history of tool calls may describe effects that no longer exist. Simply retaining this history can mislead the agent; discarding it loses evidence of unsuccessful actions that could guide future actions. State management therefore affects both how the harness dispatches tools and what context it supplies.

(3) Overhead of state management. Frequent state management must not dominate task execution time or storage use. Local state, including files and process memory, may be large, even when individual tool calls change little state. State management overheads may accumulate both as execution advances and whenever an earlier state is revisited to try different actions. Managing remote state also incurs communication latency and is constrained by MCP interfaces.

Prior approaches solve only some of these challenges. Checkpointing systems such as DMTCP [18] and Catalyzer [25] preserve local execution state, but cannot account for remote service state or agent decisions. Transactional workflows [45], speculative configuration repair [37], and intrusion recovery with external compensation [30] establish broader recovery models, but target generic workflows or application repair rather than agent exploration. Without environment and context consistency, state management cannot serve the parties that need it: an agent cannot safely roll back on its own, a harness cannot search over alternative branches, and a user cannot reliably undo an unwanted change. The open problem is thus to make an agent's evolving environment state a unit of recovery and exploration, which is consistent across local and remote state, consistent with the agent's context, and efficient enough to be used repeatedly.

We describe PLANARIAN, an agent runtime for state management that operates together with existing agent harnesses. PLANARIAN provides a unified abstraction for managing local and remote environment state, enabling consistent recovery and exploration while supplying the information needed for subsequent agent decisions. For this, PLANARIAN makes three technical contributions:

(1) Agent statepoints and primitives. Recovery and exploration need a common abstraction for managing both local and remote state. PLANARIAN introduces agent statepoints: a statepoint captures both local files and running processes together with the remote state changed through MCP operations. A statepoint remains restorable even when the remote service cannot take checkpoints, and carries a description of the captured state and the outcomes of prior executions. For state management, three primitives operate over statepoints: (i) snapshot records a new statepoint; (ii) rollback returns to a statepoint to undo state changes; and (iii) fork starts an isolated alternative execution in a branch from a statepoint, while preserving the existing state.

(2) Integrating agent statepoints with agent execution. PLANARIAN exposes its state-management primitives (a) as tools that agents invoke directly, or through APIs for (b) harness-driven search or (c) manual user requests. During execution, the agent must select suitable statepoints and interpret them correctly. PLANARIAN uses the evidence associated with statepoints both to inform this choice and to update the agent context afterward. The agent harness retains responsibility for LLM invocations and context construction, routing tool calls through PLANARIAN and incorporating the returned results. PLANARIAN manages environment state through local tool sandboxing and MCP proxying, and captures statepoints between tool calls. After restoration, PLANARIAN supplies the selected state's description and prior outcomes to the agent harness to append to the context. This identifies the environment state now available to agents without discarding the information needed to choose different actions.

Figure

Figure 1. Agent harness invoking the LLM and tools

(3) Local checkpointing and remote compensation. To keep the overhead of state management low, PLANARIAN limits the state that must be copied locally and reconstructed remotely when creating or reverting to statepoints. For local state, PLANARIAN combines incremental copy-on-write filesystem snapshots [17] with CRIU process checkpoints [7] that record only changed memory. PLANARIAN re-establishes the restored checkpoint as the baseline for subsequent memory changes, allowing incremental capture across rollback and fork without modifying CRIU or the kernel. This avoids repeatedly copying unchanged memory during exploration. For remote state, PLANARIAN proxies supported MCP requests so that their effects can be reversed through compensating actions—service operations that undo earlier changes. For example, a database MCP proxy preserves original database row values and affected keys within the transaction that modifies them, allowing destructive updates to be undone. We evaluate PLANARIAN with agents in coding, personal assistance, system administration, database management, and gaming tasks. In the Mario platform game, an agent that uses PLANARIAN to retry from statepoints achieves 15×15\times the game score of an agent without state management. When solving system-administration tasks with MCTS-style tree search, PLANARIAN takes snapshots 10×10\times faster than a baseline that uses full process and filesystem checkpoints. Across system and database administration tasks, state management adds only 1%-3% to completion time, including coordinated recovery for an agent that modifies a remote database through MCP. These results show that PLANARIAN enables agents to revisit decisions and explore alternatives while incurring little overhead for state management.

References (11)