Framework · Orchestration Frameworks

PocketFlow

Capture the core graph abstraction of LLM frameworks in 100 lines of zero-dependency Python so Agent, Multi-Agent, Workflow, and RAG patterns can be assembled on top.

Description

PocketFlow is a 100-line, zero-dependency minimalist LLM framework. Its only abstractions are Node (a small LLM/task unit) and Flow (which connects Nodes via labelled Actions); batch and async variants extend the same primitives. The Agent design pattern is realised by branching from a decision Node to one of several action Nodes and looping; the Multi-Agent pattern uses message queues in shared storage for peer-to-peer coordination. Workflow and RAG are documented as compositions of the same primitives.

Solution

Graph of Nodes connected by Action labels. A Node computes (often via an LLM call), returns an Action label, and the Flow uses that label to pick the next Node — enabling branching, looping, and agent-style 'decide-then-act'. Multi-agent coordination is implemented with asyncio.Queue message queues in shared storage; the framework explicitly does not ship a supervisor or scheduler abstraction.

Primary use cases

  • learning the core graph abstraction behind LLM frameworks
  • tiny tool-using agents with explicit action spaces
  • peer-to-peer multi-agent message-queue prototypes
  • lightweight workflow decompositions and RAG pipelines

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.