Key facts
- Workflows, agents, RAG, map-reduce, structured output, and multi-agent systems can all be drawn as graphs.
- The pattern name matters less than the state contract and the allowed transitions.
- A graph shape is a design tool even if the final implementation uses a heavier runtime.
One runtime, multiple shapes
Minimal orchestration becomes powerful when patterns stop being separate framework features and become graph shapes. A workflow is a line. An agent is a loop with a decision node. RAG is two related flows: offline indexing and online answer generation. Map-reduce is a fan-out and a fan-in. Multi-agent systems are multiple decision loops sharing a coordination protocol.
This framing is useful because the implementation surface stays small. You can add patterns by adding nodes and edges, not by adopting a new sub-framework for every product idea. The tradeoff is that you must design the state contract yourself.
Workflow: known steps in known order
Use a workflow when the order of operations is mostly deterministic. Examples include outline, draft, review; extract, normalize, validate; retrieve, answer, cite. The graph is usually a chain with occasional repair branches.
A good workflow node has a stable input and a stable output. The LLM can still produce variable text, but the node contract should be concrete enough that the next step can rely on it. If the next step has to infer what the previous step meant, your workflow boundary is too loose.
"decompose them into a chain"
Agent: decision loop with an action space
An agent is a graph where one node chooses the next action based on current state. The action space matters more than the prompt flourish. If the model can choose between overlapping actions, the graph will be hard to debug. If the actions are crisp, the agent becomes a controlled loop rather than an open-ended improvisation.
Minimal agents work best with a small action set: search, read, answer, ask, repair, stop. Each action should map to exactly one transition and should write its result back to shared state. The decision node can then inspect prior actions and decide whether another loop is useful.
decide - "search" >> search
decide - "answer" >> answer
search - "decide" >> decide RAG: two graphs joined by an index
RAG is easiest to reason about as two flows. The offline flow chunks documents, embeds chunks, and stores an index. The online flow embeds a query, retrieves relevant chunks, and generates an answer from the question plus context.
The original RAG paper frames the technique as combining model memory with explicit non-parametric memory. The minimal graph view does not change that research idea; it gives engineers a way to implement the pipeline without hiding retrieval behind a monolithic object.
Map-reduce: fan out, then aggregate
Map-reduce is the pattern for large inputs or large outputs that can be split into independent pieces. A batch node maps over chunks, files, accounts, pages, or records. A reduce node combines the partial results into a final answer, report, or decision.
The failure mode is over-parallelizing work that is not independent. If each chunk needs global context, map-reduce will produce tidy but incoherent partial results. Use it when the split is natural and the reduce step can honestly reconcile the pieces.
Structured output: validation as a node
Structured output should not be treated as "prompt harder." In a minimal graph, generation and validation are separate nodes. The generator returns candidate JSON or YAML. The validator parses it, checks schema, and returns either valid or repair. The repair node receives the errors and loops back to validation.
This makes output reliability visible. You can count repairs, inspect common schema failures, and replace the generator without rewriting the validator.
Multi-agent: coordination before personas
Multi-agent graphs are not improved by giving every node a theatrical role. The useful question is coordination: what state does each agent own, what actions can it take, how does it hand off work, and who decides completion? If those questions are unanswered, multiple agents usually multiply ambiguity.
A minimal multi-agent implementation can be just two decision loops and a shared task board. One agent proposes work. Another checks it. A coordinator moves the graph to done, revise, or escalate. The graph is more important than the names.
Sources used on this page
- Pocket Flow documentation The Pocket. Accessed July 6, 2026. Primary source for the 100-line claim, Graph + Shared Store abstraction, core patterns, and utility philosophy.
- Pocket Flow Agent pattern The Pocket. Accessed July 6, 2026. Primary source for agent loops, action spaces, and context-management guidance.
- Pocket Flow Workflow pattern The Pocket. Accessed July 6, 2026. Primary source for task decomposition into chained nodes.
- Pocket Flow RAG pattern The Pocket. Accessed July 6, 2026. Primary source for offline indexing and online query-answer nodes.
- Pocket Flow Map Reduce pattern The Pocket. Accessed July 6, 2026. Primary source for BatchNode map phases and reduce aggregation.
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks arXiv / NeurIPS 2020. Submitted May 22, 2020; accessed July 6, 2026. Primary research source for RAG as parametric plus non-parametric memory for generation.
Cite this page
Patterns as graphs. PocketFlow AI Guide. Updated July 6, 2026. https://pocketflowai.com/patterns/
PocketFlow AI Guide. "Patterns as graphs." Accessed July 6, 2026. https://pocketflowai.com/patterns/