Abstract
Large language models (LLMs) have recently been employed as agents to solve sequential decision-making tasks such as Bayesian optimization and multi-armed bandits (MAB). These works usually adopt an LLM for sequential action selection by providing it with a fixed, manually designed meta-prompt. However, numerous previous works have found that the prompt has a significant impact on the performance of the LLM, which calls for a method to automatically optimize the meta-prompt for LLM-based agents. Unfortunately, the non-stationarity in the reward observations during LLM-based sequential decision-making makes meta-prompt optimization highly challenging. To address this challenge, we draw inspirations from adversarial bandit algorithms, which are inherently capable of handling non-stationary reward observations. Building on this foundation, we propose our EXPonential-weight algorithm for prompt Optimization (EXPO) to automatically optimize the task description and meta-instruction in the meta-prompt for LLM-based agents. We also extend EXPO to additionally optimize the exemplars (i.e., history of interactions) in the meta-prompt to further enhance the performance, hence introducing our EXPO-ES algorithm. We use extensive experiments to show that our algorithms significantly improve the performance of LLM-based sequential decision-making.
Introduction
Large Language Models (LLMs) are increasingly deployed as autonomous agents to solve complex, iterative problems like Bayesian Optimization or Reinforcement Learning. These agents rely on a meta-prompt—a structured input containing a task description, specific instructions, and a history of past interactions (exemplars)—to guide their decision-making process.
While LLMs are highly sensitive to prompt phrasing, most current agentic frameworks rely on static, hand-crafted prompts. Automated prompt optimization exists for static tasks (like classification), but sequential decision-making introduces a unique challenge: non-stationarity. As an agent learns and explores, the distribution of rewards it observes changes over time. A prompt that is effective during early exploration may be suboptimal during later exploitation. Traditional stochastic optimization methods like Upper Confidence Bound (UCB) often fail in these shifting environments.
The EXPO Framework
To address non-stationarity, we introduce EXPO (EXPonential-weight algorithm for prompt Optimization) and its extension, EXPO-ES (Exemplar Selection). Our approach treats prompt optimization as an adversarial bandit problem, drawing inspiration from the EXP3 algorithm, which is designed to handle rewards that change arbitrarily over time.
As illustrated in the framework above, EXPO operates in three key stages:
- Domain Generation: An LLM generates a diverse set of candidate task descriptions and instructions by rephrasing a seed prompt.
- Neural Score Estimation: To manage the vast space of possible prompt combinations, we train a small Neural Network (NN) on prompt embeddings. This NN predicts the "score" (reward) for every prompt in the domain, allowing the system to generalize beyond observed interactions.
- Randomized Selection: The algorithm maintains a probability distribution over the prompt domain based on cumulative predicted scores. It samples a new meta-prompt for each iteration, balancing exploration of new strategies with exploitation of proven ones.
EXPO-ES further enhances this by optimizing not just the instructional text, but also the selection and ordering of past interactions (exemplars) included in the context window.
Experimental Evaluation
We evaluated EXPO and EXPO-ES across three distinct sequential decision-making benchmarks:
- Linear Regression (LR): Finding optimal coefficients ($w, b$) for noisy data.
- Traveling Salesman Problem (TSP): Discrete optimization across 10, 15, and 20 nodes.
- Multi-Armed Bandits (MAB): Standard "Easy" and "Hard" benchmarks requiring the maximization of cumulative rewards.
Key Results
Our experiments demonstrate that EXPO consistently outperforms existing baselines like OPRO (Optimization by PROmpting).
As shown in the results above, EXPO and EXPO-ES achieve significantly lower optimality gaps in TSP tasks and lower regression errors in LR tasks compared to both standard and enhanced OPRO. In MAB experiments, our methods also led to a substantial reduction in cumulative regret.
Insights and Conclusion
A critical finding of this work is that adversarial bandit methods are fundamentally better suited for agentic prompt optimization than stochastic methods. Because the agent's experience grows, the reward for a specific prompt is a moving target; EXPO’s ability to adapt to this shifting landscape is key to its success.
Furthermore, we observed that joint optimization of instructions and exemplars is crucial. While instruction optimization was universally beneficial, exemplar optimization (EXPO-ES) provided a particularly large boost in logic-heavy tasks like Linear Regression. Once an optimal prompt is discovered, it can be fixed for future runs, providing a dramatic performance increase over human-designed defaults. Future work will explore the generalizability of these optimized meta-prompts across different task domains without the need for re-optimization.
Summary updated