Abstract
Embodied agents using Large Language Models (LLMs) often struggle with the high computational cost and data requirements of processing long textual environment descriptions. We present diff history, a simple yet effective method that represents environment state changes using the standard Unix diff command. By providing the agent with an initial full-text observation followed by a sequence of symbolic "deltas," we significantly reduce input redundancy and enhance the learning signal. Our approach allows a GPT-2 (124M) agent to match state-of-the-art performance on the complex NetHack environment while requiring 1800x fewer training examples than previous vision-based methods.
Introduction
Building agents that can perceive and act within complex environments is a central goal of AI research. When using LLMs as the core reasoning engine, environments are typically converted into text descriptions. However, this approach faces two major hurdles: extreme redundancy and high data hunger. In many environments, a single action only changes a small fraction of the state, yet standard agents re-process the entire description at every step. This wastes the model's context window and obscures the causal link between actions and specific state changes.
Methods: The diff Approach
The proposed diff history method draws inspiration from software version control. Instead of a full-text history, the agent's prompt consists of an "anchor" (the first full observation) followed by a series of "deltas" generated by the Unix diff utility. These deltas highlight exactly which lines were added or removed in the environment description.
This representation is task-agnostic and purely symbolic, requiring no manual prompt engineering or domain-specific feature extraction. It naturally focuses the model's attention on salient changes, such as movement or item acquisition.
Datasets
The method was evaluated on two benchmarks:
- BabyAI-Text: A grid-world environment for testing instruction following.
- LangHack: A new dataset derived from NetHack, featuring 500,000 gameplay chunks generated by a high-performing symbolic bot (
AutoAscend) and converted into text.
Key Results
The diff history approach yields substantial improvements in both efficiency and performance:
- Sample Efficiency: On the NetHack challenge, the
diff historyagent matched the performance of top neural agents while using 1800x less training data. - Context Compression: In high-dimensional environments like NetHack,
diff historyreduced the average token count per observation by 460%, effectively extending the agent's functional memory within a fixed context window. - Learning Signal Density: Even in simpler environments like BabyAI-Text, where the
diffformat might occasionally increase token counts, it provided a 25% improvement in instruction finetuning efficiency. This suggests that the+and-notation provides a clearer causal signal for the model to learn the relationship between actions and outcomes. - Ablation Study: Removing the
diffobservations and reverting to full-text history resulted in a 98% drop in NetHack scores, underscoring the necessity of the delta representation.
Conclusion
diff history demonstrates that simple symbolic abstractions can dramatically improve the efficiency of LLM agents. By focusing on changes rather than static states, agents can learn more from less data and handle longer histories. Future research will explore applying this "delta-based" logic to unstructured text and multimodal inputs like video or sensor data, as well as integrating it with explicit planning mechanisms to handle long-term goals.
Summary updated