Manuscript Offprint

arXiv:2609.05837

AgentBrew: Offline Tool-Use Agent Learning from Raw Real-World Trajectories

Zhiyi Lyu, Yewen Li, Longtao Zheng, Shengtian Yang, Lang Feng, Lei Feng, Peng Jiang, Kun Gai, Qingpeng Cai, Bo An

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

Abstract

LLM-based agents are increasingly deployed in real-world applications through tool-use APIs, yet training them for specific environments remains fundamentally difficult: real-world applications provide no pre-defined tasks or verifiers, no faithful simulators, and limited budget for large-scale environment interaction. In this paper, we propose AgentBrew, an offline training framework that learns effective tool-use policies from a single batch of raw interaction trajectories, without task verifiers or iterative on-policy rollouts. The agent first explores the target environment to collect a raw trajectory corpus without quality filtering. To extract training signal from this noisy corpus, retrospective task inference reconstructs an aligned instruction for each trajectory based on its actual outcome, and PMI-Based credit assignment decomposes the trajectory's total information about the inferred instruction into additive per-action credits via pointwise mutual information (PMI). These credits weight the policy training objective, amplifying informative actions while suppressing ineffective ones. On three real-world MCP applications (GitHub, Notion, PostgreSQL), AgentBrew improves Qwen3-32B by +8.7 Acc / +9.7 Score on average, surpassing Qwen3-235B (+2.3 / +4.4) and outperforming rejection sampling (+5.9 / +10.3). These results demonstrate that fine-grained offline learning can recover useful supervision from raw trajectories that filtering-based approaches would discard. The code is available at https://github.com/alphatogo/AgentBrew

1 Introduction

Tool-use agents powered by Large Language Models (LLMs) are rapidly moving from research prototypes to production deployments [44; 21; 29; 2]. Standardized protocols like the Model Context Protocol (MCP) [2] now connect LLM agents to real-world applications such as Notion [22] and GitHub [10], enabling tool-use across complex, stateful environments. However, each application presents a distinct tool landscape: Notion exposes dozens of APIs spanning database operations, page management, and content editing, each requiring precise parameter composition and awareness of the application's live state. General-purpose LLMs, even at frontier scale, struggle with such environment-specific complexity, exhibiting low task completion rates on real-world tool-use benchmarks [20; 39], indicating that reliable deployment demands targeted, environment-specific training.

Existing approaches to training tool-use agents for specific applications follow two main routes. The first operates on real-world data [42; 48; 31]: practitioners design a suite of tasks with ground-truth verifiers for the target application, deploy an agent to interact with the live environment and collect trajectories, then use the verifiers to filter for successful completions and train via supervised fine-tuning on the retained high-quality subset [26; 48; 24]. The second pursues on-policy optimization

Preprint.

[30; 9; 13]: because repeated rollouts against live APIs incur monetary costs, rate limits, and irreversible side effects on production data, these methods instead construct simulated environments that replicate the application's state and tool behavior, enabling large-scale iterative training before deploying the resulting policy back to the real application [6; 38; 35; 28]. Despite their different trade-offs, both routes rest on shared prerequisites: pre-defined task suites, reliable reward signals, and either sufficient real-world interaction budget or a faithful simulator of the target environment.

While these methods have achieved strong results on curated benchmarks, applying them to real-world applications exposes fundamental difficulties at three levels. At the task level, real-world applications provide neither pre-defined task nor ground-truth verifiers. Tasks must be constructed from scratch with validity dependent on the environment's live state, and reliable verification remains an open problem [12]: neither manual annotation [7; 28] nor automated judging scales to complex, stateful API interactions (see §4.2). At the trajectory level, the offline route faces a severe data efficiency problem. Real-world tool-use tasks involve long, complex API compositions with low completion rates, so standard trajectory-level filtering [42; 48] discards the majority of an already limited corpus. Worse, even a 'failed' trajectory may contain actions that are useful training signal for a different but related task, yet trajectory-level filtering discards them entirely (Figure 1, left). At the training level, the online route introduces a significant sim-to-real gap: simulators cannot faithfully reproduce the complex, interconnected state of real-world

Figure

Figure 1: Left: trajectory-level filtering discards entire trajectories that fail the original task, losing potentially useful actions. Right: AgentBrew infers a better-aligned task for each trajectory and assigns per-action credits under the inferred task, enabling the entire corpus to contribute to training.

applications. Recent work confirms this empirically: simulator-trained agents achieve strong results on synthetic benchmarks yet degrade when evaluated on real-world platforms [6]. Together, these challenges rule out standard training pipelines and point to a setting that, despite being the norm for industrial deployment, remains largely unexplored in the research community:

How can we train a tool-use agent for a specific application, with no pre-defined tasks, no verifiers, no simulator, and limited environment interaction?

In this paper, we present AgentBrew, an offline training framework that learns effective tool-use policies from a single batch of raw interaction trajectories, without task verifiers or iterative rollouts. Our key insight is that every trajectory, regardless of whether it completes its original task, carries reusable signal: by inferring what each trajectory actually accomplished and scoring which actions genuinely contributed, we extract fine-grained supervision from the entire raw corpus without discarding any data. First, the agent explores the target environment to discover its live state and proposes grounded task instructions, then executes these tasks to collect a raw trajectory corpus without any quality filtering (§3.1). Second, we recover fine-grained supervision from this noisy corpus through two complementary mechanisms (§3.2). For each trajectory, retrospective task inference reconstructs an instruction that reflects what the trajectory actually achieved rather than what it originally intended, producing aligned instruction-trajectory pairs. PMI-Based credit assignment then quantifies how much each action contributes to the inferred task. We define the total information a trajectory carries about its inferred instruction via pointwise mutual information (PMI), and leverage the chain rule of PMI to decompose this trajectory-level quantity into additive per-action credits, each measuring the marginal information a single action contributes. Third, these credits serve as sample weights for policy training, amplifying the gradient from informative actions while suppressing that from ineffective ones (§3.3). Crucially, once the raw corpus is gathered, all subsequent stages proceed entirely offline with no further environment interaction, making the framework practical for real-world APIs where iterative exploration is infeasible.

We evaluate AgentBrew on three real-world MCP applications: GitHub, Notion, and PostgreSQL [20; 39]. Without any external reward signals, human annotations, or iterative environment interaction, AgentBrew improves over the Qwen3-32B base model by +8.7 Acc and +9.7 Score on average,

Figure

Figure 2: Overview of AgentBrew. (1) The agent explores E\mathcal{E} to propose grounded tasks and collects raw trajectories. (2) Retrospective task inference recovers aligned instructions f^n\hat{f}_n, and PMI-based credit assignment scores each action. (3) Normalized credits weight the policy training objective.

surpassing Qwen3-235B and outperforming rejection sampling by +5.9 Acc and +10.3 Score. These results demonstrate that fine-grained offline learning can extract useful training signal from raw trajectories that filtering-based approaches would discard entirely.

References (48)