ReCode:统一规划与行动,实现通用粒度控制
ReCode: Unify Plan and Action for Universal Granularity Control
October 27, 2025
作者: Zhaoyang Yu, Jiayi Zhang, Huixue Su, Yufan Zhao, Yifan Wu, Mingyi Deng, Jinyu Xiang, Yizhang Lin, Lingxiao Tang, Yingchao Li, Yuyu Luo, Bang Liu, Chenglin Wu
cs.AI
摘要
现实世界任务需要不同粒度的决策能力,人类凭借统一的认知表征在此方面表现出色——在这种认知框架中,规划本质上被理解为一种高层级的行为形式。然而,当前基于大语言模型(LLM)的智能体缺乏这种跨决策粒度流畅操作的关键能力。这一局限源于现有范式对高层规划与底层行动进行严格割裂,既损害了动态适应性,也限制了泛化能力。我们提出ReCode(递归代码生成)这一新范式,通过将规划与行动统一在单一代码表征中来解决此问题。在该表征中,ReCode将高层计划视为抽象占位函数,智能体随后将其递归分解为更细粒度的子函数,直至抵达原始动作层级。这种递归方法消解了规划与行动之间的刚性边界,使智能体能够动态控制决策粒度。此外,递归结构本身会生成丰富的多粒度训练数据,使模型能够学习层级化决策过程。大量实验表明,ReCode在推理性能上显著超越先进基线,并展现出卓越的训练数据效率,验证了我们的核心观点:通过递归代码生成统一规划与行动,是实现通用粒度控制的高效方法。代码已开源于https://github.com/FoundationAgents/ReCode。
English
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.