Role-playing collaboration gives agents complementary roles and has them work through a task together in dialogue. One agent might pose a problem while another proposes a solution; their exchange can clarify requirements and improve the result step by step. section 4.1.3
A client and a developer
For code generation, a client agent describes requirements and tests the code, while a developer agent writes it. Their back-and-forth is useful when requirements need clarification. The same pattern can produce Q&A pairs by having one agent ask and another answer. section 4.1.3
Use the dialogue only when each role contributes something useful:
- Choose it for interactive clarification, multiperspective brainstorming, or creative back-and-forth. section 4.1.3
- Skip it for simple tasks where conversation adds latency without value. section 4.1.3
- Define roles clearly and provide an external check when errors matter: poorly defined roles can lead to circular exchanges, and agents can reinforce a mistaken assumption. section 4.1.3
Table 4.4 Architectural patterns overview
| Pattern |
When to use |
When not to use |
|---|---|---|
| Sequential pipeline, agent to agent |
Well-defined, ordered tasks need to be executed in sequence. |
Not all agents need to be executed every time. |
| Parallel delegation |
Multiple tasks or agents can be executed in parallel to improve performance. |
|
| Hierarchical coordination |
The user interface agent delegates to multiple agents on behalf of the user. |
No need for complex decision-making or command of agents |
| Iterative debate and refinement |
You want to review and double- or triple-check responses. |
The problem is trivial or aligns well with simple execution. |
| Voting/best-of-N (ensemble) |
Ambiguous problems that may have multiple interpretations or facets |
Unambiguous problems |
| Role-playing collaboration |
High creativity and novel outputs are desired and align well with the principal goals. |
Real-time systems or cases with low desired creativity |
| Conditional routing (branching) |
Customer support systems that may require human approvals or intervention |
|
| Peer-to-peer network |
Decentralized command increases system robustness and reduces or eliminates complete failure. |
Compare role-playing collaboration with other coordination patterns when deciding whether creative interaction, rather than a different execution strategy, is the goal. section 4.1.3
