arXiv:2610.13064cs.LGOct 2026

Manuscript Offprint

arXiv:2610.13064

CB-Orchestrator: Adaptive Workflow Optimization for LLM Agents via Contextual Bandits

Jiahang Sun, Zhiwei Shang, Zhipiao Liu, Hongwei Yang, Guoqing Xie, Shuang Qiu, Zhongxiang Dai

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%.

1 INTRODUCTION

Large Language Model (LLM) agents have demonstrated remarkable capabilities in handling complex tasks through agentic workflows (Wu et al., 2024; Hong et al., 2024). An agentic workflow is a structured program that orchestrates a sequence of LLM calls and tool invocations to solve a query (Hu et al., 2025; Zhang et al., 2025d). However, manually designing such workflows is labor-intensive and often fails to adapt to diverse queries. This has motivated growing interest in automated workflow optimization.

As illustrated in Figure 1, current automatic workflow optimization largely falls into two paradigms: (i) task-level optimization, which implements a universal fixed workflow for a task type (Li et al., 2024; Hu et al., 2025; Zhang et al., 2025d); and (ii) query-level optimization, which generates a bespoke workflow for each incoming query (Zhang et al., 2025a; Zhu et al., 2025; Zhang et al., 2025h). However, these paradigms present a fundamental dilemma. Task-level approaches suffer from rigidity and fail to tailor solutions to diverse queries. In contrast, query-level approaches treat every query as a new generation problem. This significantly harder learning objective creates a bottleneck, inflating both the sample complexity needed for training-phase feedback collection and the computational overhead required for inference. Furthermore, neither paradigm effectively reuses high-quality workflows: learned solutions are either too generic or discarded after one-off use, preventing the system from benefiting from accumulated knowledge.

∗^{*}Corresponding author. Correspondence to daizhongxiang@cuhk.edu.cn.

Figure

Figure 1: CB-Orchestrator vs. prior workflow-optimization paradigms.

Beyond efficiency bottlenecks, a fundamental issue is that workflow effectiveness is inherently query-dependent. A single fixed workflow optimized at the task level can be unnecessarily heavy for simple instances yet insufficient for complex ones (e.g., arithmetic vs. multi-step verification in math reasoning; one-shot utility functions vs. iterative testing in code generation). While query-level methods address this heterogeneity, they often conflate adaptation with generation: generating a new workflow from scratch is a difficult program-synthesis problem with a vast search space, whereas selecting a suitable strategy from a reusable set is a much simpler decision problem. This motivates our key rationale: choosing is much easier than creating. We therefore aim to reuse a pool of strong workflows and spend the learning budget on adaptive selection.

To this end, we propose CB-Orchestrator, which decouples workflow pool construction from adaptive selection (Figure 1). CB-Orchestrator proceeds in two stages: Stage 1 constructs a diverse workflow pool automatically from the training set via execution-guided evolutionary search, and Stage 2 learns a query-conditioned selecting policy by formulating workflow selection as a contextual bandit. The bandit view enables a principled exploration-exploitation trade-off, allowing the selector to learn sample-efficiently.

Contributions. We make the following key contributions:

(1) Problem Setting: We formalize adaptive workflow reuse for LLM agents as learning a query-conditioned routing policy over a reusable workflow pool, as an alternative to task-level fixed-workflow deployment and query-level per-query workflow generation (Figure 1).

(2) CB-Orchestrator: We propose a two-stage framework that (i) constructs a diverse workflow pool automatically from the training set via execution-guided evolutionary search, and (ii) learns a contextual-bandit selector to adaptively choose workflows, enabling sample-efficient training by reducing the number of workflow evaluations needed to learn a strong policy.

(3) Results: Across five benchmarks, CB-Orchestrator consistently improves over strong baselines. On the MATH dataset, it reduces training-phase token overhead by ≥\geq 40.55% and end-to-end training overhead (including workflow pool generation) by ≥\geq 29.73%.