Execution-State Ledger
also known as Execution State Layer, Runtime Execution State, Derived Validity Index
Maintain an execution state outside the model that records what the run has observed, changed and attempted, and consult it before each step so stale observations are refused and still-valid results are reused.
Context
A long-horizon agent works in an environment it also modifies — a repository, a filesystem, a terminal, a live service. Every step appends an action and an observation to the trajectory, and after a few hundred steps that trajectory is the only account the model has of the situation it is acting in. Each entry was accurate at the moment it was taken, and the run's own later writes are what made some of them wrong. The harness controls both boundaries of a step: what is rendered into the prompt, and which command is allowed to execute.
Problem
A trajectory records what happened; nothing in it says which observations still describe the environment as it currently stands. Before every decision the model has to infer the current execution status from raw history, and that inference degrades as the history grows. When it falls short the agent acts on file contents that its own later edit superseded, or re-runs work whose result was still perfectly valid. Both failures are invisible at the step where they occur: the stale action succeeds, the redundant command returns the same answer, and the cost shows up as a wrong patch and a long, expensive run.
Forces
- The trajectory is a faithful record of what happened, which is exactly why it cannot state what is currently true — every observation in it was correct when it was taken.
- Leaving the current state to be inferred by the model costs nothing to build but is paid on every step and degrades with length; replacing the history with derived state raised Pass@1 from 56.2% to 64.2% on all 500 SWE-bench Verified instances while cutting total cost by 28.9%.
- Maintaining the state in the runtime keeps it deterministic and adds no model calls, but the invalidation rules have to be written by hand for each kind of action and each kind of resource.
- Dropping the raw trajectory from the prompt saves tokens and removes distractors, but it also removes the evidence the model would need to notice that the derived state itself is wrong.
Example
An agent is fixing a failing test in a large repository. Early in the run it reads a configuration file, forty steps later it edits that same file, and near the end it proposes a change based on the version it read at the start. A record of what the run has touched marks the first read as superseded, so the agent re-reads the file instead of writing over its own edit.
Diagram
Solution
Therefore:
The runtime keeps a structured record of the run's own execution alongside the trajectory: which resources have been observed and when, which have been modified since, and which commands have been attempted with what result. The record is maintained deterministically from the action stream, not written by the model, so it costs no extra model calls and can be inspected and tested like any other runtime component. It is then consulted at both boundaries of every step. On the way in, the prompt carries the current execution state — what is true now, what is still open — instead of the accumulated history. On the way out, each proposed command is checked against that state before it executes: a command whose recorded result is still valid is answered from the record rather than re-run, and a command premised on an observation that a later write has superseded is blocked so the agent re-observes first. The raw log can still be kept for audit; it simply stops being the thing the model reasons over.
What this pattern forbids. The raw trajectory is no longer what the model reasons over, and no command may execute without being checked against the execution state first: an action premised on an observation the state marks superseded must be blocked until the resource is re-observed, and a command whose recorded result is still valid must not be re-executed.
And the patterns that stand alongside it, or against it —
- complementsAppend-Only Thought Stream★— Make the agent's thought log append-only so the agent cannot rewrite its own history.
- alternative-toContext Compaction★— When the context window nears its limit, replace the older conversation span with a model-written digest that preserves decisions, commitments, and active constraints while discarding noise, so the agent keeps running without losing the thread.
- complementsStateless Reducer Agent★— Design the agent as a pure function (state, event) → newState; entire execution history is held in an external event log; enables pause / resume / replay / time-travel without bespoke checkpointing.
- complementsMemo-As-Source Confusion✕— Anti-pattern: the agent cites its own past memos as ground truth instead of re-verifying them against the artifacts they describe, accumulating false confidence in stale summaries.
- complementsTool Result Caching★★— Cache the result of expensive deterministic tool calls keyed by their arguments so repeat calls within a session return immediately.
- complementsWorld-Model Graph Memory★— Memory store structured as a typed entity-relation graph used as the agent's authoritative world model for planning — not only for retrieval.
- complementsAgent Resumption★★— Persist agent execution state so a long-running run survives restarts, deploys, or user disconnects.
- complementsScratchpad★★— Give the agent a writable scratch space for intermediate notes that informs later turns but does not pollute the response.
Neighbourhood
Click any neighbour to follow the language. Scroll to zoom, drag to pan.