Skip to content

feat: SubFlow, Visualization, and Pi Agent Example#4

Open
dahai9 wants to merge 9 commits intoThe-Pocket:mainfrom
dahai9:main
Open

feat: SubFlow, Visualization, and Pi Agent Example#4
dahai9 wants to merge 9 commits intoThe-Pocket:mainfrom
dahai9:main

Conversation

@dahai9
Copy link
Copy Markdown

@dahai9 dahai9 commented Mar 29, 2026

PR Description: SubFlow, Visualization, and Pi Agent

Summary

This PR introduces three major enhancements to the PocketFlow-Rust framework to improve modularity, usability, and developer experience.

1. SubFlow Node (Composition)

Introduced SubFlowNode<SubState, ParentState>, allowing a Flow to be nested within another Flow.

  • Supports flexible context inheritance/isolation via context_builder.
  • Supports dynamic state mapping via result_mapper.
  • Enables building complex, recursive workflows from smaller, testable sub-flows.

2. Mermaid Visualization

Added to_mermaid() methods to Flow and BatchFlow.

  • Automatically generates Mermaid TD flowchart strings representing the workflow graph.
  • Simplifies debugging and documentation of complex agentic workflows.

3. Pi Agent Example

A high-performance Rust implementation of a coding agent using the PocketFlow-Rust framework.

  • Modularized into a standalone workspace member (examples/pi).
  • Features interactive CLI, tool-use (read/write/bash), and history compaction.
  • Demonstrates real-world application of the framework's capabilities.

4. Simplified State Transitions

Extended ProcessState to automatically handle condition string generation via strum::Display.

  • Reduces boilerplate and simplifies the build_flow! macro usage.

Technical Details

  • No new core dependencies: Relies on existing serde, anyhow, and strum.
  • Modularity: Moved agent-specific utilities to the example crate to keep the core library generic.
  • Verification: Added unit tests for SubFlow and Mermaid visualization; verified pi agent functionality.

Verification

  • cargo test (all unit tests pass)
  • cargo check -p pocketflow_rs -p pi
  • Manual execution of examples/pi and examples/basic.rs.

Created with ❤️ by Antigravity

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.

1 participant