Skip to main content
Back

PocketFlow Squeezes an Entire AI Agent Framework Into 100 Lines

A minimalist framework that fits its entire core in 100 lines of Python, betting that graph abstractions beat vendor wrappers for building agents.

Pro

Repo, Full Access
  • Pocket Flow packs an entire LLM agent framework into 100 lines of Python with zero dependencies.
  • Core abstraction is a directed graph: Nodes, Actions as edges, and a Shared Store dictionary.
  • Supports Agents, Multi-Agent, Workflow, RAG, Map-Reduce, and Async/Parallel execution patterns.
  • Compares favorably on size: 56KB versus LangChain's 166MB and 405,000 lines.
  • Promotes Agentic Coding where humans design flows and Cursor-style agents write the node code.
  • Available as pip install pocketflow plus TypeScript, Java, Go, Rust, C++, PHP ports.

Most agent frameworks ship as sprawling libraries. LangChain weighs in at roughly 405,000 lines and 166MB, CrewAI at 18,000 lines and 173MB. Pocket Flow takes the opposite bet. The entire core is a single Python file, and the pitch is that once you strip away vendor wrappers and app-specific helpers, everything you actually want from an LLM framework collapses into one abstraction: a graph.

The project has quietly picked up momentum, sitting at over 10,700 stars and 1,200 forks on GitHub. The core lives in pocketflow/__init__.py, with zero external dependencies and zero vendor lock-in. Install it with pip install pocketflow, or copy the file straight into your project.

One file, one mental model

Pocket Flow models any LLM application as a directed graph with a shared memory space. Node handles a simple LLM task. Flow connects nodes through Actions (labeled edges). Shared Store enables communication between nodes within flows. A node returns an action string, and the flow uses that string to decide which node runs next. That is essentially the whole mental model.