H-01Perception & StateDesignEngineering

Continuous State Anchoring

Surface live post-conditions and ambient state continuously, so the agent never reconstructs reality from stale history.

Human UXAgent AXVisibility of system status→Live state anchors

Friday, 4:40 p.m. A deployment agent gets a routine task: raise the database connection pool for payments-api from 20 to 40 on staging, run the load test, and report the p95 latency. The agent starts well. On turn 2 it calls set_target(env="staging") and gets back {"ok": true}. It runs a baseline load test and reads several long reports.

On turn 9 it has a good idea. Before testing a new value, it wants to know what production actually runs, so the test is realistic. It calls set_target(env="prod-eu"), reads the config, sees pool_size: 20, and goes back to work on the load test. It never switches back.

Twelve turns later, the agent edits pool.yaml and calls apply_config(service="payments-api", file="pool.yaml"). The tool answers {"status": "applied", "revision": "r118"}. The agent restarts the service, which reports {"status": "rolling", "pods": 12}. Staging has two pods. Nobody notices the number.

The untested setting is now live in production. Twelve pods at 40 connections each ask the database for 480 connections, more than it accepts. Checkout starts failing, the on-call engineer gets paged on a Friday evening, and the first question in the incident channel is "why did the staging agent touch prod?"

The agent did not misread anything. Every response it got was accurate. It simply believed it was on staging, because "staging" was the last thing it remembered being true, and no response in the twelve turns since had said otherwise.

Why it happens

A person doing the same job would have had the answer in front of them the whole time. The shell prompt reads (prod-eu) $. Many teams color production terminals red. The IDE status bar shows the branch, and the cloud console shows the account in the top corner. Jakob Nielsen put this first in his list of usability heuristics: visibility of system status. The system keeps telling you where you are, so you never have to remember it.

The agent has no status bar. Everything it knows arrives as one long line of text, oldest first: the task, its own reasoning, every tool call and every response, appended in order. The Guide calls this the 1D temporal ribbonLexicon · 081D Temporal RibbonThe linear token stream through which an agent perceives reality.. Nothing on the ribbon is ever updated in place. A fact changes only when something later on the ribbon says it changed.

So when the agent asks itself "which environment am I in?", nothing answers. It has to reconstruct the answer from history: scan back for the most recent set_target call and trust that nothing since has changed it. That is bookkeeping, and the interface has quietly handed it to the agent.

In this session, the bookkeeping is stacked against it. The word "staging" appears in the task, on turn 2, and in almost every line of the agent's own reasoning ("the staging numbers look fine"). The word "prod-eu" appears once, in a short call on turn 9. Both statements are true, at different times, and nothing on the ribbon marks the first one as superseded. Stale state sitting next to live state, with no way to tell which is current, has a name: temporal vertigoLexicon · 17Temporal VertigoDisorientation from stale past states coexisting beside live state..

Position makes it worse. Models tend to weigh the start and the end of their context most heavily, and attend less reliably to what sits in the middle. The Guide calls this layout of strong and weak zones attention geometryLexicon · 14Attention GeometryPositional layout of information across primacy, middle and recency zones.. The task, with its "on staging", sits at the strong start. The turn-9 switch sinks into the weak middle as more load-test output piles up after it.

The figure below condenses the session from the hook to the four turns that matter, as two transcripts. Under each turn, compare where the agent really was with what it believed. In the top row, the responses say nothing about the target. In the bottom row, every response ends with the current target.

turn 2really on stagingturn 9really on prod-euturns 10–20really on prod-euturn 21really on prod-euHistory onlyset_target(env="staging"){"ok": true}agent believes stagingset_target(env="prod-eu"){"ok": true}agent believes prod-euLoad tests, long reports{"p95_ms": 182, …}notes: “staging looks fine”agent believes stagingapply_config(…){"status": "applied", "revision": "r118"}agent believes stagingLands on prod-eu. The restartrolls 12 production pods.Anchored stateset_target(env="staging"){"ok": true, "env": "staging"}agent believes stagingset_target(env="prod-eu"){"ok": true, "env": "prod-eu"}agent believes prod-euSame tests and reports{"p95_ms": 182, …, "env": "prod-eu"}agent believes prod-euset_target(env="staging")apply_config(…){"status": "applied", "env": "staging"}agent believes stagingLands on staging,as the task asked.
Fig. 1.1The same 22-turn session, two interfaces. With history only, the one prod-eu switch on turn 9 gets buried under turns that say staging, the agent goes back to believing staging, and the write lands on production. With anchored state, every response restates the target, so the agent always sees where it really is, and it switches back to staging before it writes.

