Full-Code · Orchestration Frameworksactive

PocketFlow

also known as Pocket Flow

Type: full-code  ·  Vendor: The Pocket  ·  Language: Python  ·  License: MIT  ·  Status: active  ·  Status in practice: emerging

Links: homepage docs repo

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.

Agent loop shape. 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

Key concepts

  • Node (docs)Smallest unit of computation; handles a single (LLM) task.
  • Flow (docs)Connects Nodes through Actions (labelled edges); the basis of branching and looping.
  • Agent design pattern react (docs)Branch from a decision Node to each action Node; let the agent direct flow between Nodes and loop back for multi-step.
  • Multi-Agent message queues (docs)Multi-agent coordination through asyncio.Queue message queues in shared storage; peer-to-peer rather than supervised.
  • Batch / Async variants (docs)Batch Nodes/Flows handle data-intensive tasks; Async Nodes/Flows wait for asynchronous tasks.

Patterns this full-code implements