Skip to main content

Workflow Patterns

Combine the building blocks from the overview with these patterns to add structure and reliability to your agents:

Choose Your Approach

Consider these key factors:
  • Flexibility vs Control - How much freedom does the LLM need vs how tightly you must constrain its actions?
  • Error Tolerance - What are the consequences of mistakes in your use case?
  • Cost Considerations - More complex systems typically mean more LLM calls and higher costs
  • Maintenance - Simpler architectures are easier to debug and modify
Start with the simplest approach that meets your needs. Add complexity only when required by:
  1. Breaking down tasks into clear steps
  2. Adding tools for specific capabilities
  3. Implementing feedback loops for quality control
  4. Introducing multiple agents for complex workflows
Let’s look at examples of these patterns in action.

Patterns with Examples

These patterns, adapted from Anthropic’s guide on building effective agents, serve as building blocks you can combine to create comprehensive workflows. Each pattern addresses specific aspects of task execution. Combine them thoughtfully to build reliable solutions for complex problems.

Sequential Processing (Chains)

The simplest workflow pattern executes steps in a predefined order. Each step’s output becomes input for the next step, creating a clear chain of operations. Use this pattern for tasks with well-defined sequences, like content generation pipelines or data transformation processes.

Routing

This pattern lets the model decide which path to take through a workflow based on context and intermediate results. The model acts as an intelligent router, directing the flow of execution between different branches of your workflow. Use this when handling varied inputs that require different processing approaches. In the example below, the first LLM call’s results determine the second call’s model size and system prompt.

Parallel Processing

Break down tasks into independent subtasks that execute simultaneously. This pattern uses parallel execution to improve efficiency while maintaining the benefits of structured workflows. For example, analyze multiple documents or process different aspects of a single input concurrently (like code review).

Orchestrator-Worker

A primary model (orchestrator) coordinates the execution of specialized workers. Each worker optimizes for a specific subtask, while the orchestrator maintains overall context and ensures coherent results. This pattern excels at complex tasks requiring different types of expertise or processing.

Evaluator-Optimizer

Add quality control to workflows with dedicated evaluation steps that assess intermediate results. Based on the evaluation, the workflow proceeds, retries with adjusted parameters, or takes corrective action. This creates robust workflows capable of self-improvement and error recovery.