The gap between where the agent was and what it believed is the real failure. The Guide calls the divergence between what the agent believes and what is actually true world-model driftLexicon · 20World-Model DriftDivergence between the agent's internal beliefs and actual environment state.. Drift is silent while the agent is only reading. It turns into damage at the first write, because a write acts on the real world, whatever the agent pictures.

What it costs

Writes that land in the wrong place. The prod-instead-of-staging deploy is the famous version, but the pattern is everywhere: a commit on the wrong branch, a DROP TABLE in the wrong database, a refund from the wrong merchant account, a rm -rf build/ run after a cd the agent forgot about. These are the expensive mistakes, and they usually hit the environment you least wanted touched.

Turns spent re-checking. A careful agent, or one prompted to be careful, learns to distrust its memory. It calls get_current_target() before every action, or runs git branch and pwd every few turns. Each check is a full turn of latency and reasoning for a fact the previous response could have carried for a few tokens.

Supervision that eats the gain. After one production incident, the sensible reaction is to require human approval for every deploy the agent makes, or to give it staging credentials only. Both make sense. Both also remove most of the reason for having a deployment agent.

Incidents nobody can explain at first. Every tool call in the session succeeded. The error dashboards show nothing until the database refuses connections. The post-mortem ends up with an engineer reading 22 turns of trace to find the one line on turn 9 that explains everything.

The fix

In plain words: never make the agent remember state that the system already knows. Every response should carry three things.

  1. Ambient state. A small, fixed block with the current values of whatever decides where the next action lands: environment, branch, working directory, account, open transaction. It appears on every response, in the same place, with the current values.
  2. Post-conditions on writes. Every write says what changed, where, from what to what, and what happens next.
  3. Provenance on data. Any data that depends on state says which state produced it, such as which environment a report was measured on.

Here is the load-test report the agent read on turn 20, its last read before the write, in both forms.

Beforeget_load_report → 19 tok
{
  "report": "baseline-2", 1
  "p95_ms": 182,
  "errors": 0,
  "rps": 400
}
  1. 1The report is accurate and says nothing about where the agent is now. The last statement of the target is eleven turns back, in the middle of the session.
Tokens19
Turns since the target was last shown11 turns
Afterget_load_report → 60 tok
{
  "state": { 1
    "env": "prod-eu", 2
    "env_set_at": "turn 9",
    "protected": true, 3
    "local_changes": ["pool.yaml"]
  },
  "report": "baseline-2",
  "measured_on": "staging", 4
  "p95_ms": 182,
  "errors": 0,
  "rps": 400
}
  1. 1The state block repeats on every response, about 40 tokens each time. It is overwritten each turn, never appended, so it adds no history. The tensions below cover how to keep it small.
  2. 2The current target, and the turn that set it. Turn 9 is no longer buried in the middle: the fact it established is restated at the newest end of the ribbon.
  3. 3protected: true tells the agent the target is a production environment, before it does anything that changes it.
  4. 4The report names the environment it measured. Staging numbers next to a prod-eu target is a contradiction the agent can see and act on.
Tokens60
Turns since the target was last shown0 turns
Illustrative example

Pin 1 is the core of the fix, and its shape matters as much as its content. The block is a snapshot: the same keys, the same place, current values. A running log of every state change would put old values back on the ribbon and recreate the temporal vertigo it was meant to cure.

Pins 2 and 3 answer the question the agent was failing to ask. With env: prod-eu on every response since turn 9, the next thought, "apply the staging change," sits a few lines below a value that contradicts it. Pin 4 makes the contradiction explicit: staging numbers, prod-eu target.

