Manuscript Offprint

arXiv:2611.06868

On Turn-Level Best-of-N Sampling for Scaling LLM Agents

Jalaj Bhandari, Dhawal Gupta, Hongli Zhan, Zhenting Wang, Varad Pimpalkhute, Zhengzhong Liu, Eric Xing, Rupesh Srivastava

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

In this work, we evaluate a simple inference-time scaling approach based on turn-level best-of-N sampling (Turn-BoN) for large language model (LLM) agents on complex, long-horizon tasks. We instantiate this using a generator-selector framework with two LLMs; at each turn, a generator model generates NN candidate actions and a selector model selects one of them, which is then executed in the environment. This paper is closely related to the work of Zainullina et al. (2025) who used critic models for guided search at inference time. Different from their work, we evaluate if off-the-shelf, open-weight LLMs can be effective at comparing different candidate actions directly. Experiments on long-horizon terminal tasks show that Turn-BoN can lead to significant performance improvements, both in terms of accuracy (5–10%) and consistency across repeated attempts. Analysis of agent trajectories reveal a shift in agent behaviour towards desirable patterns such as reduction in number of attempts to solve the task, improved task instruction following, debugging and testing.

1 Introduction

Large language model (LLM)-based agents have recently achieved strong performance in solving complex, long-horizon tasks across different domains such as software engineering, knowledge work and scientific discovery. Unlike single-turn reasoning tasks, such as proving a theoretical result, agentic tasks require an LLM to take a sequence of actions while interacting with an external environment where the agent executes an action, observes any changes or feedback from the environment and takes the next action. Successfully solving a long-horizon task therefore requires the agent to make good decisions throughout the trajectory. However, LLM agents can often be inconsistent. They can successfully complete the task during some attempts while failing in others, partially because actions are sampled from a stochastic policy (see Figure 1 in Zainullina et al. (2025) for example).

Inference-time scaling has emerged as an effective technique to improve performance without altering model parameters, by using additional compute during task execution. Among the most prominent ideas is trajectory-level best-of-N sampling, where multiple complete agent trajectories are generated in parallel and scored using an outcome reward model (ORM) or an LLM judge, and the best one is selected. Recent work by Kwok et al. (2026) evaluates this idea for agentic tasks, showing gains on software engineering benchmarks

*Equal contribution. Correspondence: {jalaj.bhandari, rupesh.srivastava}@mbzuai.ac.ae.

such as Terminal-Bench v2.1 (Merrill et al., 2026) and SWE-Bench-Verified (Jimenez et al., 2024), using an LLM-as-a-judge to score completed trajectories against evaluation rubrics. A limitation of this approach, however, is that selection happens only after the trajectories are completed, and therefore cannot change the distribution of the intermediate actions within each attempt. Other commonly used inference time search methods, such as depth-first search (DFS) (Yao et al., 2023) and Monte Carlo tree search (MCTS) (Kocsis and Szepesvári, 2006), explore alternative actions from intermediate states. However, applying these methods to interactive agents requires checkpointing and restoring earlier environment states, which can be impractical in many settings Zainullina et al. (2025).

We study a simple modification of trajectory level best-of-N sampling, which we call turn-level best-of-N sampling (Turn-BoN), where additional computation is used to generate N candidate actions at each turn, one of them is selected for execution in the environment. Concretely, we use a generator-selector framework with two LLMs: a generator model proposes candidate actions, and a selector model chooses among them. Intuitively, we think of Turn-BoN as implementing (a sampled version of) one-step policy improvement at inference time, where we can improve over the rollout policy by selecting actions from a sampled set of candidates. We elaborate more about this connection in Sections 2.2 and 2.3.

Note that in our setup, the action selection is done before environment execution, i.e. only the selected action is executed in the environment without requiring sandbox execution for the remaining candidates. On the other hand, trajectory level BoN generates N independent trajectories in parallel which scales the number of environment executions and sandbox infrastructure by a factor of N. Moreover, trajectory level BoN might have limited practical use beyond offline evaluation on benchmark tasks — for agents working on user machines (for example, agents working in a terminal, or computer use agents), it is not clear how N sandboxes can be obtained for parallel generation since the user's machine is the sandbox. Even sequentially generating up to N agent trajectories and scoring these seems impractical.

The idea of selecting actions from a set of sampled candidate actions has also been explored in RL before. In settings with large or continuous action spaces where enumerating all possible actions to find the best one is infeasible, existing methods (Fujimoto et al., 2019; Ghasemipour et al., 2021; Hubert et al., 2021; Gupta et al., 2023) sample a smaller set of candidate actions and use estimated action values or planning to select among them. More recently, Zainullina et al. (2025) applied the idea of value-guided action selection to LLM agents. The main motivation of this paper is to answer the following questions:

Can we use an off-the-shelf LLM as a generative critic to perform per-turn action selection at inference time for agentic tasks? Does this improve task success, and how does it change the behaviour of agents over complete trajectories?

An advantage of using an off-the-shelf LLM for action selection is that we avoid the need to train a separate action-value critic. We summarize the main contributions and findings of our work below:

  1. We study turn-level best-of-N (Turn-BoN) action selection for LLM agents using an off-the-shelf LLM to select among candidate actions before environment execution, without needing to train a separate critic model.

  2. We empirically evaluate the performance and computational trade-offs of this approach across different generator models, selector models, and sampling widths. Results show improvements in pass rates (both pass@1 and pass@k) as well as consistency across repeated attempts.

  3. We analyze how Turn-BoN sampling changes the actions selected by the agent and its behavior across complete trajectories. We observe substantially fewer executed turns and reduction in undesirable behaviors related to looping, testing, and debugging, including among unsuccessful attempts.

  4. We interpret this method as a form of approximate sampled one-step policy improvement at inference time, and derive conditions based on the expected advantage of selected actions, under which the induced policy improves upon the generator policy.

We remark that Turn-BoN incurs substantial additional inference-time compute because it generates multiple candidate actions and invokes an LLM selector, at every turn (Section 3). Developing computationally efficient approximations that retain performance gains of Turn-BoN remains an open question. We discuss this in Section 5.

A Note on Concurrent Work: We were studying Turn-BoN independently when we came across the work of Kang et al. (2026), which investigates essentially the same idea of per-turn action selection, primarily using smaller generator models (of size 4B–9B) with both self-verification and GPT-5.6-Sol (a closed-source flagship frontier model) as the selector model. We decided to release our results and analysis so far, and communicated with the authors of Kang et al. (2026). This work can be seen as concurrent, independent evaluation of the idea of action selection through guided search at larger model scales (Qwen3.6-35B at medium scale and K2-Horizon-375B at large scale), using open-weight models (such as Kimi-K3 and Deepseek-v4.1-Flash) as selector models and a different agentic harness (mini-SWE-agent).

Beyond an independent and detailed empirical investigation, our work also focusses on how per-turn action selection changes agent behaviour. For example, we analyze the categories of actions preferred by the selector model as well as evaluate trajectories over behaviour rubrics, finding significant improvements in agent behaviour related to testing, debugging, task instruction following and reduction in looping over failed commands. This is important to build an understanding of how Turn-BoN differs from other inference time approaches like trajectory level BoN (which does not change the agent behaviour) as well as in attributing gains across different metrics under turn-BoN sampling. Finally, we connect the idea of per-turn action selection to one step policy improvement at inference time, and give theoretical grounding to this approach.

References (43)