🧩 PocketFlow:10.6k Stars 的 100 行 LLM 框架,让 Agent 自己构建 Agent / PocketFlow: The 100-Line LLM Framework That Lets Agents Build Agents
Repo: The-Pocket/PocketFlow | ⭐ 10,635 Stars | 🛠 Python | 📦 56KB | MIT
你在看 LangChain 那 405K 行代码头大吗?CrewAI 一个 pip install 下去 173MB 就没了?PocketFlow 告诉你——100 行就够了。
不是"核心模块 100 行",是整个框架就 100 行。去它的 __init__.py 看一眼,真的就 100 行 Python。零依赖、零厂商锁定、零臃肿。装个包 56KB,你手机空间都比它大。
对比一下:
| 框架 | 体积 |
|---|---|
| LangChain | 405K 代码 + 166MB |
| CrewAI | 18K 代码 + 173MB |
| PocketFlow | 100 行 + 56KB |
装一下看看
pip install pocketflow
或者直接把源码复制到项目里——真的就一个文件。
真实用法:10 行搭一个多 Agent 工作流
from pocketflow import Node, Flow
class ResearchNode(Node):
def exec(self, prep_res):
# 调你的 LLM 做研究
return "研究结果"
class WriteNode(Node):
def exec(self, prep_res):
# 根据研究结果写文章
return "文章草稿"
# 串起来
research = ResearchNode()
write = WriteNode()
research >> write # 和 bash 的 pipe 一样
flow = Flow(start=research)
flow.run(shared_data)
对,就这么简单。>> 就是连接两个节点。
PocketFlow 的设计哲学是 Graph——所有 LLM 框架的核心抽象就是一个图。有了图,什么 Agent、Multi-Agent、RAG、Workflow、Supervisor、Debate 这些设计模式,全都能搭出来。项目里自带 30+ 教程,从 Chat 到 MCP 到 A2A 到 Voice Chat 全有:
# 拉个例子直接跑
git clone https://github.com/The-Pocket/PocketFlow.git
cd PocketFlow/cookbook/pocketflow-agent
python agent.py
谁该用?
- 被 LangChain 抽象恶心到的朋友
- 想搞懂 Agent 框架到底在干什么的新手(100 行代码看一遍就全懂了)
- 需要轻量级嵌入到现有项目里的场景
- 想用 Cursor/Claude Code 让 AI 帮你写 Agent 的(README 里叫这"Agentic Coding")
English Version
🧩 PocketFlow: 10.6k Stars — 100-Line LLM Framework, Zero Bloat
Tired of LangChain's 405K lines and 166MB installs? PocketFlow is literally 100 lines of Python — zero dependencies, zero vendor lock-in, zero bloat. The entire framework fits in a 56KB package.
Install
pip install pocketflow
Or just copy the single file into your project.
Quick Start: 3-Node Research Workflow
from pocketflow import Node, Flow
class ResearchNode(Node):
def exec(self, prep_res):
return "research findings"
class WriteNode(Node):
def exec(self, prep_res):
return "article draft"
# Chain them together — the `>>` operator works like a pipe
research = ResearchNode()
write = WriteNode()
research >> write
flow = Flow(start=research)
flow.run(shared_data)
PocketFlow's core insight: every LLM framework is just a Graph. From that single abstraction, you can build Agents, Multi-Agent systems, RAG pipelines, Supervisor patterns, MCP tools, and more. The repo ships with 30+ cookbook examples covering all of them.
Who's it for?
- Developers who want to understand what their Agent framework is doing
- Anyone shipping lightweight LLM features into existing apps
- People who want their AI coding agent to build other agents ("Agentic Coding")
📡 Auto-generated project recommendation — not sponsored.