{"id":2490,"date":"2026-05-08T21:58:04","date_gmt":"2026-05-08T21:58:04","guid":{"rendered":"https:\/\/oqtacore.com\/blog\/pocketflow-the-100-line-llm-framework-changing-how-engineers-build-ai-agents-in\/"},"modified":"2026-05-08T21:59:28","modified_gmt":"2026-05-08T21:59:28","slug":"pocketflow-the-100-line-llm-framework-changing-how-engineers-build-ai-agents-in","status":"publish","type":"post","link":"https:\/\/oqtacore.com\/blog\/pocketflow-the-100-line-llm-framework-changing-how-engineers-build-ai-agents-in\/","title":{"rendered":"PocketFlow: The 100-Line LLM Framework Changing How Engineers Build AI Agents in 2026"},"content":{"rendered":"<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Table of Contents<\/h3>\n<ul>\n<li><a href=\"#what-is-pocketflow\">What Is PocketFlow?<\/a><\/li>\n<li><a href=\"#why-it-was-built-the-problem-with-langchain\">Why It Was Built: The Problem With LangChain<\/a><\/li>\n<li><a href=\"#core-architecture-how-pocketflow-actually-works\">Core Architecture: How PocketFlow Actually Works<\/a>\n<ul>\n<li><a href=\"#nodes\">Nodes<\/a><\/li>\n<li><a href=\"#flows\">Flows<\/a><\/li>\n<li><a href=\"#shared-store\">Shared Store<\/a><\/li>\n<li><a href=\"#actions\">Actions<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#key-design-patterns-pocketflow-supports\">Key Design Patterns PocketFlow Supports<\/a><\/li>\n<li><a href=\"#agentic-coding-ai-agents-building-ai-agents\">Agentic Coding: AI Agents Building AI Agents<\/a><\/li>\n<li><a href=\"#pocketflow-vs-langchain-vs-crewai-a-direct-comparison\">PocketFlow vs. LangChain vs. CrewAI: A Direct Comparison<\/a><\/li>\n<li><a href=\"#when-to-use-pocketflow--and-when-not-to\">When to Use PocketFlow \u2014 and When Not To<\/a><\/li>\n<li><a href=\"#getting-started-practical-first-steps\">Getting Started: Practical First Steps<\/a><\/li>\n<li><a href=\"#faqs\">FAQs<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">What Is PocketFlow?<\/h3>\n<p>PocketFlow is a minimalist Python framework for building LLM-powered applications and AI agents. Its entire core abstraction fits in roughly 100 lines of code \u2014 and that is a design constraint, not a marketing claim.<\/p>\n<p>Created by Zachary Huang and hosted at <a href=\"https:\/\/github.com\/the-pocket\/PocketFlow\" target=\"_blank\" rel=\"noopener\">github.com\/the-pocket\/PocketFlow<\/a>, the project has crossed 10,300 GitHub stars in 2026. The attention is warranted. Most LLM frameworks have grown bloated, opaque, and genuinely painful to debug in production. PocketFlow pushes back against that directly.<\/p>\n<p>The pitch is straightforward: give developers the smallest possible surface area that still handles the patterns they actually need \u2014 agents, RAG pipelines, batch processing, async workflows, parallel execution \u2014 without burying the mechanics under layers of abstraction.<\/p>\n<p>If you have spent time fighting LangChain&#8217;s internals or trying to trace why a CrewAI agent made a particular decision, PocketFlow&#8217;s philosophy will feel immediately familiar.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Why It Was Built: The Problem With LangChain<\/h3>\n<p>LangChain started as a useful toolkit. By the time most teams hit production, it had become something else: a sprawling dependency tree, inconsistent APIs across versions, and a debugging experience that required reading framework source code more than your own.<\/p>\n<p>The frustrations are well-documented across engineering forums and GitHub issues. Teams report spending more time understanding what LangChain is doing than building actual product logic. Prompt chains become hard to inspect. State management is implicit. When something breaks in a multi-step agent, isolating the failure means navigating abstractions you did not write and did not choose.<\/p>\n<p>CrewAI addressed some of this by focusing on multi-agent orchestration, but it brought its own opinions about roles, tasks, and crew structures \u2014 opinions that do not always map cleanly to what you are actually building.<\/p>\n<p>Zachary Huang&#8217;s starting point for PocketFlow was a direct response to this pattern: what is the minimum viable abstraction that lets an engineer build any LLM workflow without the framework getting in the way? The answer was a graph-based execution model with a shared data store, expressed in approximately 100 lines of Python.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Core Architecture: How PocketFlow Actually Works<\/h3>\n<p>PocketFlow has four components: Nodes, Flows, a Shared Store, and Actions. Understand those four things and you understand the entire framework.<\/p>\n<h4 style=\"font-size: 1.25rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Nodes<\/h4>\n<p>A Node is a unit of work. It runs a function \u2014 typically an LLM call, a tool invocation, or a data transformation \u2014 and returns an action string that determines what happens next.<\/p>\n<p>Each Node has three lifecycle methods:<\/p>\n<ul>\n<li><code>prep(shared)<\/code> \u2014 reads from the shared store and prepares inputs<\/li>\n<li><code>exec(prep_result)<\/code> \u2014 runs the main logic, usually the LLM call or tool<\/li>\n<li><code>post(shared, prep_result, exec_result)<\/code> \u2014 writes results back to the shared store and returns an action<\/li>\n<\/ul>\n<p>The separation is intentional. It keeps side effects predictable and makes each step independently testable. You can unit test <code>exec<\/code> in isolation without running the full pipeline.<\/p>\n<h4 style=\"font-size: 1.25rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Flows<\/h4>\n<p>A Flow connects Nodes into a directed graph. You define transitions between nodes based on the action strings returned by each Node&#8217;s <code>post<\/code> method. The Flow handles traversal \u2014 it calls each Node in sequence, follows the returned action to the next Node, and continues until it reaches a terminal state.<\/p>\n<p>This is where the graph model earns its keep. Branching, looping, and conditional routing are expressed as graph edges, not as nested Python control flow buried inside framework callbacks.<\/p>\n<h4 style=\"font-size: 1.25rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Shared Store<\/h4>\n<p>The Shared Store is a plain Python dictionary passed through every Node in a Flow. It holds all state: inputs, intermediate results, tool outputs, conversation history, final outputs \u2014 everything.<\/p>\n<p>There is nothing magical about it. Every Node reads from and writes to the same dictionary, which means state is completely transparent at every step. That matters a lot when you are debugging a multi-step agent at 2am.<\/p>\n<h4 style=\"font-size: 1.25rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Actions<\/h4>\n<p>Actions are strings returned by a Node&#8217;s <code>post<\/code> method. They tell the Flow which Node to execute next. A Node might return <code>\"success\"<\/code>, <code>\"retry\"<\/code>, <code>\"clarify\"<\/code>, or any string you define. The Flow maps those strings to the next Node in the graph.<\/p>\n<p>This gives you explicit control over routing without a separate routing layer or a dedicated &#8220;router&#8221; agent.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Key Design Patterns PocketFlow Supports<\/h3>\n<p>PocketFlow&#8217;s documentation covers several patterns that handle the majority of production LLM use cases. Each one is implemented as a composition of Nodes and Flows \u2014 not a separate module bolted on.<\/p>\n<p><strong>Agent pattern.<\/strong> A Node calls an LLM, parses a tool-use decision, executes the tool, and loops back to the LLM with the result. The loop continues until the LLM signals completion. Because the loop is expressed as graph edges, every iteration is inspectable.<\/p>\n<p><strong>RAG (Retrieval-Augmented Generation).<\/strong> One Node retrieves relevant documents from a vector store. A second constructs a prompt with those documents and calls the LLM. The Shared Store holds both the retrieved context and the final response. Extending it with re-ranking or multi-hop retrieval is straightforward.<\/p>\n<p><strong>Batch processing.<\/strong> A BatchNode runs the same logic across a list of inputs, sequentially or in parallel. Useful for document processing pipelines, bulk classification, or any workload where you apply the same LLM operation to many items.<\/p>\n<p><strong>Async execution.<\/strong> AsyncNode and AsyncFlow variants support non-blocking execution for running multiple LLM calls concurrently without blocking the event loop.<\/p>\n<p><strong>Parallel execution.<\/strong> ParallelBatchNode runs batch items concurrently using async. For latency-sensitive pipelines where independent subtasks can run simultaneously, this cuts total wall-clock time significantly.<\/p>\n<p><strong>Workflow pattern.<\/strong> A structured sequence of Nodes where each step depends on the previous output. Useful for multi-step reasoning, document generation, or any pipeline where order and data flow matter.<\/p>\n<p>All of these patterns compose. You can build a multi-agent system where each agent is a Flow and a parent Flow orchestrates them \u2014 all within the same 100-line core.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Agentic Coding: AI Agents Building AI Agents<\/h3>\n<p>One of the more interesting applications of PocketFlow is what Huang calls &#8220;agentic coding&#8221; \u2014 using AI agents to write, test, and iterate on code, including the code for other AI agents.<\/p>\n<p>The PocketFlow-Tutorial-Codebase-Knowledge project demonstrates this concretely. It is a pipeline that takes a GitHub repository as input, analyzes the codebase, identifies the most important abstractions, and generates a structured tutorial explaining how the code works. The pipeline itself is built with PocketFlow.<\/p>\n<p>This matters for a couple of reasons. First, it shows that PocketFlow&#8217;s architecture is expressive enough to handle complex, multi-step reasoning without requiring framework extensions. Second, it points to a practical workflow for teams that want to use LLMs to accelerate their own development \u2014 not just as a product feature, but as a tool inside the development process itself.<\/p>\n<p>For teams building production AI agents, the implication is real. If your agents can help write and test the next version of themselves, iteration speed changes substantially. PocketFlow&#8217;s transparency makes this safer: because every step is inspectable, you can verify what the agent produced before it runs in production.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">PocketFlow vs. LangChain vs. CrewAI: A Direct Comparison<\/h3>\n<table>\n<thead>\n<tr>\n<th>Dimension<\/th>\n<th>PocketFlow<\/th>\n<th>LangChain<\/th>\n<th>CrewAI<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Core abstraction size<\/td>\n<td>~100 lines<\/td>\n<td>Thousands of lines across modules<\/td>\n<td>Hundreds of lines + role\/task model<\/td>\n<\/tr>\n<tr>\n<td>State management<\/td>\n<td>Explicit shared dict<\/td>\n<td>Implicit, varies by chain type<\/td>\n<td>Role-scoped, less transparent<\/td>\n<\/tr>\n<tr>\n<td>Debugging<\/td>\n<td>Step-by-step, transparent<\/td>\n<td>Difficult, requires tracing internals<\/td>\n<td>Moderate, agent logs help<\/td>\n<\/tr>\n<tr>\n<td>Flexibility<\/td>\n<td>High \u2014 any pattern via graph<\/td>\n<td>High but complex<\/td>\n<td>Moderate \u2014 opinionated about agents<\/td>\n<\/tr>\n<tr>\n<td>Learning curve<\/td>\n<td>Low<\/td>\n<td>High<\/td>\n<td>Medium<\/td>\n<\/tr>\n<tr>\n<td>Production stability<\/td>\n<td>Predictable<\/td>\n<td>Version-sensitive<\/td>\n<td>Improving<\/td>\n<\/tr>\n<tr>\n<td>Multi-agent support<\/td>\n<td>Yes, via nested Flows<\/td>\n<td>Yes, via agent executors<\/td>\n<td>Yes, native<\/td>\n<\/tr>\n<tr>\n<td>Async\/parallel<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<td>Partial<\/td>\n<\/tr>\n<tr>\n<td>LLM vendor lock-in<\/td>\n<td>None<\/td>\n<td>Minimal<\/td>\n<td>Minimal<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The honest summary: LangChain gives you the most pre-built integrations, but you pay for them in complexity and opacity. CrewAI is useful when your problem maps naturally to a role-based multi-agent structure. PocketFlow wins when you want full control, fast iteration, and a codebase your team can actually read.<\/p>\n<p>For teams building custom AI agents where the logic is specific to your domain, PocketFlow&#8217;s minimal surface area is a genuine advantage. You spend time on your problem, not on the framework.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">When to Use PocketFlow \u2014 and When Not To<\/h3>\n<p><strong>Use PocketFlow when:<\/strong><\/p>\n<ul>\n<li>You are building a custom AI agent where the workflow logic is domain-specific and you need full visibility into every step<\/li>\n<li>Your team is comfortable with Python and wants to own the architecture without depending on framework abstractions<\/li>\n<li>You are prototyping quickly and need to iterate on agent logic without fighting framework conventions<\/li>\n<li>You are building agentic coding tools or meta-level pipelines where transparency is essential<\/li>\n<li>You want to minimize your dependency footprint in a production system<\/li>\n<\/ul>\n<p><strong>Consider a heavier framework when:<\/strong><\/p>\n<ul>\n<li>You need extensive pre-built integrations with data sources, vector stores, or third-party APIs and do not want to write those connectors yourself<\/li>\n<li>Your team is less experienced with LLM architecture and benefits from opinionated structure<\/li>\n<li>You are building a role-based multi-agent system where CrewAI&#8217;s abstractions map naturally to your problem<\/li>\n<li>You need enterprise support, documentation, and a large community for a regulated or risk-sensitive deployment<\/li>\n<\/ul>\n<p>The decision is not binary. Some teams use PocketFlow for core agent logic and pull in specific integrations from other libraries where needed. Because PocketFlow does not try to own the entire stack, that kind of selective composition is straightforward.<\/p>\n<p>One practical note: PocketFlow&#8217;s minimalism means you write more explicit code. For experienced engineers, that is a feature. For teams that prefer convention over configuration, it can be friction. Know your team before you choose your framework.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Getting Started: Practical First Steps<\/h3>\n<p>PocketFlow is on PyPI and installs with a single command:<\/p>\n<pre><code class=\"language-bash\">pip install pocketflow\r\n<\/code><\/pre>\n<p>The GitHub repository at <a href=\"https:\/\/github.com\/the-pocket\/PocketFlow\" target=\"_blank\" rel=\"noopener\">github.com\/the-pocket\/PocketFlow<\/a> includes a cookbook with implementations of every major pattern: basic agents, RAG pipelines, multi-agent flows, batch processing, and the agentic coding tutorial. That cookbook is the fastest way to understand how the pieces fit together.<\/p>\n<p>A minimal agent in PocketFlow follows this structure:<\/p>\n<ol>\n<li>Define your Nodes, each with <code>prep<\/code>, <code>exec<\/code>, and <code>post<\/code> methods<\/li>\n<li>Instantiate a Flow and connect Nodes with action-based transitions<\/li>\n<li>Initialize a Shared Store dictionary with your input data<\/li>\n<li>Call <code>flow.run(shared)<\/code> and inspect the results in the shared store<\/li>\n<\/ol>\n<p>For production deployment, the same principles that apply to any LLM system apply here: instrument your Nodes to log inputs and outputs, set retry logic at the Node level for LLM call failures, and version your prompts separately from your Node logic so you can iterate without redeploying.<\/p>\n<p>The framework choice is one decision in a longer set of architectural choices that determine whether an agent system holds up under production load. Teams at <a href=\"https:\/\/oqtacore.com\">Oqtacore<\/a> have worked through these decisions across 50+ AI, Web3, and enterprise projects \u2014 and the downstream consequences of getting the architecture wrong show up fast once you are running real traffic.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">FAQs<\/h3>\n<p><strong>What is PocketFlow and who built it?<\/strong><br \/>\nPocketFlow is a minimalist Python framework for building LLM applications and AI agents. It was created by Zachary Huang with the goal of expressing the full range of LLM design patterns in approximately 100 lines of core code. The project is open source and available at github.com\/the-pocket\/PocketFlow.<\/p>\n<p><strong>How does PocketFlow compare to LangChain for production AI agents?<\/strong><br \/>\nPocketFlow is significantly smaller and more transparent. It has no implicit state management and no large dependency tree. For teams that need full visibility into agent execution and want to own their architecture, it is easier to debug and maintain in production. LangChain offers more pre-built integrations but introduces considerably more complexity.<\/p>\n<p><strong>Can PocketFlow handle multi-agent systems?<\/strong><br \/>\nYes. You can nest Flows inside other Flows to create multi-agent architectures. Each agent is a Flow with its own Nodes and Shared Store, and a parent Flow can orchestrate multiple agents. The graph-based routing model handles coordination between agents without requiring a separate orchestration layer.<\/p>\n<p><strong>What is agentic coding in the context of PocketFlow?<\/strong><br \/>\nAgentic coding means using AI agents to write, analyze, and iterate on code \u2014 including the code for other AI agents. The PocketFlow-Tutorial-Codebase-Knowledge project is a concrete example: a PocketFlow pipeline that analyzes a GitHub repository and generates a structured tutorial explaining the codebase. It demonstrates how PocketFlow&#8217;s transparency makes it practical to use LLMs as development tools, not just product features.<\/p>\n<p><strong>Is PocketFlow suitable for enterprise production deployments?<\/strong><br \/>\nPocketFlow&#8217;s minimalism is an advantage for teams that want control and transparency, but it means you write more explicit code and own more of the infrastructure decisions. For enterprise deployments, you will need to add your own observability, retry logic, and integration layers. The framework does not prevent production use \u2014 it just does not abstract those concerns away for you.<\/p>\n<p><strong>What Python version and dependencies does PocketFlow require?<\/strong><br \/>\nPocketFlow is designed to have minimal dependencies. It works with standard Python 3.8+ and does not require a specific LLM provider SDK \u2014 you bring your own LLM client. Check the GitHub repository for the current dependency list, as it may be updated.<\/p>\n<p><strong>When should I choose CrewAI over PocketFlow?<\/strong><br \/>\nCrewAI is a better fit when your problem maps naturally to a role-based agent structure \u2014 for example, a research pipeline with distinct roles like researcher, writer, and reviewer. PocketFlow is a better fit when your agent logic is custom, domain-specific, or requires step-level transparency that CrewAI&#8217;s abstractions obscure.<\/p>\n<hr \/>\n<h3 style=\"font-size: 1.5rem; line-height: 1.4; margin: 1.5em 0 0.5em;\">Conclusion<\/h3>\n<p>PocketFlow is not trying to be everything. That is exactly why it is worth evaluating seriously.<\/p>\n<p>If you are building AI agents in 2026 and you have spent time debugging opaque framework behavior, the 100-line constraint is a signal worth taking seriously. Smaller surface area means fewer surprises in production, faster iteration on agent logic, and a codebase your team can actually own.<\/p>\n<p>Start with the cookbook, implement one pattern end-to-end, and evaluate whether the explicit control is worth the additional code you write. For most custom agent projects, it is.<\/p>\n<p>If you are working on a production AI agent project and need engineering depth to get from architecture to deployment, the team at <a href=\"https:\/\/oqtacore.com\">Oqtacore<\/a> builds exactly this kind of system. Working on something similar? Let&#8217;s talk.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents What Is PocketFlow? Why It Was Built: The Problem With LangChain Core Architecture: How PocketFlow Actually Works Nodes Flows Shared Store Actions Key Design Patterns PocketFlow Supports Agentic Coding: AI Agents Building AI Agents PocketFlow vs. LangChain vs. CrewAI: A Direct Comparison When to Use PocketFlow \u2014 and When Not To Getting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2489,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_mo_disable_npp":"","yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-2490","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured-articles"],"acf":{"image":2489},"yasr_visitor_votes":{"number_of_votes":0,"sum_votes":0,"stars_attributes":{"read_only":false,"span_bottom":false}},"_links":{"self":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts\/2490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/comments?post=2490"}],"version-history":[{"count":3,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts\/2490\/revisions"}],"predecessor-version":[{"id":2494,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts\/2490\/revisions\/2494"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/media\/2489"}],"wp:attachment":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/media?parent=2490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/categories?post=2490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/tags?post=2490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}