Planning & TODOs
Agent SDK includes a powerful planning mode that helps manage complex multi-step tasks through structured TODO management.
Overview
When you enable useTodoList: true, the smart agent gains access to a special manage_todo_list tool that enforces disciplined planning workflows. This is particularly useful for:
- Complex multi-step tasks that require breaking down into subtasks
- Tasks where order of operations matters
- Scenarios requiring checkpoints and progress tracking
- Long-running operations that benefit from structured plans
Enabling Planning Mode
typescript
import { createSmartAgent } from "@cognipeer/agent-sdk";
const agent = createSmartAgent({
model,
tools,
useTodoList: true, // Enable planning mode
});How It Works
1. Initial Planning
When planning is enabled, the agent must create a plan before taking any action:
typescript
const result = await agent.invoke({
messages: [{
role: "user",
content: "Research the top 3 AI frameworks and compare their features"
}],
});The agent will:
- Call
manage_todo_listto create an initial plan - Break down the request into actionable items
- Mark one item as
in-progress - Execute tools to complete each item
- Update the plan after each action
2. Plan Structure
Each TODO item has:
- id: Unique identifier
- title: Short description (3-7 words)
- description: Detailed context and requirements
- status:
not-started,in-progress, orcompleted
3. Strict Workflow Rules
The planning system enforces these rules:
- Plan First: Must create a plan before any other tool execution
- Update After Action: Must update plan after every tool call
- Single In-Progress: Keep exactly one item
in-progressat a time - Evidence Required: Attach brief evidence when marking items complete
- No Plan Exposure: Never include plan text in assistant messages
Monitoring Plans
Listen to plan events to track progress:
typescript
const agent = createSmartAgent({
model,
tools,
useTodoList: true,
onEvent: (event) => {
if (event.type === "plan") {
console.log("Plan updated:");
console.log(`Version: ${event.version}`);
console.log(`Items: ${event.todoList.length}`);
event.todoList.forEach(item => {
console.log(` [${item.status}] ${item.title}`);
});
}
},
});Benefits
- Transparency: See exactly what the agent plans to do
- Control: Intervene or approve before actions execute
- Traceability: Track which steps succeeded or failed
- Resumability: Resume from where the agent left off
- Debugging: Understand agent reasoning and decision-making
Example: Multi-Step Research
typescript
const agent = createSmartAgent({
name: "Researcher",
model,
tools: [searchTool, analyzeTool, summarizeTool],
useTodoList: true,
});
const result = await agent.invoke({
messages: [{
role: "user",
content: "Research recent developments in quantum computing and create a summary"
}],
});
// Agent creates plan:
// 1. [in-progress] Search for quantum computing news
// 2. [not-started] Analyze top 5 results
// 3. [not-started] Create structured summary
// 4. [not-started] Validate sources
// After each step, plan is updated automaticallyAdvanced: Custom Plan Prompts
You can customize planning behavior by providing additional instructions:
typescript
const agent = createSmartAgent({
model,
tools,
useTodoList: true,
systemPrompt: `
When creating plans:
- Break tasks into 3-5 items maximum
- Include estimated time for each step
- Prioritize data validation
`,
});Best Practices
- Use for Complex Tasks: Planning overhead makes sense for multi-step operations
- Monitor Events: Track plan updates to understand agent behavior
- Test Resumability: Ensure plans work with pause/resume workflows
- Limit Plan Size: Keep plans focused (3-7 items typically)
- Clear Descriptions: Provide detailed task descriptions for better planning
See Also
- State Management - Pause and resume with plans
- Tool Approvals - Combine planning with human approval
- Debugging - Trace plan execution