TL;DR
The paper introduces Object-Centric Environment Modeling (OCM), a framework that structures an LLM agent's accumulated experience into an executable, two-part Python codebase consisting of object definitions and procedural interaction patterns. By enforcing execution-based verification and utilizing progressive knowledge disclosure, OCM allows agents to continually learn and act reliably in complex environments without suffering from memory bloat or logical inconsistencies.
What Problem Does This Paper Address?
Large Language Model (LLM) agents can improve over time by reflecting on past experiences, but traditional memory mechanisms usually save these insights as free-form natural language text or isolated action scripts. As an agent accumulates hundreds of experiences, textual memory streams become redundant, stale, and difficult to validate. This often leads to "memory corruption," where errors propagate and cause the agent to attempt invalid actions.
On the other hand, existing symbolic approaches fall into two extreme camps: they either learn highly localized skills that lack a shared understanding of the environment's underlying rules, or they attempt to build massive, monolithic world models that simulate every single state transition—a feat that is computationally impractical for complex tasks.
OCM targets the missing middle ground: organizing an agent's memory around persistent environment entities (objects) and their mechanisms, ensuring that procedural skills remain grounded and logically consistent.
Methods
OCM splits the agent's environment model into two interconnected codebases:
- Object Knowledge ($K_o$): Python classes that define environment entities, their observable states, affordances, constraints, and transition mechanisms (e.g., a
Containerclass that tracks whether it is open or closed). - Procedure Knowledge ($K_p$): Executable Python files recording specific interaction patterns or experiential rules (e.g., how to handle a specific recipe). Crucially, these files must import and use the classes defined in the object knowledge base.
The framework operates in a closed learning loop consisting of three main phases:
- Object-Centric Reflection: After an episode, the agent reviews the trajectory and generates a structured JSON plan detailing what object mechanisms or procedural rules need to be created or updated.
- Knowledge Update & Verification: The agent generates concrete Python code based on the plan. Before committing the new code to the codebase, OCM runs an automated verification step: it executes all procedure files against the updated object model. If any script throws an error, the update is rejected and sent back for repairs.
- Progressive Knowledge Disclosure: To prevent the LLM's context window from being overwhelmed by code during future tasks, OCM initially exposes only compact code signatures and indexes. The agent can then issue internal
Inspect[...]commands to selectively read the full source code of specific classes or procedures only when needed.
Datasets
The authors evaluated OCM in an online learning setting across three distinct interactive text-based benchmarks:
- ScienceWorld: A complex environment testing grounded scientific reasoning across 30 task categories (e.g., thermodynamics, material changes).
- ALFWorld: A benchmark focused on embodied household interactions and high-level routines.
- PlanCraft: A structured crafting environment based on Minecraft-like recipe dependencies, testing intermediate state transformations.
Key Insights and Ideas
- Code as a Substrate for Memory: Representing memory as executable code rather than text allows the agent to use standard programming invariants (like compilation and execution checks) to audit its own experience.
- The Power of the Invariant: By forcing procedures to import object classes, the agent cannot easily hallucinate impossible actions. If an object's affordance changes, the verification step immediately catches any broken procedures.
- Separating "What It Is" from "How To Use It": Splitting knowledge into object properties ($K_o$) and procedural workflows ($K_p$) mirrors classic object-oriented programming, making the agent's learned knowledge highly modular and reusable across completely different tasks.
Key Results
OCM achieved the best average rank (1.75) across all three benchmarks, outperforming strong baselines including ReAct, Reflexion, ExpeL, and specialized symbolic agents like WorldCoder and Wall-E.
- ScienceWorld: OCM achieved the highest success rate (34.8%) and average reward (57.7) while maintaining a competitive step count.
- PlanCraft: OCM excelled at tracking intermediate dependencies, achieving a 49.6% overall success rate, with notable performance boosts on "Medium" difficulty tasks (55.0% vs. the next best baseline at 40.0%).
- Action Feasibility: OCM dramatically reduced the number of invalid actions rejected by the environment. On ScienceWorld, OCM averaged just 4.0 invalid actions per task compared to ReAct's 12.3 and WorldCoder's 17.5. On PlanCraft, OCM achieved an invalid action count of essentially 0.0.
Limitations and Future Work
- Text-Based Focus: The current implementation relies on text-based environments with relatively stable object types and action interfaces. Extending OCM to open-ended, multimodal, or continuous environments where object boundaries are fuzzy remains an open challenge.
- Syntactic vs. Semantic Verification: The verification step ensures that code is executable and internally consistent, but it cannot formally guarantee that the code accurately reflects the true physics or semantics of the environment.
- Computational Overhead: The framework requires additional LLM calls for the post-episode reflection, code generation, and occasional internal inspection steps, which increases overall token consumption and latency.
Summary updated