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.