Skip to content
AI.info

AI agents

Environment, Observation, State, and Action

Define the environment interface that determines what an agent can observe, remember, and change.

By the end you can

An observation is a reading that may already be stale

An agent acts inside an environment whose relevant state may be only partially observable. Observations are time-stamped views, not the world itself. Actions may succeed, fail, or change state in ways the model did not predict.

That is not a house opinion about agent design. It is a formalism, and it has been on the record since 1998. Kaelbling and two colleagues stated the whole problem in two sentences in Artificial Intelligence: “A POMDP is an MDP in which the agent is unable to observe the current state. Instead, it makes an observation based on the action and resulting state.”

The pieces have names. A POMDP is the tuple (S, A, T, R, Omega, O): an MDP plus a finite set of observations Omega, and an observation function O: S x A -> Pi(Omega). The agent itself splits in two. A state estimator (SE) updates a belief state from the last action, the current observation and the previous belief. A policy maps belief states to actions, never world states. Every runtime that reads a tool response and writes it into memory is implementing SE. Most of them never called it that.

The runtime should therefore define observation sources, freshness, identity, action preconditions, and postconditions. Otherwise the model must infer system semantics from prose and inconsistent tool outputs. A reading taken at one moment is not the world. By the time the agent acts on it, the world may have moved.

Leave preconditions and postconditions unstated and the model reconstructs your system’s semantics from prose. Every gap returns later dressed as a reasoning failure.

Case

OSWorld: 369 tasks, 72.36 percent human, 12.24 percent best model

OSWorld puts a number on that distance. It runs “369 computer tasks” across “Ubuntu, Windows, and macOS”. Each task is scored by executing a check against the resulting machine state, not by reading the transcript. The 2024 paper reports that “humans can accomplish over 72.36% of the tasks, [while] the best model achieves only 12.24% success”, with models “primarily struggling with GUI grounding and operational knowledge”. Converted to counts, that is about 267 tasks of 369 for people and about 45 for the model. At least 60.12 points of gap, and at least 5.9 times — both minima, because the human figure is a floor.

The gap is not a quirk of the desktop. WebArena reproduces it on the web. In 2023 its authors released “a ready-to-use benchmark with 812 long-horizon web-based tasks” across four self-hosted functional websites. Scoring again ignores the action transcript and asks for “the functional correctness of these tasks, i.e., does the result of the execution actually achieve the desired goal”. The abstract: “The results demonstrate that solving complex tasks is challenging: our best GPT-4-based agent only achieves an end-to-end task success rate of 14.41%, significantly lower than the human performance of 78.24%.” A gap of 63.83 points, and a ratio of about 5.4x.

Two independent environments, one desktop and one web. 369 tasks and 812 tasks. Both scored on end state rather than on what the agent said it did, and both showing the same shape. The model can produce a plausible sequence of actions and still leave the world in the wrong condition. What collapses is not eloquence. It is the loop from observation to state to action.

Figure

OSWorld's 369 real computer tasks: people finish over 72.36 percent of them, the best model in the 2024 paper 12.24 percent — about 267 tasks against about 45.

Comparison

Where designs for environment modeling diverge

Most interfaces an agent meets are partially observable, and some are adversarial. Designs are usually drawn as though every interface were fully observable. Partially observable means the agent sees a slice, and cannot tell which parts it is missing. A design handles that well when state updates are based on observed postconditions rather than model assumptions. It handles it badly when the runtime forgets that a tool response is evidence with provenance, not unquestionable truth, and writes whatever came back straight into state.

The third column is the one usually asserted and rarely measured. It has been measured. AgentDojo, published in 2024, evaluates agents executing tools over untrusted data: 97 realistic user tasks across banking, Slack, workspace and travel environments, and 629 security test cases. Its abstract names the channel exactly: “AI agents are vulnerable to prompt injection attacks where data returned by external tools hijacks the agent to execute malicious tasks.”

Read that sentence next to the middle column and the two collapse into one problem. The attack does not arrive in the user's instruction. It arrives inside the observation the runtime was about to trust. An adversarial environment is a partially observable one in which the missing slice was chosen by someone else.

