ReCAP : Recursive Context-Aware Reasoning and Planning for Large Language Model Agents

Zhenyu Zhang, Tianyi Chen, Weiran Xu, Alex Pentland, Jiaxin Pei · 2025

Read ReCAP : Recursive Context-Aware Reasoning and Planning for Large Language Model Agents by Zhenyu Zhang, Tianyi Chen, Weiran Xu, Alex Pentland, Jiaxin Pei (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2510-23822.txt.

Introduction

Zhenyu Zhang and four co-authors introduce ReCAP, a framework that helps language model agents finish long, multi-step tasks without losing the thread. Sequential prompting drifts: goals fade from context and agents loop through the same failures. Hierarchical prompting keeps goals better but can break continuity between levels or cost too much runtime.

ReCAP plans ahead: the model writes a full subtask list, executes the first item, then refines the rest as it goes. Parent plans are re-injected in structured form whenever the agent returns from a subtask, keeping context consistent across levels. The active prompt stays bounded, so cost grows only linearly with task depth. On long-horizon benchmarks the method improved subgoal alignment and success rates clearly. It gained about thirty-two percent on a synchronous cooking-robot test and twenty-nine percent on the asynchronous version, under a strict one-try scoring rule.

Catalog record

CREATORZhenyu Zhang, Tianyi Chen, Weiran Xu, Alex Pentland, Jiaxin Pei
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE56 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2510-23822

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

ReCAP : Recursive Context-Aware Reasoning and Planning for Large Language Model Agents Zhenyu Zhang, Tianyi Chen, Weiran Xu, Alex Pentland, Jiaxin Pei Abstract Long-horizon tasks requiring multi-step reasoning and dynamic re-planning remain challenging for large language models (LLMs). Sequential prompting methods are prone to context drift, loss of goal information, and recurrent failure cycles, while hierarchical prompting methods often weaken cross-level continuity or incur substantial runtime overhead. We introduce ReCAP ( Re cursive C ontext- A ware Reasoning and P lanning), a hierarchical framework with shared context for reasoning and planning in LLMs. ReCAP combines three key mechanisms: (i) plan-ahead decomposition, in which the model generates a full subtask list, executes the first item, and refines the remainder; (ii) structured re-injection of parent plans, maintaining consistent multi-level context during recursive return; and (iii) memory-efficient execution, bounding the active prompt so costs scale linearly with task depth. Together these mechanisms align high-level goals with low-level actions, reduce redundant prompting, and preserve coherent context updates across recursion. Experiments demonstrate that ReCAP substantially improves subgoal alignment and success rates on various long-horizon reasoning benchmarks, achieving a 32% gain on synchronous Robotouille and a 29% improvement on asynchronous Robotouille under the strict pass@1 protocol. 0 0 footnotetext: Code and data: https://github.com/ReCAP-Stanford/ReCAP (a) Limitations of pure sequential/hierarchical prompting. In sequential prompting (e.g., ReAct/Reflexion), early high-level thoughts drift far in a sequential history, leading to loss of goal information. In hierarchical prompting (e.g., ADaPT/THREAD), subtasks run in separate local contexts, fragmenting information across depths and leading to recurrent failure cycles. (b) ReCAP. At each depth, the agent generates or refines a subtask plan, executes primitive actions as they occur, and appends new observations. After resolving each subgoal, the parent’s remaining plan is re-injected into a single sliding LLM context, keeping high-level intent proximal to the current decision point and preserving coherence across multiple levels of reasoning. Figure 1 : sequential/hierarchical prompting vs. ReCAP 1 Introduction A fundamental characteristic of intelligence is the smooth transition between high-level abstract reasoning and low-level task execution—something humans routinely perform in everyday activities ( newell1972human ) . Imagine organizing a multi-day trip: one first outlines a broad plan—such as identifying destinations, transport, and accommodations—before refining it into actionable subtasks like booking tickets or arranging local travel. Real-world task execution, however, rarely follows a fixed script: a resource may be unavailable, an intermediate step may fail, or schedules may conflict. Such situations demand long-horizon reasoning that both preserves the global intent and maintains coherence between different levels of detail within the plan, while flexibly revising steps as feedback unfolds. Current LLM-based methods face challenges here: sequential prompting exhibits context drift and repeated cycles when early plans leave the context window, while hierarchical prompting often lose continuity across levels or incur redundant memory usage. Addressing such scenarios demands context-aware long-horizon adaptive reasoning and planning, requiring an intelligent system that can commit to a plan while remaining flexible to feedback and maintain coherence across multiple levels of reasoning ( wang2023voyageropenendedembodiedagent ; yao2023react ) . Recent reasoning frameworks enable LLMs to interleave reasoning with action, improving problem solving in multi-step settings. Sequential prompting methods such as Chain-of-Thought (CoT) ( wei2023chainofthoughtpromptingelicitsreasoning ) , ReAct ( yao2023react ) , and Reflexion ( shinn2023reflexionlanguageagentsverbal ) operate in a largely linear fashion: the model produces step-by-step thoughts (and optionally actions/observations) along a single trajectory. These approaches are simple and effective on short horizons, but in long-horizon environments, early plans often drift out of the context window or become stale, leading to loss of goal information and recurrent failure cycles even with extended contexts ( liu2023lost ; yao2023tot ; dagan2023dynamicplanningllm ) . Ada-Planner ( ada-planner ) extends this paradigm by editing a single global linear plan through explicit closed-loop refinement, but it remains fundamentally linear and still susceptible to divergence from planned trajectory on long horizons. In response, hierarchical prompting methods explicitly organize reasoning beyond a single chain: Tree of Thoughts (ToT) explores branching and backtracking over thought trees ( yao2023tot ) ; Graph of Thoughts (GoT) generalize to non-linear dependencies ( besta2024graph ) ; THREAD recursively spawns subproblems but prompts each with isolated subgoal context ( thread ) ; ADaPT alternates planner–executor prompts to refine subgoals ( adapt ) ; and REPL-Plan maintains an external program state and code-execution loop to drive planning ( replplan ) . While these methods organize reasoning in hierarchy, they can either (i) reduce continuity between levels of reasoning when subtasks are prompted in largely isolated contexts (e.g., THREAD, where subgoal prompts carry only partial parent information), or (ii) introduce increased runtime overhead and strong dependence on prior trajectories or tool-specific states (e.g., REPL-Plan, which introduces extra overhead by depending on an external code-execution environment). To address these limitations, we introduce ReCAP ( Re cursive C ontext- A ware Reasoning and P lanning), a hierarchical prompting framework with shared context for long-horizon tasks and dynamic environments. ReCAP is built around three major mechanisms. (1) Plan-ahead task decomposition : instead of generating one subtask at a time, ReCAP produces a complete subtask list in a single pass, executes only the first item, and refines the remaining plan upon subtask completion—preserving global intent while avoiding plan drift. (2) Consistent multi-level context with structured injection : reasoning across all recursion depths occurs within a shared LLM context. When returning from a subgoal, the parent’s plan (latest thoughts and remaining subtasks) is re-injected into the active context window, preserving cross-level continuity and ensuring coherent progression through the task hierarchy (3) Memory-efficient scalability : the active prompt remains bounded, with critical planning information reintroduced through structured injection so that truncation does not cause loss of high-level intent. This avoids unbounded context accumulation, eliminates redundant few-shot duplication across recursive calls, and makes the external state grow linearly with recursion depth. Together, these mechanisms preserve high-level intent, support coherent multi-level reasoning, and provide robustness across a wide range of long-horizon tasks and dynamic environments. We evaluate ReCAP across embodied and knowledge-intensive tasks with different planning horizons and feedback dynamics: Robotouille ( gonzalezpumariega2025robotouilleasynchronousplanningbenchmark ) , ALFWorld ( shridhar2021alfworldaligningtextembodied ) , FEVER ( Thorne18Fever ) , and SWE-bench ( jimenez2024swebench ) . ALFWorld features short, largely linear embodied sequences. In Robotouille, the horizon grows much longer, and subgoals must be interleaved or refined continuously under resource contention. FEVER remains a shallow, tool-mediated retrieval task with a small symbolic action API. SWE-bench expands the action space from finite to effectively unbounded: the agent must compose multi-step code edits in a space far larger than environments with a limited verb set. Importantly, we adopt a strict pass@1 protocol: each task instance is solved through a single uninterrupted reasoning–execution trajectory, without retries, self-consistency, or ensembling, and we use a one-shot demonstration per agent. This is stricter than the ReAct setting, which is frequently reported with pass@6 and multiple demonstrations, and thus better reflects realistic single-run agent deployment. To summarize, ReCAP introduces a recursive, context-aware framework for long-horizon reasoning and planning with LLMs. It enables structured subtask decomposition, dynamic memory tracking, and observation-driven plan adaptation without any training or fine-tuning. ReCAP outperforms strong baselines—achieving up to 32% in long-horizon tasks. 2 ReCAP: Recursive Context-Aware Reasoning and Planning 2.1 Framework Overview Algorithm 2 formalizes the overall procedure, starting

Read the complete text