Paper 2510.23564
ReCode: Unify Plan and Action for Universal Granularity Control
- Published
- Oct 2025
- Research lab
- Independent
- Citations
- 11
- GitHub
- 561 stars
01 In brief
Summary
The paper introduces ReCode, a novel paradigm for LLM-based agents that unifies planning and action within a single code representation to achieve universal control of decision granularity.
ReCode treats high-level plans as abstract placeholder functions, which are recursively decomposed into finer-grained sub-functions until reaching executable primitive actions, thereby dissolving the rigid boundary between planning and action.
This recursive structure also generates hierarchical, multi-granularity training data, enhancing data efficiency.
Experiments across ALFWorld, ScienceWorld, WebShop, and ManiSkill show ReCode significantly outperforms baselines like ReAct and CodeAct in inference (e.g., 60.8% average reward with GPT-4o mini vs.
47.4% for ReAct) and training (70.4% with Qwen2.5-7B vs.
67.6% for ReAct+SFT), while reducing costs by up to 84%.
The method demonstrates robust performance across multiple LLMs and environments, validating the core insight that unifying plan and action through recursive code generation is effective for adaptive decision-making.
02 From the paper
Abstract
Real-world tasks require decisions at varying granularities, and humans excel at this by leveraging a unified cognitive representation where planning is fundamentally understood as a high-level form of action. However, current Large Language Model (LLM)-based agents lack this crucial capability to operate fluidly across decision granularities. This limitation stems from existing paradigms that enforce a rigid separation between high-level planning and low-level action, which impairs dynamic adaptability and limits generalization. We propose ReCode (Recursive Code Generation), a novel paradigm that addresses this limitation by unifying planning and action within a single code representation. In this representation, ReCode treats high-level plans as abstract placeholder functions, which the agent then recursively decomposes into finer-grained sub-functions until reaching primitive actions. This recursive approach dissolves the rigid boundary between plan and action, enabling the agent to dynamically control its decision granularity. Furthermore, the recursive structure inherently generates rich, multi-granularity training data, enabling models to learn hierarchical decision-making processes. Extensive experiments show ReCode significantly surpasses advanced baselines in inference performance and demonstrates exceptional data efficiency in training, validating our core insight that unifying planning and action through recursive code generation is a powerful and effective approach to achieving universal granularity control. The code is available at https://github.com/FoundationAgents/ReCode.