CB-Orchestrator: Adaptive Workflow Optimization for LLM Agents via Contextual Bandits
Organizations: The Chinese University of Hong Kong, Shenzhen · Huawei Technologies · City University of Hong Kong
Abstract
Large Language Model (LLM) agents have demonstrated remarkable capabilities in tackling complex tasks through agentic workflows. However, manually designing these workflows is labor-intensive and lacks flexibility to adapt to diverse queries. While automated workflow optimization is a promising direction, existing methods often incur expensive API costs during training-phase feedback collection. Furthermore, they fail to adaptively reuse high-quality workflows, which creates a bottleneck for both performance and cost-effectiveness. To address these limitations, we propose CB-Orchestrator, an adaptive framework that decouples workflow generation from selection. In the first stage, we construct a diverse pool of candidate workflows via evolutionary search. In the second stage, we formulate workflow selection as a Contextual Bandit problem, which enables sample-efficient learning by balancing exploration and exploitation, thereby significantly reducing the feedback required for training. During inference, the model adaptively selects the optimal workflow tailored to each query. Evaluations across five diverse benchmarks demonstrate that CB-Orchestrator consistently outperforms all baselines. Notably, on the MATH dataset, CB-Orchestrator achieves better performance than strong recent baselines while reducing training-phase API token overhead by no less than 40.55% and total end-to-end training (including workflow pool generation) token overhead by no less than 29.73%.
Figures & tables
| Method | MATH | GSM8K | MBPP | HumanEval | Avg . |
|---|---|---|---|---|---|
| Basic Prompting | |||||
| Vanilla | 46.29 | 87.45 | 71.83 | 87.08 | 73.16 |
| CoT ( Wei et al., 2022 ) | 46.40 | 87.10 | 71.83 | 88.13 | 73.37 |
| CoT SC (5-shot) ( Wang et al., 2023 ) | 47.91 | 87.57 | 73.60 | 88.60 | 74.42 |
| Fixed Multi-Agent Systems | |||||
| LLM-Debate ( Du et al., 2024 ) | 48.54 | 89.47 | 70.29 | 88.68 | 74.25 |
| Method | M G | G M |
|---|---|---|
| Baseline Methods | ||
| GPTSwarm | 89.96 | 45.18 |
| AFlow | 91.95 | 49.39 |
| MaAS | 92.80 | 51.02 |
| CB-Orchestrator (Ours) | ||
| Source Pool & Source NN | 89.72 | 53.62 |
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Domain | Train | Test | Workflows | Operators |
|---|---|---|---|---|---|
| MATH | Math reasoning | 119 | 486 | 68 | Custom, ScEnsemble, Programmer |
| GSM8K | Math reasoning | 264 | 1055 | 72 | Custom, ScEnsemble, Programmer |
| HumanEval | Code generation | 33 | 131 | 31 | Custom, CustomCodeGenerate, ScEnsemble, Test |
| MBPP | Code generation | 86 | 341 | 81 | Custom, CustomCodeGenerate, ScEnsemble, Test |
| GAIA | Multi-tool QA | 93 | 301 | 36 | Custom, Reasoning, Decompose, Search, FileAnalysis, Programmer, ScEnsemble, FinalAnswer |
| Parameter | Sym. | Val. | Parameter | Sym. | Val. |
|---|---|---|---|---|---|
| Stage 1: Workflow Pool Construction | |||||
| Evolution rounds | 2 | Transfer rounds | 2 | ||
| Gen. temperature | - | 1.0 | Exec. temperature | - | 0 |
| Similar queries | 5 | ||||
| Stage 2: Bandit Training | |||||
| Embedding dim | 2560 | Learning rate | |||
| Dataset | Train Queries | Covered | Coverage | Pool Size |
|---|---|---|---|---|
| MATH | 119 | 86 | 72.3% | 68 |
| GSM8K | 100 | 98 | 98.0% | 72 |
| HumanEval | 33 | 31 | 93.9% | 31 |
| MBPP | 86 | 82 | 95.3% | 81 |
| Method | Pool Gen. | Training | Inference | Total | Solve % |
|---|---|---|---|---|---|
| LLM-Debate | – | – | 13.73 | 13.73 | 48.54 |
| DyLAN | – | 38.30 | 9.39 | 47.68 | 48.63 |
| GPTSwarm | – | 27.70 | 3.89 | 31.59 | 47.88 |
| AFlow | – | 62.88 | 4.66 | 67.54 | 51.28 |
| MaAS | – | 5.43 | 2.16 | 7.60 | 51.82 |
| CB-Orch ( =200) | 0.59 | 0.78 | 2.24 | 3.61 | 51.19 |
| Method | Train Input | Train Output | Infer Input | Infer Output |
|---|---|---|---|---|
| LLM-Debate | – | – | 3.28 | 10.46 |
| DyLAN | 22.15 | 16.15 | 6.08 | 3.30 |
| GPTSwarm | 21.33 | 6.37 | 3.11 | 0.79 |
| AFlow | 33.83 | 29.05 | 2.51 | 2.15 |
| MaAS | 3.05 | 2.38 | 1.31 | 0.85 |
| CB-Orch ( =1200) | 3.24 | 1.76 | 1.60 | 0.70 |
| Operator | Description & Interface |
|---|---|
| Custom | General-purpose LLM call with customizable prompts. Flexible for planning, reflection, decomposition, formatting, etc. |
| (input: str, instruction: str) -> {response: str} | |
| ScEnsemble | Self-consistency voting across multiple solutions. Requires 3+ solutions for effective voting. |
| (solutions: List[str], problem: str) -> {response: str} | |
| Programmer | Generates and executes Python code in a sandbox. Auto-retries on errors. Returns computed answer. |
| (problem: str, analysis: str) -> {code: str, output: str} |
| Operator | Description & Interface |
|---|---|
| Custom | General-purpose LLM call for reasoning about code structure and logic. |
| (input: str, instruction: str) -> {response: str} | |
| CustomCodeGenerate | Specialized code generation with entry point awareness. |
| (problem: str, entry_point: str, instruction: str) -> {response: str} | |
| ScEnsemble | Self-consistency voting for code solutions. |
| (solutions: List[str], problem: str) -> {response: str} |
| Operator | Description & Interface |
|---|---|
| Custom | General-purpose LLM call for flexible reasoning and formatting. |
| (input: str, instruction: str) -> {response: str} | |
| Reasoning | Multi-step structured reasoning. Can receive context from other operators. |
| (question: str, context: str) -> {thought: str, answer: str} | |
| Decompose | Breaks complex questions into sub-tasks with dependency tracking. |
| (question: str, context: str) -> {analysis: str, subtasks: List, final_aggregation: str} |
| Operation | Time | Frequency |
|---|---|---|
| Matrix update: | Per sample | |
| Cholesky decomposition: | Per batch | |
| Uncertainty: | Per (query, workflow) | |
| Neural network forward pass | Per (query, workflow) |
| Method | MATH | HumanEval | Avg. |
|---|---|---|---|
| Vanilla | 31.93 | 80.06 | 56.00 |
| MaAS | 42.97 | 85.26 | 64.12 |
| CB-Orchestrator | 44.36 | 84.12 | 64.24 |
| Method | MATH | MBPP | Avg. |
|---|---|---|---|
| Framework Variants | |||
| PureRandom | 47.99 | 81.64 | 64.81 |
| WithoutEvo | 51.89 | 84.17 | 68.03 |
| Exploration Strategy Variants | |||
| RandomNN | 52.59 | 82.34 | 67.47 |
| GreedyNN | 52.63 | 83.93 | 68.28 |
| Method | L1 | L2 | L3 | Avg. |
|---|---|---|---|---|
| Vanilla | 7.5 | 4.4 | 0 | 4.7 |
| Fixed Multi-Agent Systems | ||||
| TapeAgent | 23.7 | 14.5 | 10.2 | 16.6 |
| Sibyl | 21.5 | 15.7 | 4.1 | 15.6 |
| Autonomous Multi-agent Systems | ||||
| AutoAgents | 16.1 | 0 | 0 | 5.2 |
| Rank | Dist. | Shared Structure |
|---|---|---|
| 1 | 0.32 | Both ask “Bekah has [N] brass digits… how many distinct numbers” (identical template, different N) |
| 2 | 0.44 | Both ask circular seating of Senate committee with party constraints |
| 3 | 0.45 | Both ask “put 4 balls in 3 boxes” with distinguishability variants |
| 4 | 0.46 | Both ask area of isosceles right triangle given altitude to hypotenuse |
| 5 | 0.47 | Both show identical triangle diagrams (Asymptote code), ask for |
| Rank | Dist. | Query A Domain | Query B Domain |
|---|---|---|---|
| 1 | 1.42 | Parametric line equations | Circular permutations |
| 2 | 1.42 | Triangle angle trisectors | Counting odd 5-digit numbers |
| 3 | 1.41 | Simplify | Probability of consecutive seats |
| 4 | 1.41 | 3-digit palindrome multiples of 3 | Simplify radical expression |
| 5 | 1.40 | Polygon perimeter geometry | Product divisibility probability |
| Type | Dist. | Workflow A | Workflow B |
|---|---|---|---|
| Close | 0.13 | Custom Programmer(1 ) ScEnsemble Format | Custom Programmer(3 ) ScEnsemble Format |
| Close | 0.13 | Custom Programmer(3 loop) ScEnsemble Format | Custom Programmer(3 ) ScEnsemble Format |
| Close | 0.14 | Custom Programmer(3 ) ScEnsemble Format | Custom Custom(3 ) ScEnsemble Format |
| Far | 0.93 | Custom ScEnsemble Programmer | Programmer only (hardcoded) |
| Far | 0.93 | Custom Programmer(3 ) ScEnsemble Programmer Format | Custom ScEnsemble Programmer |
| Far | 0.93 | Custom Programmer(3 ) ScEnsemble Format | Custom Custom Custom Programmer (no ensemble) |
| Metric | Value | Interpretation |
|---|---|---|
| KNN Prediction Accuracy | 84.75% | Correct prediction of success/failure |
| Random Baseline (majority) | 51.08% | Baseline without smoothness |
| Pearson Correlation ( ) | 0.73 | Strong positive correlation |
| -value | Statistically significant |
| Distance Type | Mean Distance | Sample Size |
|---|---|---|
| Success–Success (intra) | 0.40 | 2,138 pairs |
| Success–Failure (cross) | 0.50 | 1,066 pairs |
LLM Agent Workflow Optimization
LLM agent workflow optimization studies how to design and run multi-step agents for better task success, reliability, latency, and cost.
See all 256 papers