TL;DR
AgentBrew is an offline training framework that enables LLM agents to learn effective tool-use policies from a single batch of raw, unfiltered interaction trajectories. By combining retrospective task inference (re-labeling what an agent actually achieved) with an information-theoretic credit assignment mechanism, it extracts high-quality training signals from noisy or failed attempts without needing environment simulators or manual verifiers.
What Problem Does This Paper Address?
Building LLM agents that can reliably interact with real-world applications via APIs (like GitHub or Notion) is incredibly challenging. Current agent training pipelines typically rely on two expensive assumptions: either they require a high-fidelity simulator for online reinforcement learning, or they need pre-defined tasks with automated verifiers to filter out successful trajectories for supervised fine-tuning (SFT).
In practice, building accurate simulators for complex enterprise apps is nearly impossible, and automated judges struggle to verify success in stateful environments. As a result, standard "rejection sampling" approaches throw away the vast majority of collected data because the agent failed the intended task—even if individual actions within that failed trajectory were perfectly valid and educational.
Methods
AgentBrew introduces a three-stage offline framework to recycle these "imperfect" trajectories:
- Grounded Experience Collection: The agent explores the target environment to discover its live state (e.g., existing databases, repositories) and proposes realistic tasks grounded in this state. It then executes these tasks to collect a raw trajectory corpus without any quality filtering.
- Experience Distillation:
- Retrospective Task Inference: For every trajectory, an LLM inspects the actual observable outcomes and rewrites the task instruction to match what was genuinely accomplished, turning a "failed" trajectory into a successful example of a different task.
- PMI-Based Credit Assignment: To separate helpful actions from mistakes or redundant steps, AgentBrew uses Pointwise Mutual Information (PMI). It calculates how much each individual action reduces the reference model's uncertainty (negative log-likelihood) about the newly inferred task.
- PMI-Weighted Policy Training: These per-action credits are normalized and applied as sample weights during SFT. This amplifies the gradient of highly informative actions while effectively masking out errors and random exploration.
Datasets
The authors evaluate AgentBrew on three real-world Model Context Protocol (MCP) applications:
- GitHub (code collaboration, exposing 41 tools)
- Notion (knowledge management, exposing 19 tools)
- PostgreSQL (relational database administration, exposing 9 tools)
The evaluation tasks and ground-truth verifiers are provided by the independent mcp-universe and mcpmark benchmarks. Crucially, the training environments share no entities, data entries, or states with the evaluation environments to prevent data leakage.
Key Insights and Ideas
- Failed trajectories are goldmines: A trajectory that fails a complex multi-step goal often successfully completes a simpler, related sub-task. Relabeling the goal based on the outcome prevents massive data wastage.
- Information theory over LLM judges: Instead of prompting an LLM to subjectively score an agent's actions (which performs poorly in complex tool environments), computing mathematical information gain (PMI) provides a robust, automated safeguard that naturally suppresses noisy or misaligned data.
- Targeted offline adaptation beats scale: A 32B model fine-tuned with AgentBrew on a specific environment can significantly outperform a general-purpose 235B foundation model.
Key Results
- Substantial Performance Gains: On average across the three applications, AgentBrew improves the Qwen3-32B base model by +8.7% in Accuracy and +9.7 in overall Score.
- Outperforming Baselines: It comfortably beats standard Rejection Sampling (+5.9% Acc / +10.3 Score improvement over it) and the cross-environment synthetic data baseline TOUCAN.
- Rescuing Complex Environments: On Notion, where complex stateful interactions cause standard LLM judges to fail completely (resulting in 0% accuracy for rejection sampling due to over-filtering), AgentBrew recovers enough fine-grained signal to achieve 14.2% Accuracy.
- Offline Transferability: The data distilled by a Qwen3-32B model successfully transfers to a smaller Qwen3-14B model, boosting its performance by +11.5% Accuracy and nearly matching the 32B model's performance on Notion.
Limitations and Future Work
- Application Scope: The framework has currently only been validated across three MCP applications.
- Long Trajectories: Retrospective task inference might degrade or face context limits on extremely long or chaotic trajectories.
- Causal Entanglement: PMI acts as an informational proxy for action quality, which means it might not capture all true causal effects in highly entangled action sequences where an early mistake sets off a chain reaction.
- Future Directions: The authors suggest applying AgentBrew directly to real user interaction logs in production environments to learn from authentic human demonstrations at scale.
Summary updated