Planning & Control Flow

Standing State Injection

Recompute a compact task-state snapshot each turn and inject it as a fresh system block before the model reasons, so a long tool-call loop stays oriented on the goal.

Problem

A goal stated once at the start of a long trajectory drifts as the history grows: the model loses track of what it set out to do, what is already done, and what comes next, and it may ask a question it already answered or declare the task finished early. Relying on the buried opening instruction is brittle, while re-reading the whole history each turn is expensive and still leaves the goal lost in the middle. The agent needs its current state restated where it will actually be read, every turn.

Solution

Before each model turn, the harness builds a compact state snapshot from the live execution: the standing goal, a one-line status of what is done, and the immediate next step or open question. It renders this as a short structured block and injects it as a system message placed near the top of the assembled prompt, where the model attends most. The block is recomputed every turn from the current run rather than copied from the previous turn, so it tracks progress as the agent works. The full history may still be present or offloaded elsewhere, but the standing block guarantees the goal and next step are always restated in a low-cost, high-salience position, independent of any durable plan file.

When to use

  • Tasks run long enough that the original goal sinks into the low-attention middle of the context window.
  • The harness controls prompt assembly and can derive a current-state snapshot from the live run each turn.
  • Goal drift, premature completion, or re-asking answered questions is an observed failure on long trajectories.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related