The second half of the fix is on writes. Even with the state block in place, the response to a write is the last chance to catch a mistake before it spreads. Here is apply_config reporting its post-conditions:

{
  "status": "applied",
  "env": "prod-eu",
  "revision": "r118",
  "changed": { "db.pool_size": { "from": 20, "to": 40 } },
  "takes_effect": "on restart of 12 pods"
}

A bare "applied" asks the agent to trust that the write did what it meant. This response says where it went and what it did. An agent that reads "prod-eu" and "12 pods" here has one more turn to stop before the restart.

Where the state block applies

Any tool surface where actions depend on a mode, a location or a session has state worth anchoring. The block can come from each tool, or the harness can attach it to every response from one place. Either way, the agent sees the same fields every turn.

SurfaceState the agent tends to reconstructWhat to anchor
Deploy or cloud CLItarget environment, account, regionenv, account, region, protected
Shellworking directory, active virtualenvcwd, venv, last exit code
Gitbranch, uncommitted changesbranch, dirty, commits ahead of remote
Databasewhich database, open transactiondatabase, in_transaction, read_only
Browsercurrent page, signed-in userurl, user, open tabs count
Editor or filesopen buffers, unsaved editsopen_files, unsaved

Keep the block to fields that change during a session and change where actions land. The service name the agent was asked to work on doesn't belong there. The branch it is committing to does.

In MCP terms

If your deploy tools live in an MCP server, the protocol won't keep the agent's status bar for you. It gives you a typed slot for the state block and a way to point at live state. The block itself, and the post-conditions on writes, are yours to send.

  • Output schema (outputSchema). Declare the state object, with env, env_set_at, protected and local_changes, in the output schema of every tool, get_load_report included, and list it under required. Servers must return structured results that conform to the schema, so the block can't quietly drop off one tool.
  • Structured content (structuredContent) and text content (content). Return the state block in structuredContent. The spec asks tools that return structured content to also return the serialized JSON in a text block, for backwards compatibility, so the target shows up at the top of both, for example a first line of env=prod-eu protected=true.
  • Resource links (resource_link) and update notifications (notifications/resources/updated). apply_config can link to a resource for the live target, say deploy://payments-api/prod-eu, that the client can fetch or watch. When the target changes, the server sends an update notification for that URI.
  • Not in the protocol. Notifications reach the client, not the model, and carry only a URI. No field means "here is the world after your call." So apply_config itself has to answer with env, changed and takes_effect, as in the post-conditions above, and every other response has to restate env.

Spot it in your traces

Here are six of the session's 22 turns as a trace, renumbered T1 to T6. The prod-eu switch from turn 9 is T2. It was the only moment the agent could have caught the problem, and by the write it was far behind.

TraceA deployment agent raising a connection pool on staging
  1. T1
    set_target(env="staging")→ { "ok": true }Target set to staging, as the task asks.Correct first move. The confirmation says nothing about the new state, but the call itself is clear.
  2. T2
    set_target(env="prod-eu")→ { "ok": true }Check what production runs, so the test value is realistic.A reasonable read, done by switching the global target. Nothing after this turn mentions the switch again.
  3. T3
    get_config(service="payments-api", key="db.pool_size")→ { "value": 20 }Production uses 20 too. Back to the staging test.The agent's reasoning says it went back. No call switched the target back. World-model drift starts here.
  4. T4
    get_load_report(id="baseline-2")→ { "p95_ms": 182, "errors": 0, "rps": 400 }Staging baseline is healthy. Apply the new pool size.Eleven turns since the target was last stated. Nothing in the response contradicts the stale belief.
  5. T5
    apply_config(service="payments-api", file="pool.yaml")→ { "status": "applied", "revision": "r118" }Applied to staging. Restart to pick it up.A write with no post-conditions. The response never says where the config went.
  6. T6
    restart_service(service="payments-api")→ { "status": "rolling", "pods": 12 }Production restarts. The pod count was the only clue, and the agent had no reason to compare it with staging's two.

