Planning Actions#
Version: 0.8.22
This document covers planning and decomposition primitives for agentic workflows (TEA-AGENT-001.3).
Overview#
Planning actions implement the planning pattern from Agentic Design Patterns, enabling:
Goal Decomposition: Break complex goals into manageable subtasks
Dependency Management: Express and validate subtask dependencies as DAGs
Execution Control: Sequential or parallel execution respecting dependencies
Failure Handling: Strategies for dealing with subtask failures
Re-planning: Adjust plans based on execution results
Actions Summary#
Action |
Description |
Story |
|---|---|---|
|
Decompose goal into subtasks |
TEA-AGENT-001.3 |
|
Execute plan respecting dependencies |
TEA-AGENT-001.3 |
|
Re-plan from current state |
TEA-AGENT-001.3 |
|
Get plan execution status |
TEA-AGENT-001.3 |
plan.decompose#
Decompose a goal into subtasks using LLM. Returns a structured plan with subtask dependencies forming a DAG.
Parameters#
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
Yes |
- |
The goal to decompose |
|
string |
No |
|
LLM model for planning |
|
string |
No |
|
Planning strategy: |
|
integer |
No |
|
Max depth for hierarchical plans |
|
integer |
No |
|
Maximum number of subtasks |
|
string |
No |
- |
Custom prompt for decomposition |
|
float |
No |
|
LLM temperature |
Planning Strategies#
Strategy |
Description |
Best For |
|---|---|---|
|
Simple sequential list of subtasks |
Linear tasks |
|
Tree of subtasks with sub-subtasks |
Complex goals |
|
Plan one step at a time based on current state |
Exploratory tasks |
Returns#
{
"plan": {
"id": "plan_abc123",
"goal": "Research and summarize topic X",
"strategy": "hierarchical",
"subtasks": [
{
"id": "search",
"description": "Search for relevant sources",
"dependencies": [],
"status": "pending"
},
{
"id": "analyze",
"description": "Analyze found sources",
"dependencies": ["search"],
"status": "pending"
}
],
"metadata": {
"created_at": 1704393600.0,
"replan_count": 0,
"max_replans": 3
}
},
"planning_trace": [...],
"success": true,
"plan_id": "plan_abc123",
"subtask_count": 2
}
Example#
nodes:
- name: create_plan
action: plan.decompose
with:
goal: "{{ state.user_goal }}"
strategy: hierarchical
max_depth: 3
model: gpt-4
prompt_template: |
Break down this goal into actionable subtasks.
Each subtask should be specific and measurable.
Goal: {{ goal }}
plan.execute#
Execute plan subtasks respecting dependency order. Supports sequential and parallel execution.
Parameters#
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
object |
No |
|
Plan to execute |
|
boolean |
No |
|
Execute independent subtasks in parallel |
|
integer |
No |
|
Max concurrent subtasks when parallel |
|
object |
No |
|
Action config for executing subtasks |
|
string |
No |
|
Failure strategy: |
|
integer |
No |
|
Max retries per subtask (for retry strategy) |
|
float |
No |
|
Delay between retries in seconds |
|
integer |
No |
|
Max replan attempts (for replan strategy) |
Failure Strategies#
Strategy |
Behavior |
|---|---|
|
Stop execution immediately on failure |
|
Mark failed subtask as skipped, continue |
|
Retry with exponential backoff |
|
Re-plan from current state preserving completed work |
Subtask Executor#
The subtask_executor parameter configures how each subtask is executed:
subtask_executor:
action: llm.call
with:
model: gpt-4
temperature: 0.7
Or use agent dispatch:
subtask_executor:
action: agent.dispatch
with:
agent: worker
Returns#
{
"plan": {...},
"subtask_results": {
"search": "Found 5 relevant sources...",
"analyze": "Key findings: ..."
},
"plan_status": {
"total": 4,
"completed": 2,
"pending": 2,
"failed": 0,
"skipped": 0
},
"replan_count": 0,
"planning_trace": [...],
"success": true
}
Example#
nodes:
- name: execute_plan
action: plan.execute
with:
plan: "{{ state.plan }}"
parallel: true
max_concurrent: 3
on_subtask_failure: retry
max_retries: 2
subtask_executor:
action: llm.call
with:
model: gpt-4
plan.replan#
Re-plan from current state, preserving completed subtasks. Used when a subtask fails or when the plan needs adjustment based on new information.
Parameters#
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
object |
No |
|
Current plan |
|
string |
No |
|
LLM model for re-planning |
|
float |
No |
|
LLM temperature |
State Variables Used#
state.plan: Current planstate.subtask_results: Results from completed subtasksstate.failed_subtask: ID of the failed subtaskstate.failure_reason: Reason for failure
Returns#
{
"plan": {...},
"preserved_subtasks": 2,
"new_subtasks": 3,
"planning_trace": [...],
"success": true
}
Example#
nodes:
- name: handle_failure
action: plan.replan
with:
model: gpt-4
temperature: 0.5
plan.status#
Get current plan execution status with aggregated counts and optional subtask details.
Parameters#
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
object |
No |
|
Plan to get status for |
|
boolean |
No |
|
Include completed subtasks in response |
|
boolean |
No |
|
Include full subtask details |
Returns#
{
"status": {
"total": 5,
"pending": 2,
"in_progress": 1,
"completed": 2,
"failed": 0,
"skipped": 0
},
"progress": 0.4,
"plan_id": "plan_abc123",
"goal": "Research and summarize topic X",
"subtasks": [...], // if include_details=true
"success": true
}
Example#
nodes:
- name: check_progress
action: plan.status
with:
include_details: true
include_completed: false
Plan Structure#
Plans follow this structure:
{
"id": "plan_abc123",
"goal": "Research and summarize topic X",
"strategy": "hierarchical",
"subtasks": [
{
"id": "subtask_1",
"description": "Search for relevant sources",
"dependencies": [],
"status": "completed",
"result": "Found 5 sources..."
},
{
"id": "subtask_2",
"description": "Analyze sources",
"dependencies": ["subtask_1"],
"status": "in_progress",
"result": null
}
],
"metadata": {
"created_at": 1704393600.0,
"replan_count": 0,
"max_replans": 3
}
}
Subtask Status Values#
Status |
Description |
|---|---|
|
Not yet started |
|
Currently executing |
|
Successfully completed |
|
Execution failed |
|
Skipped due to failure strategy |
State Variables#
Planning actions set these state variables:
Variable |
Type |
Description |
|---|---|---|
|
dict |
Current plan structure |
|
dict |
Aggregated status counts |
|
dict |
Currently executing subtask |
|
dict |
Map of subtask_id → result |
|
int |
Number of re-plans triggered |
Complete Workflow Example#
name: research-planner
state_schema:
user_goal: str
plan: dict
subtask_results: dict
final_result: str
nodes:
- name: plan_research
action: plan.decompose
with:
goal: "{{ state.user_goal }}"
strategy: hierarchical
max_depth: 2
model: gpt-4
- name: execute_research
action: plan.execute
with:
plan: "{{ state.plan }}"
parallel: true
max_concurrent: 3
on_subtask_failure: replan
max_replans: 2
subtask_executor:
action: llm.call
with:
model: gpt-4
- name: check_completion
action: plan.status
with:
include_details: false
- name: synthesize
action: llm.call
with:
model: gpt-4
messages:
- role: system
content: Synthesize the research results into a comprehensive summary.
- role: user
content: |
Goal: {{ state.user_goal }}
Results: {{ state.subtask_results | tojson }}
navigation:
plan_research: execute_research
execute_research: check_completion
check_completion: synthesize
synthesize: __end__
Error Handling#
Planning actions return structured errors:
{
"error": "Invalid plan structure: Cycle detected: a -> b -> c -> a",
"success": false,
"planning_trace": [...]
}
Common error conditions:
Error |
Cause |
Solution |
|---|---|---|
“No plan provided” |
Missing plan in state |
Call |
“Cycle detected” |
Subtask dependencies form a cycle |
Fix dependency structure |
“Unknown subtask” |
Dependency references non-existent subtask |
Verify subtask IDs |
“Max replans exceeded” |
Too many replan attempts |
Increase |
Best Practices#
Start with flat strategy for simple tasks, upgrade to hierarchical for complex goals
Use iterative strategy when the full scope isn’t known upfront
Set appropriate max_subtasks to prevent overly complex plans
Use parallel execution for independent subtasks to speed up execution
Prefer retry or skip over abort for robust workflows
Monitor progress with
plan.statusfor long-running plansStore plans in checkpoints for resumable execution