Create PlannerComponent for Step-by-Step Plan Generation
Summary
Create a PlannerComponent that enables AI agents to generate detailed step-by-step plans for achieving user goals, with specialized state update capabilities for plan management.
Description
This issue implements part of the design document from gitlab-com/content-sites/handbook!14034 (merged) and follows the componentization architecture established in #1216 (closed). The PlannerComponent should be similar to AgentComponent but with enhanced capabilities for plan creation and management.
Current State:
- Planning functionality exists in
duo_workflow_service/tools/planner.pywith specialized tools -
ToolsExecutoratduo_workflow_service/agents/tools_executor.pyhandles planner tools differently - No dedicated component exists for plan generation workflows
Key Differences from AgentComponent:
-
State Update Capability: ToolsNode must be capable of writing updates to the state
context:<component_name>.plan -
Plan Output: Must write to
context:<component_name>.plan - Specialized Tools: Uses planner-specific tools that modify workflow state directly
Requirements
Core Functionality:
-
Create PlannerComponentclass extendingBaseComponent -
Implement plan generation with step-by-step task breakdown -
Support output to context:<component_name>.planformat -
Enable detailed planning workflows for complex user goals
Technical Implementation:
-
Extend AgentComponentarchitecture with plan-specific modifications -
Implement specialized PlannerToolsNodethat handles plan specific tools, be aware of #1189 which outlines problems with injection of state into tools execution -
Support planner tools from duo_workflow_service/tools/planner.py:-
CreatePlan- Create initial plan with tasks -
AddNewTask- Add tasks to existing plan -
RemoveTask- Remove tasks from plan -
UpdateTaskDescription- Modify task descriptions -
SetTaskStatus- Update task completion status -
GetPlan- Retrieve current plan state
-
State Management:
-
Verify if LangGraphCommandresponses for state updates can be used, alternatively create dedicated node that will return correct state updates directly -
Manage plan state through specialized tools -
Support plan reset and incremental updates -
Integrate with existing PlanandTaskentities
Integration Points:
-
Leverage existing planner tools -
Maintain compatibility with BaseComponentinterface -
Support prompt registry integration for planning prompts
Output Specification:
-
Write plan output to context:<component_name>.plan -
Support structured plan format with tasks and status -
Enable plan persistence across workflow steps
Technical Notes
Reference Implementation:
- Study
duo_workflow_service/tools/planner.pyfor tool behavior - Understand
LangGraphCommandusage in planner tools for state updates
Key Differences in Tool Handling:
# Standard tools return strings/ToolMessage
def standard_tool_run(self, args) -> str:
return "Tool result"
# Planner tools return LangGraphCommand for state updates
def planner_tool_run(self, args) -> LangGraphCommand:
return LangGraphCommand(
update={
"conversation_history": {...},
"context": { "plan": Plan(steps=steps, reset=reset) },
}
)
Acceptance Criteria
-
PlannerComponentgenerates detailed step-by-step plans - Component outputs to
context:<component_name>.planformat - Planner tools work correctly with state updat
- Plan state is properly managed and persisted
- Integration with existing planning tools is seamless
- Component follows
BaseComponentinterface patterns
Examples
Expected Usage:
planner = PlannerComponent(
name="task_planner",
flow_id="workflow_123",
flow_type=CategoryEnum.DUO_WORKFLOW,
inputs=[IOKey(target="user_request")],
prompt_id="planner_prompt",
prompt_version="v1.0",
toolset=planner_toolset,
)
Expected Output:
# In workflow state after execution
state["context"]["task_planner"]["plan"] = {
"steps": [
{"id": "task-0", "description": "Analyze requirements", "status": "not_started"},
{"id": "task-1", "description": "Design solution", "status": "not_started"},
{"id": "task-2", "description": "Implement changes", "status": "not_started"}
],
"reset": False
}
Related Issues
- Builds on #1216 (closed) (Base Component Class Architecture)
- Part of epic gitlab-org/duo-workflow&1 (Componentize Duo Workflow Graph)
- Related to #1303 (Human-in-the-Loop Tool Approval)
Definition of Done
-
PlannerComponentimplementation complete -
Specialized PlannerToolsNodehandles state updates -
Plan output correctly written to context -
Integration tests with planner tools passing -
Documentation and examples provided
Edited by Mikołaj Wawrzyniak