Every call in that trace succeeded. To find the same pattern in your own logs, look for these signals:

  • A state change far from the write it affects. Find every call that changes a mode or location (set_target, checkout, cd, use_database, switch_account). Count the turns until the next write, and check whether any response in between restated the new state. Long gaps with no restatement are where drift lives.
  • Reasoning that names a stale state. Search the agent's reasoning for environment, branch or directory names, and compare each mention with the most recent call that set that value. A thought that says "staging" after a switch to prod is drift caught in the act.
  • Frequent "where am I" calls. An agent that runs pwd, git status or get_current_target() before most actions is doing bookkeeping the interface should do for it. The calls are cheap individually and expensive in total turns.
  • Writes that don't name their target. List every tool that changes something and check whether its success response says where the change landed. {"status": "applied"} is a write the agent can't verify.
  • Numbers that don't fit the believed state. Pod counts, row counts, account balances or file paths that only make sense in a different environment. If the trace shows them and the agent kept going, nothing made the mismatch stand out.

Review checklist

Run these against any tool surface where actions depend on a mode, location or session. Each check takes a call or two and works as a pull request template for new tools.

Review checklist · 6 items
  1. Attach a state block with the current target, location or mode to every response, in the same place and with the same keys.How to check Call three different tools in a row. Each response should include the same state keys, such as env, branch or cwd, with current values.
  2. Overwrite the state block each turn instead of appending a history of changes.How to check Change the target twice, then make any call. The state block should show only the current value, not a list of past ones.
  3. Make every write report its post-conditions: where it landed, what changed from what to what, and what happens next.How to check Run a write against a test environment. The response should name the environment and show old and new values, not only "status": "ok".
  4. Label data with the state that produced it.How to check Fetch a report or query result, then switch the target. The earlier result should say which environment or branch it came from, so it can't be mistaken for the new one.
  5. Mark protected or production targets in the state block.How to check Switch to a production target and make any read. The state block should flag it, for example protected: true.
  6. Keep the state block under about 50 tokens and limited to fields that change during a session.How to check Count the block's characters and divide by four. Remove any field that never changes within a session.

When laws collide

A state block repeats on every response, so it competes with laws that guard the context window, and it pairs naturally with laws that keep state honest.

  • Where they clash
    Token Hygiene asks every response to carry only what helps the next decision. A 40-token state block on every response of a 60-turn session adds about 2,400 tokens, and on most of those turns the state didn't change.
    How to have both
    Keep the block small, fixed and overwritten, with only fields that decide where actions land. On a turn where nothing changed, a one-line form such as env=prod-eu branch=pool-40 is enough. Spend the full block, plus protected flags, when state changed or a write is next.
  • How they combine
    This heuristic keeps the current state visible at the newest end of the ribbon. Freshness & Context Half-Life marks older observations as stale or superseded, such as the turn-2 confirmation of staging.
    What you get
    Together they close both sides of temporal vertigo: the live value is always present, and the stale one is labelled as old. The agent no longer has to judge which of two true-looking statements is current.
  • Works with · H-10Poka-Yoke Boundaries
    How they combine
    Anchoring shows the agent where it is. Poka-Yoke Boundaries lets a write state where it expects to be, for example apply_config(..., expect_env="staging"), and refuses to run when the two disagree.
    What you get
    The state block prevents most wrong-target writes, and the precondition stops the rest before they reach production. An agent that ignored the block still gets a refusal that names the real target.

How much anchoring a surface needs depends on who uses it. The Guide treats the model as the user persona: family, size and training decide how a given interface lands, an idea it calls Persona = ModelLexicon · 12Persona = ModelTreating model family, scale and training as the user persona.. A large model in a short session may track a target switch on its own. A small, fast model in a 60-turn session will lose it. The state block costs both of them a few tokens and protects both from the same incident.

Terms from this page

081D Temporal Ribbon
The linear token stream through which an agent perceives reality.
17Temporal Vertigo
Disorientation from stale past states coexisting beside live state.
14Attention Geometry
Positional layout of information across primacy, middle and recency zones.
20World-Model Drift
Divergence between the agent's internal beliefs and actual environment state.
12Persona = Model
Treating model family, scale and training as the user persona.
esc

Try “tokens”, “errors”, “stale”, “handoff” or “blast radius”.