Large language model (LLM)-based multi-agent systems (MAS) rely on role-specific prompts and execution models to solve complex tasks collaboratively. However, prompt optimization typically keeps model assignments fixed, leaving differences in role requirements and their associated inference costs outside the search. We present UniMASO, a Unified framework for heterogeneous Multi-Agent System Optimization through the joint adaptation of prompts and model assignments. UniMASO evaluates candidate updates through local, downstream, and global feedback, using cost-aware Pareto search to retain useful quality-cost trade-offs. Topology-aware co-evolution then coordinates these updates according to agent roles and dependencies. Cross-level trajectory memory further supplies historical successes and failures to guide subsequent optimization. Experiments on five benchmarks and five execution topologies show that UniMASO achieves competitive task performance at substantially lower deployment cost than the strongest homogeneous configurations. Under centralized execution, it improves the average score from 69.79 to 70.40 while reducing token-weighted deployment cost by 85.2% relative to DeepSeek-V4-Pro with MASPO. These results support joint prompt-model adaptation as an effective approach to efficient multi-agent collaboration. The code is available at https://github.com/Achilles008/UniMASO_main.
Figures & tables
Method
Prompt
Model
MIPRO ( Opsahl-Ong et al., 2024 )
✓
✗
GPTSwarm ( Zhuge et al., 2024 )
✓
✗
MASS ( Zhou et al., 2026 )
✓
✗
MASPOB ( Hong et al., 2026 )
✓
✗
MASPO ( Wang et al., 2026 )
✓
✗
MasRouter ( Yue et al., 2025 )
✗
✓
Table 1: Comparison of prompt and model optimization paradigms.
Figure 1: Homogeneous vs. Heterogeneous MAS.
Figure 2: Overview of UniMASO. Cost-aware multi-agent optimization proposes and evaluates prompt candidates from execution traces; heterogeneous execution runs the current prompt–model configuration on the realized topology; topology-aware adaptation reconciles role, dependency, and system views to update model assignments; and trajectory memory records cross-level feedback and retrieves historical evidence for subsequent rounds.
Model
Method
AGIEval
GPQA
BFCL
LiveCodeBench
HotpotQA
Avg.
Acc.
Cost
Acc.
Cost
Acc.
Cost
pass@1
Cost
EM
Cost
Result
Cost
Qwen3.5-4B
Vanilla MAS
62.11
7.3
67.17
5.3
88.40
4.8
18.32
3.8
58.00
5.8
58.80
5.38
+TPE
59.77
8.2
66.67
6.1
88.80
5.4
19.08
4.2
58.20
6.5
58.50
6.08
+SPO
63.28
8.3
69.70
5.9
88.60
5.5
20.61
4.3
58.00
6.6
60.03
6.12
+MASPOB
63.67
8.2
68.69
5.8
89.40
5.3
19.85
4.3
58.60
6.5
60.04
6.02
+MASPO
63.28
8.2
69.19
5.9
89.60
5.5
21.37
4.4
58.40
6.4
60.36
6.08
Table 2: Task quality and deployment cost under the centralized topology. Prompt-only baselines use homogeneous models; UniMASO jointly optimizes prompts and model assignments.
Figure 5
Method
AGIEval
GPQA
BFCL
LiveCodeBench
HotpotQA
Avg.
Acc.
Cost
Acc.
Cost
Acc.
Cost
pass@1
Cost
EM
Cost
Result
Cost
Reference: Proposed Framework
UniMASO (Full)
82.42
56.86
78.28
33.02
92.40
12.21
35.11
13.27
63.80
39.26
70.40
30.92
(I) Component Ablations
Table 3: UniMASO ablations and parameter sensitivity under centralized execution.
Target
Memory
Acc.
Cost
AGIEval-MATH
None
80.08
51.35
Own
82.42
56.86
Other
81.64
52.93
GPQA-Diamond
None
76.77
31.58
Own
78.28
33.02
Other
77.78
29.43
Table 4: Cross-task memory transfer.
Method
Coordination
Efficiency
Comm. ↑
Plan. ↑
Cost-of-Pass ↓
Centralized MAS
68.45
64.39
1.154
+TPE
71.81
66.86
1.357
+SPO
69.90
64.15
1.271
+MASPOB
71.54
67.08
1.245
+MASPO
72.84
68.41
1.241
Table 5: Coordination and efficiency.
Figure 9
Target dataset
Method
Opt. pool
Accuracy ↑ (%)
Cost ↓ (M)
AGIEval-MATH
Vanilla MAS
None
76.17
217.3
MASPO
AGIEval-MATH
78.12
249.6
UniMASO (in-domain)
AGIEval-MATH
82.42
56.9
UniMASO (cross-dataset)
MATH-500
81.25
58.7
MATH-500
Vanilla MAS
None
79.20
262.9
MASPO
MATH-500
84.80
339.5
Table 6: Cross-dataset transfer of UniMASO between AGIEval-MATH and MATH-500. The Vanilla MAS and MASPO baselines use DeepSeek-V4-Pro for all task agents. Accuracy and deployment cost are measured on the target evaluation set.
Method
AGIEval-MATH
GPQA-Diamond
BFCL-V3
HotpotQA
LiveCodeBench
Input
Output
Cost
Input
Output
Cost
Input
Output
Cost
Input
Output
Cost
Input
Output
Cost
UniMASO
5.92
0.085
51.9
4.14
0.072
37.0
1.93
0.065
19.0
4.89
0.070
42.8
6.45
0.077
55.6
MASPO
7.48
0.103
1188.4
5.21
0.086
843.1
2.37
0.074
421.2
6.19
0.082
979.9
8.17
0.094
1278.0
Table 7: Optimization-side LLM usage and cost of MASPO and UniMASO under centralized execution. Input and output tokens and relative weighted-token cost are reported in millions (M). The accounting includes optimizer and evaluator calls and UniMASO’s Co-Evolver calls.
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
Dataset
Samples
Metric
AGIEval-MATH
256
Accuracy
GPQA-Diamond
198
Accuracy
BFCL-V3
500
Accuracy
LiveCodeBench-v6
131
Pass@1
HotpotQA
500
Exact match
Total
1,585
–
Appendix
Table 8: Final-evaluation sample counts and metrics by benchmark.
Table 9: Performance comparison of UniMASO against homogeneous model assignments across five execution topologies. For each topology, we compare five homogeneous configurations with the heterogeneous configuration selected by UniMASO, reporting both task quality and deployment cost.
Model
Capability
cin
cout
Qwen3.5-4B
Very weak
1
4
Qwen3.5-9B
Medium
2
8
Qwen3.5-27B
Strong
8
32
DeepSeek-V4-Flash
Very strong
24
72
DeepSeek-V4-Pro
Extremely strong
72
216
Appendix
Table 10: Model capability levels and relative token-cost coefficients.