← Back to all projects

PocketFlow

The entire framework is about a hundred lines you can read in one sitting — everything else is yours to write

MIT
Stars
11.1k
Forks
1.2k
Open issues
75
Last commit
26 Jul 2026

What is PocketFlow?

PocketFlow is a reaction to frameworks you cannot see the bottom of. The whole thing is roughly a hundred lines with no dependencies: a node does one piece of work in three phases — gather what it needs, do the work, decide what happens next — and the string a node returns picks which edge to follow. Nodes share one plain dictionary. That is the framework. There is no model client, no retry policy for a provider's particular errors, no tracing; you write those, and the cookbook of worked examples stands in for a reference manual. It suits people who would rather own a small amount of code than configure a large amount of someone else's.

What can you do with PocketFlow?

  • Read the whole framework in one sitting — About a hundred lines with no dependencies, which means you can answer a question about its behaviour by looking rather than by searching an issue tracker.
  • Three phases per node — Gathering the inputs, doing the work and deciding what happens next are separate methods, so the part that calls a model stays free of the surrounding bookkeeping.
  • Route by returning a name — A node returns a string and that string picks the next edge, so branching and looping are written where the decision is actually made.
  • Retry and fall back per node — Each node can be given a number of attempts and a fallback result, so one flaky step does not take the whole flow down.
  • Batch and async variants of the same shapes — The same node and flow ideas come in versions for running over many items and for waiting on slow calls concurrently.

Before you choose PocketFlow

  • Nothing wraps the model. The API call, the handling of a provider's rate limits and error shapes, and any record of what a run did are all code you write and maintain.
  • The documentation is a cookbook of worked examples rather than a reference: for anything the examples do not cover, the hundred lines of source are the specification.

Frequently asked questions

Is PocketFlow free for commercial use?

PocketFlow is released under the MIT licence — OSI-approved open source, which permits commercial use.

How can PocketFlow be deployed?

PocketFlow is available as Runs locally / Self-hosted.

Documentation

Reproduced from the The-Pocket/PocketFlow README, published under MIT. Read the original ↗

English | 中文 | Español | 日本語 | Deutsch | Русский | Português | Français | 한국어

Pocket Flow is a 100-line minimalist LLM framework

  • Lightweight: Just 100 lines. Zero bloat, zero dependencies, zero vendor lock-in.

  • Expressive: Everything you love—(Multi-)Agents, Workflow, RAG, and more.

  • Agentic Coding: Let AI Agents (e.g., Cursor AI) build Agents—10x productivity boost!

Get started with Pocket Flow:

Why Pocket Flow?

Current LLM frameworks are bloated… You only need 100 lines for LLM Framework!

AbstractionApp-Specific WrappersVendor-Specific WrappersLinesSize
LangChainAgent, ChainMany (e.g., QA, Summarization)Many (e.g., OpenAI, Pinecone, etc.)405K+166MB
CrewAIAgent, ChainMany (e.g., FileReadTool, SerperDevTool)Many (e.g., OpenAI, Anthropic, Pinecone, etc.)18K+173MB
SmolAgentAgentSome (e.g., CodeAgent, VisitWebTool)Some (e.g., DuckDuckGo, Hugging Face, etc.)8K+198MB
LangGraphAgent, GraphSome (e.g., Semantic Search)Some (e.g., PostgresStore, SqliteSaver, etc.) 37K+51MB
AutoGenAgentSome (e.g., Tool Agent, Chat Agent)Many [Optional] (e.g., OpenAI, Pinecone, etc.)7K (core-only)+26MB (core-only)
PocketFlowGraphNoneNone100+56KB

How does Pocket Flow work?

The 100 lines capture the core abstraction of LLM frameworks: Graph!

From there, it’s easy to implement popular design patterns like (Multi-)Agents, Workflow, RAG, etc.

