arXiv · 2026UMass Amherst · Adobe Research

Learning Compact State Abstractions for LLM Agents

1 University of Massachusetts Amherst  ·  2 Adobe Research
\(s_t = \phi(s_{t-1},\, o_t,\, a_{t-1})\)

What does an LLM agent actually need to remember? Instead of feeding the agent its whole history, we learn a small Python program \(\phi\) that keeps a compact, readable state. It runs without any extra model calls, and the agent stays just as successful.

−71%
policy input tokens, best ALFWorld family
−57%
policy input tokens, best ScienceWorld family
−95%
policy input tokens on long-horizon BabyAI
+1.7 pp
success vs. full history, 95% CI [−1.8, +5.3]

The idea

History is not state

A ReAct-style agent appends every observation and action to its prompt. That is sufficient by construction, but most of it stops mattering: the rooms already searched, the drawer that was empty, the step that failed. We ask what the agent actually needs to carry forward, and learn a program that keeps only that.

Read the abstract

LLM agents commonly use the full interaction history as a proxy for state, retaining all past observations and actions regardless of whether they remain relevant. We instead ask what information an agent actually needs to carry forward. We define agent state as a compact abstraction of interaction history that preserves the competence of a fixed reference agent, with the minimal such abstraction as the ideal. Because matching the reference agent's behavior is unnecessarily restrictive and difficult for black-box policies, we define sufficiency through task performance rather than behavior matching. We represent state abstractions as deterministic recursive programs and search over them using an LLM-guided genetic algorithm. Across ALFWorld and ScienceWorld, the learned abstractions preserve near-reference task success while reducing mean policy input by up to 71% and 57%, respectively. The resulting programs are directly inspectable, providing an explicit account of what information is retained, updated, and discarded during interaction.

ALFWorld · Pick & Place · task: put a mug in desk
Full historypolicy sees \(c_t = (o_1, a_1, \dots, o_t)\)
policy input0 tok
Learned statepolicy sees \(s_t = \phi(s_{t-1}, o_t, a_{t-1})\)
policy input0 tok
step 0 / 8

An illustrative episode. The state fields follow the learned Pick & Place program shown below. Token counts are rough (about four characters per token) and leave out the agent's reasoning, which full history would also keep. \(\phi\) reads the new observation and action, updates its fields, and throws the raw text away: once the mug is found, the search frontier is cleared.

Formulation

Keep the agent competent, not identical

The policy \(\pi\) is a fixed black-box LLM. The only thing we learn is the abstraction \(\phi\), which updates the state recursively, starting from \(s_0 = \varnothing\). The update has to be recursive: computing the state from the whole history would mean keeping the history.

Animation: (a) the full-history agent's context grows by one observation and action every step; (b) the recursive agent passes each new observation through phi into the next state, drops the raw text, and the policy sees only the latest state.
(a) A standard agent conditions on the growing context \(c_t\). (b) The abstracted agent folds each new action and observation into \(s_t\) with \(\phi\), drops the raw text, and the policy sees only \(s_t\).

An agent state is a compact abstraction of the interaction history that preserves the performance of a reference agent acting on the full history. An ideal agent state is the minimal such abstraction.

Objective
\[\max_{\phi}\; J(\pi\circ\phi) - \lambda\, T(\phi) \quad \text{s.t.}\quad J(\pi\circ\phi) \ge (1-\epsilon)\, J(\pi_{\text{full}}),\;\; T(\phi) < T(\phi_{\text{naive}})\]
\(J\) is expected task success and \(T\) is mean policy input tokens. \(\pi\circ\phi\) is the agent that maintains \(s_t\) with \(\phi\) and acts with \(\pi(\cdot \mid s_t)\). \(\pi_{\text{full}}\) is the same policy conditioned on the full history, and \(\phi_{\text{naive}}\) is the starting program that simply concatenates history. The constraint stops the search from buying compactness with lost success (we use \(\epsilon = 0.10\)). \(\lambda\) then pushes toward smaller states among the feasible ones. Because \(\phi\) acts inside the interaction loop and is scored only by trajectory return, this has the structure of an RL problem in which the policy is frozen and the state representation is what gets learned.
Why not match behavior?
Here \(J(\cdot)\) is expected task success, \(\pi_{\text{full}}\) is the policy acting on the full history \(h_t\), and \(\pi\circ\phi\) is the same policy acting on the state \(s_t\) that \(\phi\) computes. Behavior matching would require the two agents to choose actions with nearly the same probabilities at every step. It measures the gap with the cumulative total-variation distance \(B(\phi)\), taken over the histories that \(\pi\circ\phi\) actually visits:
\[B(\phi) = \sum_{t=1}^{H} \mathbb{E}_{h_t \sim d_t^{\pi\circ\phi}} \Big[ \mathrm{TV}\big( \pi_{\text{full}}(\cdot \mid h_t),\; \pi(\cdot \mid s_t) \big) \Big]\]
Performance matching asks only that the success gap \(|J(\pi_{\text{full}}) - J(\pi\circ\phi)|\) be small. Our criterion asks only that success not drop, which constrains the signed gap \(J(\pi_{\text{full}}) - J(\pi\circ\phi)\). With a binary success signal at the end of a horizon-\(H\) episode, the three gaps are ordered:
\[\underbrace{J(\pi_{\text{full}}) - J(\pi\circ\phi)}_{\text{ours (signed)}} \;\le\; \underbrace{\big|J(\pi_{\text{full}}) - J(\pi\circ\phi)\big|}_{\text{performance matching}} \;\le\; \underbrace{B(\phi)}_{\text{behavior matching}}\]
Ours: success may not drop Performance matching Behavior matching
Many tasks have several successful trajectories, and a black-box LLM's action distribution is hard to match anyway. Because of this ordering, any \(\phi\) that satisfies a tolerance \(\delta\) under behavior matching also satisfies it under performance matching and under our criterion. So the feasible sets nest as in the diagram. Constraining only the drop in success gives the largest set, so it admits the most compact states. It also allows abstractions that change behavior or even improve success.
Why programs?
  • Expressive. \(\phi\) is a general-purpose program, so in principle it can implement any computable state update, using arbitrary control flow, data structures, libraries and tools.
  • Matches the job. Keeping state is mostly structured bookkeeping: parse an observation, update a record, flip a flag, and drop the text once it has been absorbed. Machine-generated observations such as simulator text, HTML pages and API responses can be parsed directly.
  • Free at deployment. A Python update adds no model calls per step. For free-form text, \(\phi\) could call a language model to extract what the state needs. That trades away some of the zero-inference cost for broader coverage.
  • Deterministic. Once the raw history is discarded, a random error at one step would carry into every later state. All the programs in our experiments are deterministic, which removes that source of compounding error.
  • Readable. Unlike the hidden state of a recurrent network, the learned state is a set of named variables with explicit update rules: a readable hypothesis about what information the agent needs.

