arXiv:2608.22928cs.PLAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.22928

When Can Agents Safely Checkpoint, Fork, Restore, and Merge? Exact Checking for Execution Edits

Yusheng Zheng, Xiaoyu Song, Yanpeng Hu, Lebin Cheng, Yuxi Huang, Wei Zhang

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

Yusheng Zheng*, Xiaoyu Song†, Yanpeng Hu‡, Lebin Cheng§, Yuxi Huang¶, and Wei Zhang‖

*University of California, Santa Cruz

†University of Texas at Dallas

‡ShanghaiTech University

§RailXia ¶Eunomia Labs ‖University of Connecticut

Abstract—Agent runtimes can Checkpoint an execution, Fork it, Restore a checkpoint, or Merge branches without restarting a task. We call these operations execution edits, with Checkpoint recording the current execution for later use and Fork, Restore, and Merge changing what the Agent will do next. An execution edit cannot undo an earlier authorization or a tool request already sent. An unsafe edit can therefore authorize the same tool action twice, discard a result the task still requires, or conflict with a call that began before the edit. The Agent is untrusted, so the runtime uses its execution record to determine which past actions an edit must account for and which required results it must preserve to keep the subsequent execution safe. Yet existing Agent systems support such operations without deriving what each edit must preserve from the running execution, whereas prior methods for computing safe behavior take that requirement as input. We give an algorithm that decides exactly whether an edit is safe. It returns all safe ways to continue, or proves that none exists. To make this decision, the algorithm lists every way the task can finish without violating policy. It removes any way that could make a still-required result impossible to finish later. If none remain, it returns a checkable proof that no safe implementation exists. Otherwise, the remaining ways describe exactly what the runtime may allow. Our formal results cover Checkpoint and the six forms of Fork, Restore, and Merge, together with extensions, atomic enforcement, and the information every exact checker needs. Lean mechanizes the finite checker and runtime invariant, and tests validate all six edit forms. The source code, Lean proofs, and executable tests are available in the public GitHub repository at https://github.com/eunomia-bpf/agent-check-restore-safety.

I. INTRODUCTION

Tool-using Agent runtimes can change an execution while it is in progress. They let an Agent Checkpoint an execution, Fork it into alternatives, Restore an earlier checkpoint, and Merge branches [1], [2], [3], [4], [5], [6]. These operations support exploration, recovery, and reuse without restarting the task. We call all four operations execution edits. Checkpoint records the current execution for later use, while Fork, Restore, and Merge change what the Agent will do next.

Consider an Agent buying one laptop for a school. Before asking the school to approve the purchase, it saves checkpoint k. The school approves one purchase, and the Agent later chooses supplier R and authorizes payment. The Agent then restores k to compare supplier L and merges the L branch into the current execution. If the runtime sees only the restored workspace, it may request the same approval again or continue with L even though payment to R is already authorized [7]. Either behavior breaks the school's purchasing rules because the first repeats a one-time approval and the second combines incompatible supplier actions.

This example shows that the runtime cannot rely on the Agent's account of the execution. The Agent may request an edit that omits an earlier action or a result the task still requires. The trusted runtime instead determines what may happen next from an execution record that the Agent cannot modify; in this example, the record remembers the one-time approval and the authorized payment to R. A tool action is an external operation governed by policy, such as approval, payment, or shipment. The runtime checks every tool action against policy. The runtime makes its security decision when authorizing a tool request. Sending the request later and recording its return cannot undo that decision. The runtime stores that decision in an authorization record, which later calls may reuse. Our security goal is therefore to prevent an edit from authorizing a tool action forbidden by policy or discarding a result that the task still requires. Meeting this goal requires four facts: (1) the task structure and its required results, (2) which calls refer to the same action, (3) earlier authorizations and call progress, and (4) which rules govern a call that overlaps the edit. Each fact can change the correct answer. The restored workspace, an execution trace alone, an authorization log alone, and the Agent's own description each omit information the checker may need. Before an edit takes effect, the runtime records the finite set of relevant tool calls, their possible orders, and results. The Agent's internal reasoning remains unchanged.

Existing approaches cover parts of this problem but do not derive its complete safety condition. Agent systems provide branching, staged effects, transactions, or recovery checks [8], [9], [10], [11], [12], [13], [14], [15]. Control and synthesis choose behavior after a model of possible executions and desired final states has been supplied [16], [17], [18], [19]. Neither line of work derives from a recorded execution everything that a particular edit must preserve before it takes effect.

Our key idea is to derive from the execution record what

Figure

Fig. 1. Fork, Restore, and Merge change the current workflow but do not erase recorded calls. Restore creates a new call that refers to the same action as the original call. The atomic rule update orders authorization creation and reuse against the rule change.

each edit must preserve: earlier authorizations and every result that remains required. Every result required before the edit must remain required, already be satisfied by the recorded execution, or be explicitly removed by the same authority that required it. The Agent requests an edit under a registered edit rule. The trusted runtime checks the recorded task structure and determines from that record, rather than from Agent text, what may happen next and which requirements carry over. The Agent therefore cannot obtain a favorable answer by describing an execution that omits earlier actions or required results.

This idea creates three technical problems. First, calls copied by Fork or Restore may refer to the same underlying action, so the runtime must distinguish a new authorization from reuse of an earlier authorization and return value. Second, throughout every allowed execution, every result that is still required and still possible must retain a safe way to finish. The checker must enforce this condition without forbidding additional safe behavior. Third, the rules for an accepted edit must take effect atomically with calls that overlap the edit and remain valid if the runtime or machine stops unexpectedly and later recovers.

We give an exact checker that computes every safe way for a requested edit to proceed or proves that every possible way is unsafe. For a requested edit, the runtime constructs every allowed complete execution from the current record. It removes an execution if allowing its calls one at a time could leave a still-required result without a safe completion. If none remains, the runtime returns an independently checkable proof that no runtime rule set can enforce the edit safely. Otherwise, the remaining executions contain every safe way for the edit to proceed. Before the edit takes effect, the runtime checks the current execution record again and atomically switches to the newly computed rules. Each overlapping call is checked entirely under either the old or new rules. Figure 1 illustrates this process for an approval task containing Fork, Merge, Restore, and calls that overlap the atomic rule update. After Restore, the repeated approval call reuses the earlier authorization record instead of authorizing the approval again.

a) Contributions:

  1. Safety model. We define Checkpoint, Fork, Restore, and Merge safety from the execution record rather than letting the Agent choose the edited execution. The model preserves past actions and every still-required result and proves that exact checkers must distinguish answer-changing cases from all four record parts.

  2. Exact checking and atomic enforcement. We construct an executable checker that returns every safe way to proceed or a proof that none exists. Checkpoint has an exact check, and the checker accepts each of the six forms of Fork, Restore, and Merge exactly when the safety condition is enforceable. Our formal runtime protocol rechecks the record, makes accepted rules take effect atomically, preserves safety across repeated edits and restarts, and has the same Agent-visible behavior as an ideal atomic machine.

  3. Mechanization and executable validation. Six Lean modules mechanize registration, all six edit forms, the atomic rule update, concurrent calls, and preservation across finite executions. Nineteen paper-specific tests and measurements over 2–128 results exercise the executable checker.