Anthropic published a very popular blog, Building Effective Agents, a research post describing the most useful patterns for building production AI systems. The patterns are practical, proven, and widely adopted.
The good news: you can build every one of those patterns in Laravel today, with very little code, using the Laravel AI SDK.
All the examples in this post use just the agent() helper function, a single line to spin up an agent. That alone is enough to show how powerful these patterns can be. But the Laravel AI SDK doesn't stop there. You can bring your own dedicated agent classes, attach tools, configure models, add middleware, and build workflows as complex as production demands.
Install the Laravel AI SDK via Composer: composer require laravel/ai.
What Is a Multi-Agent Workflow?
A single LLM call works great for simple tasks. But for complex work, such as reviewing code, generating polished emails, or routing support tickets, you want multiple agents working together, each focused on a specific task.
Multi-agent workflows let you do multiple things:
- Break a task into ordered steps.
- Run independent steps in parallel.
- Route inputs to the right specialist.
- Evaluate and refine outputs in a loop.
The Five Patterns (and How You Can Use Them with the Laravel AI SDK)
1. Prompt Chaining
One agent's output becomes the next agent's input.
Think of it as an assembly line. Each step does one thing well and hands the result forward. This is the simplest and most common pattern.
Example: Cold Email Generator
Let’s think of a simple workflow: Draft → review quality → improve if needed.
With the Laravel AI SDK, the three agents are orchestrated through a Pipeline . Each step receives the full payload and passes it forward, enriched:
Each pipeline step is backed by a dedicated agent:
✅ When to use it: This works for tasks with a clear sequence: generate, validate, refine, format. Each step should do one job well.
2. Routing
Classify the input first, then send it to the right agent.
Instead of a single agent handling everything, a classifier examines the input and selects the best specialist. Different query types get different instructions. Different complexity levels get different models.
Example: Customer Support
Workflow: Classify → pick the right instructions → choose a cheap or capable model based on complexity.
#[UseCheapestModel] Attribute can be added to StandardSupportAgent for making simple queries run fast and cheaply. Complex queries go to the full model. The classifier decides which is which.
✅ When to use it: This is ideal when inputs vary widely in type or complexity and a single prompt can't handle all cases well.
3. Parallelization
Run independent agents at the same time.
When steps don't depend on each other, there's no reason to run them one by one. Laravel's Concurrency::run() is PHP's equivalent of Promise.all() . You can kick off all agents at once, and collect the results when they're done.
Example: Code Review
Workflow: Three specialist agents review code simultaneously. A fourth synthesizes their findings.
Three agents review in parallel. The summary agent only runs after all three are done, giving it the full picture.
✅ When to use it: Multiple independent analyses of the same input, or when you need several specialists to each look at the same problem.
4. Orchestrator-Workers
One agent coordinates; worker agents do the work.
The orchestrator understands the full task and decides what needs to be done. Workers are specialists—they only handle their specific job. The orchestrator calls them automatically as tools, in whatever order makes sense.
Example: Feature Implementation
Orchestrator agent receives a feature request, then automatically calls worker agents to create, modify, or delete files.
Each tool is itself an agent() — a sub-agent with its own focused instructions:
You don't hardcode which files to change or what order to process them. The orchestrator figures that out from the feature request.
✅ When to use it: Complex tasks where the required steps aren't known upfront — the model needs to plan and delegate dynamically.
5. Evaluator-Optimizer
The pattern is generate → evaluate → improve, in a loop.
Sometimes one pass isn't enough. The evaluator-optimizer pattern runs output through a quality check and keeps refining until it meets the bar or hits the iteration limit.
Example: Content Writer
Workflow: Write a paragraph → score it → rewrite if not approved → repeat up to three times.
The evaluator uses structured output to return a score, an approval flag, and a list of specific issues. The writer only retries if approved is false , and it knows exactly what to fix.
✅ When to use it: When you have clear quality criteria and the output benefits from iterative refinement: translations, writing, code generation.
Laravel AI SDK Simplifies Multi-Agent Work
Anthropic's research identified these patterns because they consistently work in production. What's striking is how little code they take in Laravel using the Laravel AI SDK.
| Pattern | Use when |
|---|---|
| Prompt Chaining | Fixed sequence of steps |
| Routing | Inputs vary in type or complexity |
| Parallelization | Independent tasks can run simultaneously |
| Orchestrator-Workers | Dynamic planning and delegation |
| Evaluator-Optimizer | Quality bar requires iteration |
Start simple. A single agent() call handles most tasks. Reach for these patterns only when the task genuinely needs them, and when you do, you'll find they're straightforward to implement.
You can install the Laravel AI SDK via Composer. Just run composer require laravel/ai.
To learn more about other Laravel AI tools, like Laravel Boost and MCP, check out this blog post.
