Skip to content

feat: implement multi-step planning loop with parallel execution and …#1672

Open
peterish8 wants to merge 2 commits into
mofa-org:mainfrom
peterish8:issue-405-planning-loop
Open

feat: implement multi-step planning loop with parallel execution and …#1672
peterish8 wants to merge 2 commits into
mofa-org:mainfrom
peterish8:issue-405-planning-loop

Conversation

@peterish8
Copy link
Copy Markdown
Contributor

📋 Summary

Implements the four-phase planning loop described in issue #405, giving autonomous agents a structured way to approach complex multi-step goals. The existing ReAct loop handles single-shot tasks but has no mechanism for breaking down a complex goal, tracking progress across steps, adjusting when something fails, or synthesising partial results into a final answer.

🔗 Related Issues

Closes #405


🧠 Context

Agents given multi-part research tasks or complex data transformation pipelines today have no structured approach beyond fitting everything into a single prompt. This change adds a proper planning abstraction at the kernel level and a concrete executor at the foundation level, following the existing microkernel architecture.


🛠️ Changes

  • mofa-kernel: New Planner trait with PlanningRequest, ExecutionPlan, PlannedStep, MemoryItemSnapshot, and CompletedStep types. ExecutionPlan provides validate() and topological_groups() for dependency-aware parallel scheduling.
  • mofa-foundation: PromptPlanner (LLM-backed Planner impl) and PlanningExecutor running four phases — planning, parallel execution, per-step reflection, and synthesis. Independent steps run concurrently via futures::join_all. Long-term memory is recalled during planning via the existing Memory trait.
  • examples/planning_agent: End-to-end example — three parallel research subtasks feed a synthesis step that produces a structured report.

🧪 How you Tested

  1. cargo check -p mofa-kernel -p mofa-foundation — passes clean
  2. cargo test -p mofa-kernel planner — 6 tests pass (topological sort, cycle detection, validation edge cases)
  3. cargo check -p planning_agent (from examples/) — compiles clean
  4. Three foundation planning tests cover: parallel step execution timing, recalled memory in planning prompt, and reflection-triggered re-planning

Note: mofa-foundation coordination tests have pre-existing compile errors on main unrelated to this PR.


⚠️ Breaking Changes

  • No breaking changes

🧹 Checklist

Code Quality

  • Code follows Rust idioms and project conventions
  • cargo fmt run
  • cargo clippy passes without warnings

Testing

  • Tests added/updated
  • cargo test passes locally without any error

Documentation

  • Public APIs documented
  • README / docs updated (if needed)

PR Hygiene

  • PR is small and focused (one logical change)
  • Branch is up to date with main
  • No unrelated commits
  • Commit messages explain why, not only what

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement multi-step goal decomposition and planning loop for autonomous agents

1 participant