Result 1 · Held-out tasks

Much smaller inputs, success near the reference

Each task family gets its own \(\phi\), learned on training instances and evaluated on held-out ones. The policy is GPT-5.6 Luna in a ReAct scaffold. Baselines are a fixed LLM summarizer and ACON, which learns compression guidelines. Both baselines call an LLM at run time to write summaries, and their token counts exclude those calls. \(\phi\) is plain Python.

Result 2 · Longer horizons

Full history grows every step; the state levels off

On BabyAI GoTo (3×3 rooms, 576-step cap), full history reaches 27.5k tokens per call by the step cap. \(\phi\) levels off at about 250 tokens from step 25 onward, tracking heading and position by dead reckoning and remembering where the target was last seen. Over a full episode that is 29× fewer input tokens, and the difference in success is not significant (exact McNemar, p = 0.18).

BabyAI GoTo · tokens per policy call (log scale)

Full history\(\phi\)

Tokens added per step (held-out slope)

Full history\(\phi\)

On ALFWorld and ScienceWorld, full history adds 24–36 tokens per step in every family. \(\phi\) adds far fewer, except on Two Objects and Forces, where the learned \(\phi\) is itself a bounded recent history.

Result 3 · Is it real?

Three runs, unseen rooms, a different model

LLM policies sample their responses, so one run can mislead. We re-ran \(\phi\), full history and a token-matched recent-history window three times on all 254 held-out instances.

\(\phi\) − full history
+1.7 pp

95% CI [−1.8, +5.3]. No systematic difference, and the sign holds in every run (+0.4 to +3.5 pp).

\(\phi\) − last-k window
+10.0 pp

95% CI [+5.9, +13.9], with a window matched to \(\phi\)'s length. Up to +25.5 pp on Pick & Place.

Run-to-run std
0.7 pp

The lowest of the three methods (full history 1.0, window 1.8).

Success over three runs (mean ± std)

Full history\(\phi\)Last-k window

Unseen ALFWorld rooms

Splitn\(\phi\) − full95% CI
Seen68+1.5 pp[−4.4, +7.4]
Unseen134−1.5 pp[−7.5, +4.5]

\(\phi\) scores 0.81 on seen rooms and 0.86 on unseen ones: no sign of overfitting.

Swap the policy: Qwen-3.5-397B

We ran each \(\phi\) learned with GPT-5.6 Luna, unchanged, with Qwen-3.5-397B. The pooled ALFWorld difference from Qwen with full history is −1.5 pp (95% CI [−5.9, +2.5], n = 202), with token reductions of up to 69%. Transfer is not guaranteed, because sufficiency is defined relative to a policy. When you switch agents, the intended use is to re-run the search.

Result 4 · What the state contains

Each program is a readable hypothesis about what matters

Across families, the programs turn raw text into persistent variables and discard observations once they have been absorbed. What they keep depends heavily on the task. ALFWorld programs recover navigation, search, object and transformation state. ScienceWorld programs also need entity resolution, relations, device settings and process variables. Where token savings were small, the search settled on a bounded recent history.

Persistent information retained

Excerpt of the final learned \(\phi\). Normalization and boilerplate are omitted.

Hide one field group from the policy (change in success, 95% CI)

To find out which fields the policy actually needs, we hide one group at a time. \(\phi\) keeps updating its full state, and only the policy's copy is masked. Seven of the eight groups matter, and every one of those confidence intervals excludes zero.

The agent can depend on fields it never mentions. On Clean & Place, hiding the flags that record which objects are already clean drops success from 0.73 to 0.04: the agent finds the object, then keeps cleaning it until it runs out of steps. Hiding the goal has no effect, because the task prompt already states it.

Use the results

Every number on this page, as CSV

Each table is available for download so you can compare against it, re-plot it or check it. Success is the fraction of held-out episodes solved. Tokens are mean policy input tokens per step.

Search cost. All ten searches together used 860 meta-LLM calls (17.7M tokens) and 5,948 environment rollouts. This is a one-time cost per task family, and the resulting program runs for free at deployment.

Limits. We find compact, sufficient states within a restricted program class. We do not certify minimality. The achievable reduction varies a lot by family: Two Objects and Forces stay close to bounded histories, and Forces ends up slightly larger than full history.

Citation

BibTeX

@article{chittepu2026compact,
  title   = {Learning Compact State Abstractions for {LLM} Agents},
  author  = {Chittepu, Yaswanth and Addanki, Raghavendra and Rao, Anup
             and Kveton, Branislav and Niekum, Scott},
  journal = {arXiv preprint arXiv:2611.31800},
  year    = {2026}
}