ReCAP
On a long task, an agent can forget why it started. ReCAP, short for Recursive Context-Aware Reasoning and Planning, keeps the goal in view by planning ahead, executing step by step, and reinserting the parent plan whenever it returns from a subtask. That structured reinsertion is the trick: the agent always sees the higher-level goal it is serving, so it drifts far less over long horizons, while the active prompt stays bounded.
*These are learning tools, not prompts. They teach you to write your own, think of them as training wheels that guide you while you learn, then fall away once you can ride on your own.
Keep the Parent Goal in View
Decomposition helps an agent tackle a big task by breaking it into subtasks. But there is a hidden cost: as the agent dives into a subtask, and then a sub-subtask, the original goal slides out of the active context. By the time it climbs back up, it may have forgotten what the subtask was for, and its answer no longer fits the larger plan. This is goal drift, and it gets worse the deeper and longer the task runs.
ReCAP fixes this with recursion that carries context both ways. The agent plans ahead by listing the subtasks, executes the first, then refines what remains. Crucially, when it returns from a subtask, it reinserts the parent plan into the context, so the higher-level goal is always visible at the moment the agent decides what to do next. The structure of the task is never lost, because it is re-shown at every return.
Because only the relevant levels of the plan are kept active, ReCAP also bounds the prompt: the context does not balloon with the entire history, so cost scales with the depth of the task rather than its total length. The result is an agent that stays anchored to its goal across long, nested work without paying an ever-growing context bill.
One way to fight goal drift is to keep the entire history in context, but that grows without limit. ReCAP instead reinserts the parent plan at each recursive return, so the agent sees the goal it is serving without carrying every past step. Context stays bounded while the goal stays visible.
The ReCAP Process
Plan ahead, execute, refine, and reinsert the parent plan on return
Plan Ahead
The agent decomposes the task into an ordered list of subtasks before acting. Having the full subtask list up front gives every later step a visible place in the larger plan.
Goal: organize a small event. Subtasks: pick a date, book a venue, invite guests, arrange catering, confirm details.
Execute the First Subtask
The agent works the first item, recursing into it if it needs its own subtasks. Deeper levels get their own local plans, so complex subtasks are handled with the same structure as the whole.
"Book a venue" recurses into: shortlist options, check availability, compare cost, reserve.
Reinsert the Parent Plan on Return
When a subtask finishes, the agent brings the parent plan back into context before continuing. It sees the higher-level goal and the remaining subtasks again, so its next decision is made with the full picture in view.
After booking the venue, the parent event plan is reinserted, reminding the agent that inviting guests comes next.
Refine and Continue to the Goal
With the parent plan in view, the agent refines the remaining subtasks in light of what it just learned, then moves on. Because the active prompt holds only the relevant levels, the process stays bounded as it works down the whole plan.
Learning the venue seats fewer people, the agent refines the guest list step before sending invites.
See the Difference
Losing the goal in deep subtasks versus reinserting it
Plain Decomposition
The agent descends into subtasks, and the original goal drops out of the active context. Returning from a deep subtask, it no longer sees what the subtask was for.
Goal drift: the agent's later steps stop fitting the larger plan, especially on deep, long-running tasks.
ReCAP
On every return from a subtask, the higher-level plan is put back in view, so the agent always decides with its goal in front of it.
Far less goal drift over long horizons, with the active prompt bounded so cost scales with depth rather than total length.
Practice Responsible AI
Always verify AI-generated content before use. AI systems can produce confident but incorrect responses. When using AI professionally, transparent disclosure is both best practice and increasingly a legal requirement.
Most US states are actively legislating AI transparency and accountability. Critical thinking remains your strongest tool against misinformation.
ReCAP in Action
See how reinserting the plan keeps nested work on track
"Write a briefing comparing three vendors on price, support, and security."
Plan: research each vendor, then compare on the three dimensions, then write.
Recurse: researching "security" for one vendor goes deep into certifications and incident history.
Reinsert on return: the parent plan reminds the agent it is comparing three vendors on three dimensions, so it captures security in the comparable form the briefing needs, not a standalone deep dive.
"Add a feature that touches the API, the database, and the UI."
Plan: change the database schema, update the API, then the UI, then test end to end.
Recurse: the schema change spawns its own migration subtasks.
Reinsert on return: back at the top level, the agent remembers the API and UI still depend on the new schema, so it carries the change through instead of stopping at the migration.
A task runs for dozens of steps; keeping the whole history would blow the context budget.
Only the active levels of the plan are held, so the prompt does not grow with every step.
Result: cost scales with how deep the task nests, not with how long it runs, while the goal remains visible through reinsertion.
When to Use ReCAP
Best for deep, long-horizon tasks with nested subtasks
Perfect For
Work that breaks into subtasks and sub-subtasks benefits most, since reinserting the parent plan at each return is exactly where drift is prevented.
Tasks that run for many steps stay anchored to the goal, which single-pass decomposition tends to lose track of over time.
When keeping the whole history is too expensive, ReCAP's bounded active prompt controls cost while still surfacing the goal.
When later steps depend on the results of earlier ones, seeing the parent plan again ensures those dependencies are honored.
Skip It When
If a task has no nesting and few steps, there is little goal drift to prevent, so the recursive machinery is overhead.
When subtasks share nothing and never need the parent goal, the reinsertion step adds little value.
For a single-shot answer with no execution phase, a plain reasoning method is a better fit than recursive planning.
Use Cases
Where ReCAP delivers the most value
Multi-File Coding
Carry a feature across schema, API, and UI changes, reinserting the overall plan so downstream layers are not forgotten after a deep subtask.
Structured Research
Keep a comparison or briefing coherent by reminding the agent of the shared dimensions each time it returns from researching one item.
Project Execution
Run multi-stage projects where early results reshape later steps, refining the remaining plan with the goal in view at each return.
Budget-Bounded Agents
Run long tasks under a context or cost ceiling, holding only the active plan levels so the prompt does not grow without limit.
Hierarchical Planning
Handle tasks that naturally form a tree of goals and subgoals, keeping each level aware of the one above it.
Drift-Resistant Long Runs
Improve reliability on tasks where agents usually lose the thread, by making the parent goal visible at every recursive return.
Where ReCAP Fits
Context-aware recursion in the planning family
ReCAP and Plan-and-Act both fight goal drift on long tasks; ReCAP's angle is recursive reinsertion of the parent plan with a bounded prompt. Reach for it when a task nests deeply and the agent tends to forget the higher-level goal on the way back up.
Related Techniques
Explore complementary planning and decomposition techniques
Keep the Goal in View
Explore how reinserting a parent plan keeps nested tasks on track in the Prompt Builder, or see related planning techniques.