FigureComparison · 3 columns

Fully observable interface

The runtime exposes all relevant state before each choice.

  • Simpler reasoning
  • Rare in real products
  • Still needs freshness checks

Partially observable interface

The agent sees incomplete or delayed evidence.

  • Common in APIs and GUIs
  • Requires belief or uncertainty
  • Clarification may be necessary

Adversarial observation

External content may contain manipulation or false state.

  • Typical of web and email
  • Needs trust boundaries
  • Cannot be solved by prompting alone

Visual

Trace the chain backwards from the wrong action

Environment state becomes an observation. The observation becomes internal state. Internal state becomes an action. That chain is the one to trace, and four of its five nodes already have names from the 1998 formalism. The environment states are S. The observations are Omega. The channel between them is the observation function O: S x A -> Pi(Omega). The node drawn here as "Internal state" is the belief state, maintained by the state estimator (SE) from the last action, the current observation and the previous belief. The policy consumes that belief state, not the world.

That matters for debugging. Because the policy is a function of the belief state, a wrong action has exactly four possible origins along the chain: the policy, the belief the state estimator built, the observation the belief was built from, or a world that changed after the reading was taken. Whoever owns the action should not also own the transition evidence. Trace the chain backwards when something goes wrong. Stop at the first node whose input you cannot reconstruct.

FigureProcess · 5 steps
  1. 1

    Environment state

    The external facts and resources that matter to the task.

  2. 2

    Observation

    A partial, delayed, or filtered view exposed to the agent.

  3. 3

    Internal state

    The task ledger, plan, memory, and pending commitments.

  4. 4

    Action

    A typed request that can alter the environment.

  5. 5

    Transition evidence

    The observed result used to update the next decision.

Key idea

A tool response is evidence with provenance, not unquestionable truth

Different services may disagree because of caching, eventual consistency, permissions, or attacks. Two of them can both be telling the truth about different moments. That is not sloppy engineering. It is a proved impossibility. Gilbert and Lynch opened their 2002 paper with the verdict: “When designing distributed web services, there are three properties that are commonly desired: consistency, availability, and partition tolerance. It is impossible to achieve all three.” Their Theorem 1 is the formal version: “It is impossible in the asynchronous network model to implement a read/write data object that guarantees the following properties: Availability, Atomic consistency, in all fair executions (including those in which messages are lost).” A system that keeps answering during a partition must sometimes answer from a state that has already moved.

So the disagreement will arrive. What matters is whether the runtime acts on one channel without reconciling it. The most documented case of a machine doing exactly that is not an agent at all. Two sensors on Lion Air flight 610 disagreed for the whole flight. The National Transportation Safety Board recorded it in 2019, in report ASR-19-01: “The airplane’s digital flight data recorder (DFDR) recorded a difference between the left and right angle of attack (AOA) sensors that was present during the entire accident flight; the left AOA sensor was indicating about 20° higher than the right AOA sensor.” Those readings drove the automation. The report states that “these erroneous AOA sensor inputs resulted in the MCAS activating on the accident flights”. Lion Air flight 610 went down on 29 October 2018, 189 dead. Ethiopian Airlines flight 302 followed on 10 March 2019, its left sensor reading about 59 degrees higher than the right. The board issued seven recommendations to the FAA about the assumptions behind that design, A-19-10 through A-19-16.

Two channels disagreed for an entire flight. The automation read one of them and acted, repeatedly. Attach source, timestamp, confidence, and trust level to observations. Verify critical transitions with an independent read.

An agent that cannot say when it learned something will keep planning confidently against a world that has already moved.

Steps

Specify an agent environment contract

Specify the environment contract for one workflow already in service: observation sources, freshness, identity, preconditions, postconditions. Writing it down usually reveals how much the design trusts what a tool reports on sight. It also leaves a record of which state changes the runtime confirms by looking at the environment afterwards, instead of assuming they happened.

