# Automatic Workflow Search

> Treat the agent's workflow itself (a graph of LLM-invoking nodes connected by edges) as an artefact to search; use Monte Carlo Tree Search guided b...

- **Category**: Agentic AI
- **Subcategory**: Routing & Composition
- **Canonical URL**: https://designpattern.fyi/patterns/automatic_workflow_search/

---

## Description
**Intent**: Treat the agent's workflow itself (a graph of LLM-invoking nodes connected by edges) as an artefact to search; use Monte Carlo Tree Search guided by an eval benchmark to discover the best workflow, then deploy it.
**Context**: A team is building an agent for a repeatable task domain such as competitive coding, mathematical problem solving, or question answering, where each output can be scored automatically against a benchmark of known answers. They are choosing how to compose the agent out of named building blocks like a router, a planner, an ensembler, a reviewer, and a revise step, but no one on the team knows in advance which arrangement of these blocks will perform best on the target task.
**Solution**: Represent each candidate workflow as code or a graph of nodes (router, planner, ensemble, review, revise, executor). Use MCTS — selection by UCB-style scoring on past benchmark performance, expansion by code mutations or graph edits, simulation by running the workflow on the eval set, backpropagation of scores. After a search budget, deploy the best-scoring workflow. Use a library of operators (Ensemble, Review, Revise) to constrain the search space.


## Use Cases
- You have a stable eval benchmark that can score full workflows end-to-end.
- Designer bias toward familiar patterns is leaving real workflow improvements on the table.
- Compute budget for many workflow trials is available and amortised across many future runs.





## Trade-offs


### Advantages

- Discovers non-obvious workflow compositions a human designer would not try.

- Cheaper smaller models reach larger-model performance on some benchmarks.

- The search artefact is a reusable, inspectable workflow.




### Considerations & Drawbacks

- Eval set quality bounds discovered workflow quality.

- Compute-intensive: many workflow evaluations per search.

- Risk of overfitting to the eval set; held-out eval needed.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/automatic-workflow-search/)

