
PocketFlow
The entire framework is about a hundred lines you can read in one sitting — everything else is yours to write
What is PocketFlow?
PocketFlow is a reaction to frameworks you cannot see the bottom of. The whole thing is roughly a hundred lines with no dependencies: a node does one piece of work in three phases — gather what it needs, do the work, decide what happens next — and the string a node returns picks which edge to follow. Nodes share one plain dictionary. That is the framework. There is no model client, no retry policy for a provider's particular errors, no tracing; you write those, and the cookbook of worked examples stands in for a reference manual. It suits people who would rather own a small amount of code than configure a large amount of someone else's.
What can you do with PocketFlow?
- Read the whole framework in one sitting — About a hundred lines with no dependencies, which means you can answer a question about its behaviour by looking rather than by searching an issue tracker.
- Three phases per node — Gathering the inputs, doing the work and deciding what happens next are separate methods, so the part that calls a model stays free of the surrounding bookkeeping.
- Route by returning a name — A node returns a string and that string picks the next edge, so branching and looping are written where the decision is actually made.
- Retry and fall back per node — Each node can be given a number of attempts and a fallback result, so one flaky step does not take the whole flow down.
- Batch and async variants of the same shapes — The same node and flow ideas come in versions for running over many items and for waiting on slow calls concurrently.
Before you choose PocketFlow
- Nothing wraps the model. The API call, the handling of a provider's rate limits and error shapes, and any record of what a run did are all code you write and maintain.
- The documentation is a cookbook of worked examples rather than a reference: for anything the examples do not cover, the hundred lines of source are the specification.
Star history
27 Aug to 30 Oct · +156
Frequently asked questions
Is PocketFlow free for commercial use?
PocketFlow is released under the MIT licence — OSI-approved open source, which permits commercial use.
How can PocketFlow be deployed?
PocketFlow is available as Runs locally / Self-hosted.