Lune

NeurIPS2024Top-tier venue

WorldCoder, a Model-Based LLM Agent: Building World Models by Writing Code and Interacting with the Environment

Hao Tang, Darren Key, Kevin Ellis

Abstract

We give a model-based agent that builds a Python program representing its knowledge of the world based on its interactions with the environment. The world model tries to explain its interactions, while also being optimistic about what reward it can achieve. We define this optimism as a logical constraint between a program and a planner. We study our agent on gridworlds, and on task planning, finding our approach is more sample-efficient compared to deep RL, more compute-efficient compared to ReAct-style agents, and that it can transfer its knowledge across environments by editing its code.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

26 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • PoE-World: Compositional World Modeling with Products of Programmatic Experts cites Generating Code World Models with Large Language Models Guided by Monte Carlo Tree Search
  • PoE-World: Compositional World Modeling with Products of Programmatic Experts cites Code Repair with LLMs gives an Exploration-Exploitation Tradeoff
  • Generating Code World Models with Large Language Models Guided by Monte Carlo Tree Search cites Mastering Atari with Discrete World Models
  • Generating Code World Models with Large Language Models Guided by Monte Carlo Tree Search cites Code Repair with LLMs gives an Exploration-Exploitation Tradeoff
  • Code Repair with LLMs gives an Exploration-Exploitation Tradeoff cites Teaching Large Language Models to Self-Debug
  • Code World Models for General Game Playing cites Generating Code World Models with Large Language Models Guided by Monte Carlo Tree Search
  • Code World Models for General Game Playing cites Code Repair with LLMs gives an Exploration-Exploitation Tradeoff
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers26

  1. Code Repair with LLMs gives an Exploration-Exploitation TradeoffHao Tang, Keya Hu, Jin Zhou, Sicheng Zhong et al.NeurIPS 2024 · 85 citations
  2. Generating Code World Models with Large Language Models Guided by Monte Carlo Tree SearchNicola Dainese, Matteo Merler, Minttu Alakuijala, Pekka MarttinenNeurIPS 2024 · 49 citations
  3. PoE-World: Compositional World Modeling with Products of Programmatic ExpertsTop Piriyakulkij, Yichao Liang, Hao Tang, Adrian Weller et al.NeurIPS 2025 · 31 citations
  4. Code World Models for General Game PlayingWolfgang Lehrach, Daniel Hennes, Miguel Lazaro-Gredilla, Xinghua Lou et al.ICLR 2026 · 27 citations
  5. Agent World Model: Infinity Synthetic Environments for Agentic Reinforcement LearningZhaoyang Wang, Canwen Xu, Boyi Liu, Yite Wang et al.ICML 2026 · 25 citations

Builds on31

  1. Mastering Atari with Discrete World ModelsDanijar Hafner, Timothy P. Lillicrap, Mohammad Norouzi, Jimmy BaICLR 2021 · 1,170 citations
  2. Teaching Large Language Models to Self-DebugXinyun Chen, Maxwell Lin, Nathanael Schärli, Denny ZhouICLR 2024 · 1,085 citations
  3. ALFWorld: Aligning Text and Embodied Environments for Interactive LearningMohit Shridhar, Xingdi Yuan, Marc-Alexandre Côté, Yonatan Bisk et al.ICLR 2021 · 819 citations
  4. On the Planning Abilities of Large Language Models - A Critical InvestigationKarthik Valmeekam, Matthew Marquez, Sarath Sreedharan, Subbarao KambhampatiNeurIPS 2023 · 509 citations
  5. Large Language Models as Commonsense Knowledge for Large-Scale Task PlanningZirui Zhao, Wee Sun Lee, David HsuNeurIPS 2023 · 423 citations

Related papers

  1. Reader: Model-based language-instructed reinforcement learningNicola Dainese, Pekka Marttinen, Alexander IlinEMNLP 2023 · 1 citation
  2. RLang: A Declarative Language for Describing Partial World Knowledge to Reinforcement Learning AgentsRafael Rodríguez-Sánchez, Benjamin Adin Spiegel, Jennifer Wang, Roma Patel et al.ICML 2023 · 4 citations
  3. Case-based reasoning for better generalization in textual reinforcement learningMattia Atzeni, Shehzaad Zuzar Dhuliawala, Keerthiram Murugesan, Mrinmaya SachanICLR 2022 · 16 citations
  4. Integrating Planning and Deep Reinforcement Learning via Automatic Induction of Task SubstructuresJung-Chun Liu, Chi-Hsien Chang, Shao-Hua Sun, Tian-Li YuICLR 2024 · 6 citations
  5. Investigating the Role of Model-Based Learning in Exploration and TransferJacob C. Walker, Eszter Vértes, Yazhe Li, Gabriel Dulac-Arnold et al.ICML 2023 · 8 citations
Dusk over the sea between two cliffs drawn in fine vertical lines