Outer-Inner Agent Loop
Run two nested loops — an outer planner agent that decomposes the goal into subtasks and dispatches them, and an inner executor agent that runs its own tool-use/ReAct loop on each subtask; the outer can interrupt and replan based on the inner's progress.
Intent & Description
🎯 Intent
Run two nested loops: an outer planner agent that decomposes the goal into subtasks and dispatches them, and an inner executor agent that runs its own tool-use/ReAct loop on each subtask; the outer can interrupt and replan based on the inner’s progress.
📋 Context
A team operates an agent on long-horizon work — multi-step report writing, multi-stage data investigations, multi-day refactors — where the breakdown of the goal matters as much as the individual steps. Partway through the run, the agent may discover something that invalidates the original plan. The team wants the planner to react to that evidence instead of letting execution proceed on a stale plan.
💡 Solution
- Define two roles: Outer agent (Dispatcher + Planner) decomposes the goal into subtasks with milestones, dispatches each to the inner agent, and may interrupt to replan when milestones are missed or new evidence arrives. - Inner agent (Actor) runs a tool-use loop on a single subtask and reports back a structured result. - Outer holds global state; inner holds local state. - The interruption channel is the only path the outer has into the inner’s loop.
Real-world Use Case
- Goals decompose into subtasks where global planning and local action have different cadences.
- An outer planner needs an interruption channel to replan based on inner-loop evidence.
- Global state and local state can be cleanly separated between the two loops.
Source
Advantages
- Planning and execution are separately legible and separately tunable.
- Outer can budget steps and cost per subtask.
- Inner failures are localised; outer can retry with a different plan.
Disadvantages
- Two loops double the orchestration surface and the failure modes.
- Interrupt semantics are easy to get wrong (mid-step interrupts, partial state).
- Outer’’s monitoring calls are themselves LLM calls, adding cost.