Choose Agent Patterns by Task Shape
Choose Agent Patterns by Task Shape
The agent world now has a pattern for everything.
There is a pattern for tool use, a pattern for reflection, a pattern for planning, a pattern for search, a pattern for retrieval, a pattern for memory, a pattern for code editing, a pattern for browser control, a pattern for debate, and a pattern for making several models vote.
That is useful. It is also dangerous.
A long list of patterns can make a team feel more strategic while it is actually becoming less disciplined. Every new architecture looks like a possible answer. Every failure invites another pattern. The system grows sideways. Soon the product has a zoo, but no operating manual.
The question is not “Which agent architecture is best?”
The question is: what is the shape of this task?
Pattern fit beats pattern fashion
A task has a shape before it has an architecture.
Some tasks require external tools. Some require grounded retrieval. Some require long-horizon planning. Some require safe refusal. Some require codebase edits. Some require comparing many candidates. Some require remembering user-specific history. Some require navigating a browser. Some require doing nothing until a human approves.
If the task shape is unclear, architecture selection becomes taste.
This is how systems end up using multi-agent debate for simple extraction, GraphRAG for a narrow document lookup, reflection loops for tasks with no verification signal, or browser agents where a direct API call would be safer.
The pattern may be impressive. The fit may still be wrong.
A practical routing table
I prefer to start with a boring routing table.
| Task shape | Better starting pattern | Why |
|---|---|---|
| needs tool calls with observations | ReAct | action and observation alternate naturally |
| needs a sequence before execution | planner/executor | the plan can be inspected before actions |
| needs grounded answers from documents | Self-RAG or Corrective RAG | retrieval quality must be checked |
| needs entity/community reasoning | GraphRAG | relationships matter more than chunks |
| needs repository changes | SWE-agent style loop | files, tests and diffs are first-class |
| needs web interaction | browser/computer-use agent | page state is part of the task |
| needs risky side effects | dry-run + approval gate | irreversibility must be scored before execution |
| needs candidate selection | feature extraction + deterministic picker | avoid flat model scoring |
| needs long-term adaptation | workflow or episodic memory | previous execution matters |
This table is not final. It is a starting discipline.
The routing layer should be editable, testable, and explicit. It should say why a task goes to a pattern. It should preserve the decision in the trace. It should make routing failures visible.
Do not route by noun
A common mistake is to route by surface noun.
If the task mentions “documents”, use RAG. If it mentions “code”, use coding agent. If it mentions “web”, use browser agent. If it mentions “hard reasoning”, use Tree of Thoughts.
That is too shallow.
The better router looks at constraints:
- Is the source of truth external or internal?
- Is the task reversible?
- Does success have an objective verification signal?
- Is latency more important than completeness?
- Does the agent need to modify state?
- Does the task require exploration or execution?
- Are there safety constraints that override usefulness?
- Does the answer need citations, tests, screenshots, logs, or approvals?
A support question about a document may not need RAG if the relevant passage is already in context. A coding task may not need an autonomous code agent if it is a two-line config change. A web task may not need browser control if an API exists. A reasoning task may not need tree search if the correct move is to ask for missing input.
Routing is not keyword matching. It is architectural triage.
Meta-controller, but not magic
It is tempting to build a meta-controller and let it choose everything. That can work, but only if the meta-controller is not just another vague prompt.
A real meta-controller should output a structured routing decision:
{
"task_shape": "risky_file_operation",
"selected_pattern": "dry_run_policy_gate",
"reason": "task modifies durable state and lacks rollback evidence",
"required_evidence": ["diff", "backup", "approval"],
"fallback": "ask_human"
}
Then deterministic policy can check whether the selected pattern is allowed.
For example, a meta-controller should not be able to send a production deletion task directly to an unrestricted tool-use agent. The routing layer itself needs policy.
The controller proposes. The runtime permits.
Wrong pattern, right model, bad system
Many agent failures are blamed on the model when the real failure is pattern mismatch.
A strong model inside the wrong architecture still fails.
If a task requires evidence and the pattern only produces prose, the system fails. If a task requires reversible execution and the pattern has no dry-run, the system fails. If a task requires repository-level verification and the pattern cannot run tests, the system fails. If a task requires durable learning and the pattern has no memory boundary, the system fails.
This is why architecture matters. It encodes what the system can notice, preserve, verify, and refuse.
The strategy layer
A real agent strategy is not a list of architectures. It is a routing discipline:
task intake
-> classify task shape
-> select allowed pattern
-> declare evidence requirements
-> execute with trace
-> evaluate outcome
-> update routing rules when failure repeats
The last step matters. Routing should learn from failures, but not by silently changing behavior inside the model. It should change through explicit rules, tests, and traces.
If GraphRAG keeps being too slow for simple lookups, add a cheaper route. If a code agent keeps claiming success without tests, tighten the evidence gate. If reflection loops keep polishing weak answers, replace scoring with feature extraction.
This is how the zoo becomes a platform.
Final thought
Agent patterns are tools. A tool collection is not a strategy.
The strategy is the layer that decides when a tool is appropriate, what evidence it must return, what risks block execution, and how failures update the system.
Do not ask which architecture is best. Ask what the task is shaped like, what can go wrong, and what proof the runtime needs before it trusts the result.
That question is less fashionable. It is also much closer to engineering.