Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsJul 2, 2026·3 min de lectura

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.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
PocketFlow Overview
Comando de instalación directa
npx -y tokrepo@latest install fb4bc241-7657-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con 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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados