ReCode: Unify Plan and Action for Universal Granularity Control

Zhaoyang Yu, Jiayi Zhang, Huixue Su, Yufan Zhao, Yifan Wu +7 more
10/27/2025
16 citations
cs.AIcs.CLcs.LG

Official code: FoundationAgents/ReCode (576 stars, Python, MIT, last commit 2026-04-21).

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

MIT

Next paradigm for LLM Agent. Unify plan and action through recursive code generation for adaptive, human-like decision-making.

57669Python, HTMLOct 27, 20257 months agoMIT

Similar Papers

Cite this paper

@article{yu2025recode,
  title  = {ReCode: Unify Plan and Action for Universal Granularity Control},
  author = {Zhaoyang Yu and Jiayi Zhang and Huixue Su and Yufan Zhao and Yifan Wu and Mingyi Deng and Jinyu Xiang and Yizhang Lin and Lingxiao Tang and Yuyu Luo and Bang Liu and Chenglin Wu},
  year   = {2025},
  eprint = {2510.23564},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.23564v4}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.23564.svg)](https://codeofpaper.com/paper/2510.23564)

Discussion