PocketFlow
Pocket Flow: 100-line LLM framework. Let Agents build Agents!
A tiny 100-line Python library for building AI agent workflows, connect steps into a graph where each step's output decides what runs next, with no vendor lock-in and no heavy dependencies.
PocketFlow is a minimalist Python library for building AI-powered applications that use large language models. Its entire core fits in exactly 100 lines of code, compared to popular alternatives that run into tens of thousands of lines and install hundreds of megabytes of dependencies. The library has no built-in wrappers for specific AI providers or cloud services, so you can connect it to whichever AI model or database you prefer.
The central idea is that most AI application patterns, such as autonomous agents, multi-step workflows, and retrieval-augmented generation (a technique where an AI looks up relevant documents before answering), can all be expressed as graphs. A graph here just means a set of steps connected by transitions, where the output of one step decides which step runs next. PocketFlow gives you that graph structure and leaves everything else up to you.
The project includes a cookbook of tutorial examples covering common use cases: a basic chatbot that remembers conversation history, an agent that searches the web to answer questions, a workflow that outlines then writes then formats a document, a system that processes a large batch of files, and more. Each example shows how to wire together nodes in a graph to accomplish real tasks.
Installation is a single pip command, or you can just copy the 100-line source file directly into your project. The library is also available in TypeScript, Java, C++, Go, Rust, and PHP for teams working in other languages. Documentation and video tutorials are linked from the README.
The intended audience is developers who want to build AI agent pipelines without adopting a large opinionated framework. It is MIT licensed and actively maintained with a Discord community.
Where it fits
- Build a multi-step AI workflow that outlines, writes, and formats a document in sequential stages.
- Create an AI agent that searches the web for real-time information before generating an answer.
- Wire together a chatbot that maintains conversation history using a simple graph of nodes.
- Process a large batch of files through an AI pipeline with multiple parallel or sequential steps.