NameDifficultyDescription
Chat☆☆☆ DummyA basic chat bot with conversation history
Structured Output☆☆☆ DummyExtracting structured data from resumes by prompting
Workflow☆☆☆ DummyA writing workflow that outlines, writes content, and applies styling
Agent☆☆☆ DummyA research agent that can search the web and answer questions
RAG☆☆☆ DummyA simple Retrieval-augmented Generation process
Batch☆☆☆ DummyA batch processor that translates markdown into multiple languages
Streaming☆☆☆ DummyA real-time LLM streaming demo with user interrupt capability
Chat Guardrail☆☆☆ DummyA travel advisor chatbot that only processes travel-related queries
Majority Vote☆☆☆ DummyImprove reasoning accuracy by aggregating multiple solution attempts
Map-Reduce☆☆☆ DummyBatch resume qualification using map-reduce pattern
CLI HITL☆☆☆ DummyA command-line joke generator with human-in-the-loop feedback
Multi-Agent★☆☆ BeginnerA Taboo word game for async communication between 2 agents
Supervisor★☆☆ BeginnerResearch agent is getting unreliable… Let’s build a supervision process
Parallel★☆☆ BeginnerA parallel execution demo that shows 3x speedup
Parallel Flow★☆☆ BeginnerA parallel image processing showing 8x speedup
Thinking★☆☆ BeginnerSolve complex reasoning problems through Chain-of-Thought
Memory★☆☆ BeginnerA chat bot with short-term and long-term memory
Text2SQL★☆☆ BeginnerConvert natural language to SQL queries with an auto-debug loop
Code Generator★☆☆ BeginnerGenerate test cases, implement solutions, and iteratively improve code
MCP★☆☆ BeginnerAgent using Model Context Protocol for numerical operations
Agent Skills★☆☆ BeginnerRoute requests to reusable markdown skills and apply them in an agent flow
A2A★☆☆ BeginnerAgent wrapped with A2A protocol for inter-agent communication
Streamlit FSM★☆☆ BeginnerStreamlit app with finite state machine for HITL image generation
FastAPI WebSocket★☆☆ BeginnerReal-time chat interface with streaming LLM responses via WebSocket
FastAPI Background★☆☆ BeginnerFastAPI app with background jobs and real-time progress via SSE
Voice Chat★☆☆ BeginnerAn interactive voice chat application with VAD, STT, LLM, and TTS.
Judge★☆☆ BeginnerLLM-as-Judge evaluator-optimizer loop for iterative content refinement
Debate★☆☆ BeginnerAdversarial reasoning with two advocates and an impartial judge
Agentic RAG★☆☆ BeginnerAgent-driven RAG that decides which documents to read
Self-Healing Mermaid★☆☆ BeginnerGenerate Mermaid diagrams with automatic error recovery
Heartbeat★☆☆ BeginnerClawBot-like always-on periodic monitoring with nested flows
Lead Generation★★☆ IntermediateSales pipeline: scrape, enrich, score, and personalize emails
Newsletter★★☆ IntermediateAI newsletter curation: search, filter, summarize, and format
Invoice Processing★★☆ IntermediateExtract and validate invoice data from PDFs using vision
NotebookLM★★☆ IntermediateTurn documents into a podcast with two AI hosts
Deep Research★★☆ IntermediateRecursive map-reduce research with iterative refinement
Coding Agent★★★ AdvancedProduction coding agent with 6 tools, memory, and patch-as-subflow

👀 Want to see other tutorials for dummies? Create an issue!

How to Use Pocket Flow?

🚀 Through Agentic Coding—the fastest LLM App development paradigm-where humans design and agents code!

✨ Below are examples of more complex LLM Apps:

App NameDifficultyTopicsHuman DesignAgent Code
Website Chatbot Turn your website into a 24/7 customer support genius★★☆ MediumAgent RAGDesign DocFlow Code
Danganronpa Simulator Forget the Turing test. Danganronpa, the ultimate AI experiment!★★★ AdvancedWorkflow AgentDesign DocFlow Code
Codebase Knowledge Builder Life’s too short to stare at others’ code in confusion★★☆ MediumWorkflowDesign DocFlow Code
Build Cursor with Cursor We’ll reach the singularity soon …★★★ AdvancedAgentDesign DocFlow Code
Ask AI Paul Graham Ask AI Paul Graham, in case you don’t get in★★☆ MediumRAG Map Reduce TTSDesign DocFlow Code
Youtube Summarizer Explain YouTube Videos to you like you’re 5 ★☆☆ BeginnerMap ReduceDesign DocFlow Code
Cold Opener Generator Instant icebreakers that turn cold leads hot ★☆☆ BeginnerMap Reduce Web SearchDesign DocFlow Code
  • Want to learn Agentic Coding?

    • Check out my YouTube for video tutorial on how some apps above are made!

    • Want to build your own LLM App? Read this post! Start with this template!