RoleFlow: Self-Evolving Multi-Role Agentic Collaboration via Structural Adaptation
Organizations: University of Maryland, College Park · University of Pittsburgh · The University of Texas at Dallas
Abstract
Large language model (LLM) based multi-agent systems often rely on predefined collaboration structures, limiting their adaptability to evolving task requirements. Although recent approaches enable dynamic orchestration, trajectory-level rewards they apply assign one outcome to each decision, ofen struggling to identify the contributions of individual structural changes. We propose RoleFlow, a self-evolving multi-role agentic system that refines collaboration structures through feedback-driven atomic edits and on-demand role synthesis. To make structural adaptation learnable, we introduce Single-Edit Counterfactual Policy Optimization (SECPO), which evaluates each edit against its no-edit counterpart at the same chain state and assigns targeted credit to edit-specific tokens. Across seven benchmarks spanning four domains, RoleFlow achieves the optimal average performance, surpassing the strongest competitor by 4.7 points. It leads on all three multi-hop QA benchmarks by 3.2-7.5 F1 points and also shows supremacy on mathematical reasoning, web interaction, and code generation. Further analyses demonstrate cross-benchmark transferability, training-data efficiency, and cross-executor generalization.
Figures & tables
| Method | Multi-hop QA | Reasoning | Coding | Web | |||||
| HotpotQA | 2Wiki OOD | MuSiQue OOD | MATH-500 | MBPP | HumanEval OOD | WebShop | Avg. | ||
| Direct Prompting | |||||||||
| GPT-4o-mini | 45.6 | 24.5 | 23.4 | 76.5 | 83.7 | 88.3 | 59.0 | 57.3 | |
| Claude-Haiku-4.5 | 47.2 | 26.4 | 28.1 | 92.0 | 90.6 | 96.9 | 59.5 | 63.0 | |
| Qwen2.5-7B-Instruct | 30.5 | 18.8 | 11.6 | 77.5 | 76.8 | 82.4 | 58.9 | 50.9 | |
| Llama-3.1-8B-Instruct | 32.6 | 15.1 | 9.5 | 53.3 | 70.7 | 71.8 | 57.2 | 44.3 | |
| Inference | Training | Multi-hop QA | Coding | |||||
| SECPO | HotpotQA | 2Wiki OOD | MuSiQue OOD | MBPP | HumanEval OOD | |||
| ✓ | ✓ | 3 | ✓ | 55.6 2.2 | 43.5 1.8 | 42.1 1.4 | 89.0 0.2 | 95.7 0.9 |
| ✗ | ✓ | 3 | ✓ | 45.7 1.1 | 29.6 2.8 | 25.0 5.0 | 88.1 0.3 | 93.4 0.4 |
| ✓ | ✗ | 3 | ✓ | 45.3 1.4 | 30.6 1.1 | 16.3 0.6 | 86.6 0.8 | 91.3 0.9 |
| ✓ | ✓ | 1 | ✓ | 51.8 2.4 | 36.4 3.5 | 33.6 3.0 | 88.1 0.4 | 93.9 1.3 |
| ✓ | ✓ | 3 | ✗ | 53.5 3.9 | 41.0 5.0 | 39.5 3.2 | 89.2 0.3 | 95.7 0.9 |
| Method | Configuration | Credit | Chain Executions | Training Run | Test F1 and F1 vs. GRPO | |||||||||||
| per Question | Tokens | GPU-h | HotpotQA | 2Wiki OOD | MuSiQue OOD | |||||||||||
| Updates | Reference | Bound | Realized | Rel. | (M) | F1 | F1 | F1 | ||||||||
| Group-Level Credit (GRPO) 4=0 | ||||||||||||||||
| GRPO | 5 | 5 | 1 | ✗ | Group Mean | 20 | 0 9.1 | 1.00 | 4.26 | 2.6 | 53.5 | ref. | 41.0 | ref. | 39.5 | ref. |
| GRPO, Optimizer Updates | 5 | 10 | 1 | ✗ | Group Mean | 20 | 10.0 | 1.09 | 7.33 | 3.4 | 53.4 | ( 0.1) | 40.2 | ( 0.8) | 39.4 | ( 0.1) |
| GRPO, Rollouts ( ) | 9 | 5 | 1 | ✗ | Group Mean | 36 | 16.2 | 1.78 | 7.55 | 3.5 | 54.5 | ( 1.0) | 41.6 | ( 0.6) | 39.3 | ( 0.2) |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Hyperparameter | Value |
| GR backbone | Qwen2.5-7B-Instruct |
| Executor LLM | gpt-4o-mini |
| Group size | 5 |
| Tasks per training step | 32 |
| Learning rate | |
| KL coefficient | 0.001 |
| Benchmark | Domain | Source | Train | Test | Metric |
| HotpotQA | Multi-hop QA | Yang et al. (2018) | 200 | 200 | F1 |
| 2WikiMultiHopQA | Multi-hop QA | Ho et al. (2020) | 0 | 200 | F1 |
| MuSiQue | Multi-hop QA | Trivedi et al. (2022) | 0 | 200 | F1 |
| MATH-500 | Mathematical reasoning | Lightman et al. (2023) | 200 | 500 | Accuracy |
| MBPP | Code generation | Austin et al. (2021) | 324 | 341 | Pass@1 |
| HumanEval | Code generation | Chen et al. (2021) | 0 | 131 | Pass@1 |
| (a) Role Library and RoleFlowChains | Multi-hop QA | Code | |||
| HotpotQA | 2Wiki OOD | MuSiQue OOD | MBPP | HumanEval OOD | |
| Role Library | |||||
| 3=0 | |||||
| Role Library Size | 47.7 (4 + 43.7) | 15.0 (8 + 7.0) | |||
| New Roles per Task | 3.66 | 3.98 | 4.07 | 0.22 | 0.08 |
| RoleFlowChains | |||||
| Role | Capabilities |
| Seed roles | |
| Planner | planning, coordination, edit_proposal |
| Validator | validation, quality_assessment |
| OutputFormatter | formatting, extraction |
| Retriever | retrieval, wikipedia |
| Specialists offered by name in the GR plan prompt, synthesized when named | |
| Role | Capabilities |
| Planner | planning, task_analysis, edge_case_listing |
| AlgorithmDesigner | algorithm_design, complexity_analysis |
| Coder | code_generation, python |
| TestDesigner | test_design, edge_case_analysis |
| Debugger | debugging, code_repair |
| CodeReviewer | code_review, specification_check |
Multi-Agent LLM Systems
Multi-agent large language model systems coordinate multiple AI agents to solve tasks through communication, specialization, shared tools, and memory.
See all 1,039 papers