Planning & Decomposition Kit

Automatic goal decomposition into task trees with dependency tracking and execution visualization.

0/8 tasks complete
Task Tree
Understand the request200ms
Gather information
Search academic papers1500ms
Search news articles1200ms
Search company blogs900ms
Analyze & synthesize2000ms
Create outline800ms
Write draft3000ms
Self-review & revise1200ms

Integration Code

import { createPlanner, TaskTree } from 'agent-tools-kit/reasoning'

const planner = createPlanner({
  model: 'gpt-4o',
  strategy: 'hierarchical',  // or 'flat', 'iterative'
  maxDepth: 3,
  parallelExecution: true,
  dependencyTracking: true,
})

// Decompose a high-level goal
const plan = await planner.decompose(
  'Write a research report on AI safety'
)

// Execute the plan with progress tracking
const result = await plan.execute({
  onTaskStart: (task) => console.log('Starting:', task.label),
  onTaskComplete: (task) => console.log('Done:', task.label, task.durationMs),
  onTaskFail: (task, error) => {
    console.error('Failed:', task.label, error)
    return 'retry'  // or 'skip', 'abort'
  },
})

// Access the full task tree
const tree = plan.getTree()
console.log('Total tasks:', tree.flatten().length)
console.log('Critical path:', tree.criticalPath())