Function: plan()
@providerprotocol/agents / execution / plan
Function: plan()
Section titled “Function: plan()”plan(
options):ExecutionStrategy
Defined in: src/execution/plan.ts:102
Creates a plan-then-execute strategy for agent execution.
The plan strategy implements a two-phase approach:
- Planning Phase: LLM generates a structured plan with steps and dependencies
- Execution Phase: Execute each plan step in topological order respecting dependencies
If a step fails and allowReplan is true, the strategy can generate a new plan
to recover from the failure (replanning is not yet fully implemented).
This strategy is ideal for complex multi-step tasks where the execution order matters and steps may have dependencies on each other.
Parameters
Section titled “Parameters”options
Section titled “options”PlanOptions = {}
Configuration options for the plan strategy
Returns
Section titled “Returns”An ExecutionStrategy instance implementing the plan-then-execute pattern
Example
Section titled “Example”import { createAgent, plan } from '@providerprotocol/agents';
// Basic plan-based agentconst agent = createAgent({ llm: myLLM, tools: [readFileTool, writeFileTool, searchTool], strategy: plan(),});
// With step limit and replanningconst robustAgent = createAgent({ llm: myLLM, tools: [apiTool, dbTool], strategy: plan({ maxPlanSteps: 10, allowReplan: true, }),});
// Execute a complex taskconst result = await agent.generate( 'Read config.json, update the version, and write it back');console.log(result.state.plan); // Shows executed plan steps