Manuscript Offprint

arXiv:2610.30429

RoleFlow: Self-Evolving Multi-Role Agentic Collaboration via Structural Adaptation

Yi Ge, Pan Wang, Xuehao Cui, Zian Zeng, Xu Hu, Heng Huang, Furong Huang

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, often 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.

1 Introduction

Large language model (LLM) based multi-agent systems have shown capabilities in solving complex tasks through specialized agent collaboration (Durante et al., 2025; Ghareeb et al., 2026). However, existing approaches typically rely on predefined or pre-optimized collaboration structures that remain fixed during execution. Such structures struggle to accommodate evolving task requirements, where effective collaboration may demand adding, removing, or reorganizing specialized roles.

Which film's director died later, A or B?

Hand-Crafted Structure

Deficit: Missing Comparison

Self-Evolving Structure

Trajectory-Level Credit

Group-Relative Advantage: R−RmeanR - R_{mean}

Add Comparator

With Edit

RoleFlow · Structure-Aware Credit

Per-Edit Advantage: R+−R0R^{+} - R^{0}

Without Edit

Next Cycle

Figure 1: Motivation of RoleFlow. Hand-crafted structures lack adaptability (top), while trajectory-level rewards obscure the contributions of individual structural edits (middle). Our RoleFlow enables effective structural evolution through same-state counterfactual evaluation and edit-level credit assignment (bottom).

This raises a fundamental question: How can multi-role agentic systems autonomously evolve their collaboration structures during task execution?

Recent studies have explored reinforcement learning for dynamic agent orchestration (Li et al., 2025; Zhang et al., 2026a; Nie et al., 2025). However, learning structural adaptation introduces a critical challenge: credit assignment for individual structural decisions. Conventional methods like Group Relative Policy Optimization (GRPO) (Shao et al., 2024) rely on trajectory-level rewards, assigning the same advantage to decisions within a rollout regardless of their individual contributions. As shown in Fig. 1, when collaboration structures undergo successive modifications, this coarse-grained feedback cannot reliably identify which edits improve performance and which undermine it.

Our key insight is that reliable structural evolution requires making each structural modification individually assessable and learnable. Rather than treating an evolving collaboration structure as a

†^{\dagger}Corresponding authors.

{yige, furongh, heng}@umd.edu sequence of decisions optimized only through its final outcome, we decompose structural adaptation into atomic edits and evaluate each edit against an unchanged counterpart under the same chain state. This isolates the immediate contribution of a structural decision and provides a localized learning signal, allowing the system to learn not only how to modify collaboration structures but also which modifications are worth making.

Motivated by this insight, we propose RoleFlow, a self-evolving multi-role collaboration framework that continuously adapts agent structures through execution feedback. A trainable Global Router (GR) constructs task-specific role chains and refines them through atomic structural edits, while synthesizing specialized roles on demand. To optimize these decisions, we introduce Single-Edit Counterfactual Policy Optimization (SECPO), which compares executions with and without each candidate edit under the same chain state and incorporates the resulting advantage into edit-specific token optimization. RoleFlow further maintains a return-gated role library to retain useful synthesized specialists during training. Experiments across seven benchmarks spanning four domains demonstrate the effectiveness of RoleFlow, achieving the highest average performance among evaluated multi-agent systems.

Our contributions are threefold:

• We introduce RoleFlow, a self-evolving multi-role agentic system that enables feedback-driven structural adaptation through atomic edits and on-demand specialist synthesis.

• We propose SECPO, a structure-aware policy optimization method that estimates the counterfactual contribution of individual structural edits and assigns targeted credit to edit-specific tokens.

• Experiments across seven benchmarks spanning four domains show that RoleFlow achieves the highest average performance. Further analyses validate structural adaptation, edit-level counterfactual learning, cross-benchmark transferability, training-data efficiency, and cross-executor generalization.

References (30)