Configs2026年7月2日·1 分钟阅读

PocketFlow — Minimalist 100-Line LLM Agent Framework

A tiny yet powerful LLM framework in just 100 lines of code that supports multi-agent workflows, RAG, and tool use.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
PocketFlow Overview
直接安装命令
npx -y tokrepo@latest install fb4bc241-7657-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

PocketFlow is an ultra-minimalist LLM framework whose core fits in approximately 100 lines of Python. Despite its small size, it supports agentic workflows, RAG pipelines, multi-agent collaboration, and tool calling through a composable graph-based design.

What PocketFlow Does

  • Defines workflows as directed graphs of Node objects with customizable prep, exec, and post steps
  • Supports branching, looping, and conditional routing between nodes via action-based transitions
  • Enables multi-agent patterns by composing multiple flows together
  • Provides batch processing for parallel workload execution
  • Keeps the core dependency-free so you bring your own LLM provider and tools

Architecture Overview

PocketFlow models every workflow as a graph where each Node runs three phases: prep (gather inputs), exec (call an LLM or tool), and post (process results and decide the next action). Nodes return action strings that determine graph traversal. A Flow wraps the graph and manages state as a shared dictionary passed between nodes. This architecture handles linear chains, branching decisions, retry loops, and fan-out patterns with the same primitives.

Self-Hosting & Configuration

  • Install with pip install pocketflow on Python 3.8+
  • No external dependencies in the core library — add your preferred LLM SDK separately
  • Define nodes by subclassing Node and implementing prep, exec, and post methods
  • Connect nodes with node.add_successor(next_node, action="action_name")
  • Use BatchNode and BatchFlow for parallel processing of multiple items

Key Features

  • Entire framework core is approximately 100 lines — easy to read, audit, and modify
  • Zero vendor lock-in: works with any LLM API (OpenAI, Anthropic, local models)
  • Graph-based composition supports chains, branches, loops, and nested flows
  • Batch processing mode for parallelizing work across multiple inputs
  • Communication patterns for multi-agent setups via shared state and nested flows

Comparison with Similar Tools

  • LangChain — Feature-rich but complex; PocketFlow trades breadth for simplicity and transparency
  • LangGraph — Graph-based agent framework; PocketFlow achieves similar patterns in far less code
  • CrewAI — Multi-agent focus with role-based abstractions; PocketFlow is lower-level and more flexible
  • DSPy — Programmatic prompt optimization; PocketFlow focuses on workflow composition
  • Haystack — Pipeline-based NLP framework; PocketFlow is intentionally minimal with no built-in components

FAQ

Q: How can 100 lines of code support complex workflows? A: PocketFlow provides only the graph execution primitives. LLM calls, tool use, and retrieval are implemented in your Node subclasses using any library you choose.

Q: Does it support streaming responses? A: The core does not handle streaming directly, but your Node's exec method can use streaming LLM clients and yield results through shared state.

Q: Is PocketFlow production-ready? A: The framework is stable and used in production by multiple teams. Its simplicity makes it easy to debug and extend.

Q: Can I use it for RAG pipelines? A: Yes. Create nodes for retrieval, context assembly, and generation, then wire them into a Flow.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产