The step "Define action schemas" does not require inventing a notation. HTTP already has one. RFC 9110, published in 2022, defines the If-Match header field. It makes a request conditional on the target resource currently carrying an entity tag that matches one supplied by the client, compared with the strong comparison function. The spec explains why it exists: “If-Match is most often used with state-changing methods (e.g., POST, PUT, DELETE) to prevent accidental overwrites when multiple user agents might be acting in parallel on the same resource (i.e., to prevent the "lost update" problem).” The enforcement is not advisory. An origin server “MUST NOT perform the requested method if the condition evaluates to false”, and may answer 412 (Precondition Failed).

The step "Model uncertain transitions" has a specification too. The same standard makes PUT, DELETE and the safe methods idempotent, for precisely the case where the agent never learned what happened: “Idempotent methods are distinguished because the request can be repeated automatically if a communication failure occurs before the client is able to read the server's response.” MDN puts the same rule in one line: “A client can safely retry a request that uses an idempotent method, for example, in cases where there is doubt as to whether the request reached the server.” The converse is the trap the practice step exists to surface. “A proxy MUST NOT automatically retry non-idempotent requests”, and a client should not either, unless it has some means to know the semantics are idempotent, “or some means to detect that the original request was never applied”.

That last clause is the whole of "Choose verification reads", written by a standards body in 2022. An action whose outcome you cannot re-read is an action you cannot retry.

FigureProcess · 5 steps
  1. 1

    Enumerate state variables

    Name the external facts required for safe decisions.

  2. 2

    Describe observation channels

    Record freshness, trust, latency, and possible missingness.

  3. 3

    Define action schemas

    State preconditions, side effects, and expected postconditions.

  4. 4

    Model uncertain transitions

    List ways an action can partially succeed or complete asynchronously.

  5. 5

    Choose verification reads

    Identify independent checks for material state changes.

Example

A measurement set for environment modeling

Start by measuring how often a state change is written from an observed postcondition rather than from what the model assumed would happen. τ-bench, published in 2024, builds that discipline into the scoring itself: “We employ an efficient and faithful evaluation process that compares the database state at the end of a conversation with the annotated goal state.” The end state, not the agent's account of it.

τ-bench also supplies the number behind the phrase "only counts under repeated cases". It introduces pass^k, the rate at which an agent succeeds on all k independent trials of the same task. State-of-the-art function-calling agents such as gpt-4o “succeed on <50% of the tasks, and are quite inconsistent (pass^8 <25% in retail)”. A design that passes once and is scored once has not been measured. Halving again across eight repeats is what the second number means.

Track separately whether conflicting observations remain visible until reconciled. Two more measures — that every action declares which state version or resource identity it targets, and that the runtime can distinguish stale data from a genuine failure — count only once they hold under repeated or adversarial cases.

  • Signal 1: State updates are based on observed postconditions rather than model assumptions — the τ-bench standard, which “compares the database state at the end of a conversation with the annotated goal state” rather than the transcript.
  • Signal 2: Conflicting observations remain visible until reconciled — the failure ASR-19-01 records, where the left AOA sensor read about 20° higher than the right for an entire flight and the automation still acted on one channel.
  • Signal 3: Every action declares which state version or resource identity it targets — RFC 9110 section 13.1.1 gives the mechanism: an If-Match entity tag under the strong comparison function, and 412 (Precondition Failed) when it no longer matches.
  • Signal 4: The runtime can distinguish stale data from a genuine failure — RFC 9110 section 9.2.2 supplies idempotence for the retry, and section 13.1.1 covers the case where the change “has already succeeded, but the user agent might not be aware of it, perhaps because the prior response was lost”.

Prompt rewrites are cheaper than fixing what the agent may touch

The environment contract is often more important than the prompt. It determines what the model can know, and which mistakes the runtime can prevent. Most of it has already been written down by other people, as the last three sections show: the belief state in 1998, the entity tag and the idempotent retry in RFC 9110, the disagreement itself in Gilbert and Lynch's impossibility proof.

An audit starts with the tool responses. Where they came from, how much weight the design puts on them, and whether anything checked them. It then follows each recorded state change back to the observation that justified it, rather than to the step the model expected to succeed. Where that trace ends in an assumption instead of a reading, you have found the thing that no prompt will fix.

Prompt rewrites are cheap and visible, which is why teams keep making them instead of fixing what the agent is allowed to see and touch.

Key takeaways