TL;DR
EnvFactory is a fully automated framework designed to scale LLM tool-use capabilities by autonomously synthesizing robust, stateful execution environments and generating realistic training trajectories. By replacing rigid, over-specified "instruction lists" with natural, ambiguous human intents and enforcing strict tool-dependency resolution, it trains highly capable agents using a fraction of the data required by previous methods.
What Problem Does This Paper Address?
Teaching Large Language Models (LLMs) to interact with external tools (like APIs or databases) via Agentic Reinforcement Learning (Agentic RL) is a major frontier in AI. However, progress is bottlenecked by two core challenges:
- Environment Scarcity and Instability: Interacting with real-world APIs is expensive and introduces network latency that destabilizes RL training. Conversely, using LLMs to simulate environments leads to hallucinations, and existing synthetic sandboxes are often stateless or restricted to pre-curated documents.
- The Realism Gap in Training Data: Current synthetic data generation methods produce over-specified "instruction lists" that explicitly tell the agent every parameter and step to take. In reality, human users provide concise, ambiguous, and implicit requests, leaving a massive gap between training conditions and real-world deployment.
Methods
EnvFactory introduces a unified, fully autonomous pipeline divided into two main components: environment construction (EnvGen) and trajectory synthesis (QueryGen).
1. EnvGen: Autonomous Environment Construction
Instead of relying on static documents, EnvFactory uses a multi-agent loop to build executable environments from scratch:
- Search Agent: Explores authentic online resources (websites, API documentation) to find diverse tool-use scenarios.
- Code Agent: Generates stateful databases and executable Python code wrapped in a standardized tool interface (Model Context Protocol, or MCP).
- Test Agent: Automatically generates unit tests, validates database state transitions, and feeds error reports back to the Code Agent for iterative refinement.
2. QueryGen: Realistic Trajectory Synthesis
To generate high-quality training data, EnvFactory avoids naive random walks across tools and instead implements:
- Dependency Tool Graph: Maps out nonlinear relationships between tools by combining semantic parameter matching with LLM-guided logical refinement.
- Topology-Aware Sampling: Ensures that when a tool sequence is sampled, all required input parameters are realistically satisfiable—either provided explicitly by the user or internally derived from a preceding tool's output.
- Calibrated Refinement: An LLM refines raw tool chains into natural human queries by compressing intermediate steps, introducing realistic referential ambiguity, and expanding goals with plausible secondary objectives.
Datasets
The authors used EnvFactory to autonomously construct 85 verified environments comprising 842 tools across 7 distinct domains (commerce, finance, travel, office, lifestyle, research, and utilities). From these, they synthesized 1,622 SFT tasks and 953 RL tasks.
Evaluation was conducted across four prominent benchmarks:
- BFCL v3 (Berkeley Function Calling Leaderboard) for multi-turn tool use.
- MCP-Atlas for real-world Model Context Protocol competency.
- $\tau^2$-Bench and VitaBench for complex, interactive conversational tool use.
Key Insights and Ideas
- Data Efficiency Trumps Raw Scale: EnvFactory consistently outperforms concurrent frameworks (like AWM and EnvScaler) despite using up to 5x fewer environments and significantly fewer training tasks. High-fidelity, stateful environments provide a much cleaner reward signal for RL than massive, poorly validated datasets.
- Statefulness is Mandatory: Moving beyond stateless tool-calling to stateful databases allows agents to learn the long-term consequences of their actions (e.g., how calling
book_hotelmodifies the system state for a subsequentcancel_bookingcall). - SFT is the Foundation, RL is the Polisher: The authors show that direct RL training without an SFT cold-start phase yields unstable and suboptimal results, proving that high-quality synthetic SFT initialization remains critical for stable policy optimization.
Key Results
EnvFactory achieved substantial performance gains when post-training Qwen3-series models (1.7B, 4B, and 8B parameters):
- BFCL v3 (Multi-turn): Qwen3-4B improved its average score from a baseline of 33.50% to 48.50%.
- MCP-Atlas: Qwen3-8B achieved a 13.75% pass rate (up from a 5.15% baseline) and 25.98% mean coverage, outperforming models trained on much larger datasets.
- Conversational Benchmarks: The framework boosted model performance by up to +6% on $\tau^2$-Bench and VitaBench, proving that the agents successfully generalized to handling implicit human intent and conversational ambiguity.
Limitations and Future Work
The primary limitation of EnvFactory stems from its strict stateful architecture. Because write-capable tools modify a shared environment database, each conversation requires a dedicated transport connection to the target MCP servers to prevent cross-contamination. This requirement constrains parallel tool invocation and creates a throughput bottleneck during large-scale data synthesis.
While the authors mitigated this using an asynchronous execution pipeline, future work will focus on optimizing session virtualization and scaling the framework to support multi-agent cooperative environments.
Summary updated