inferwire
/
AI·5 min read

EnvFactory Trains Tool-Using Agents in 85 Synthetic Environments

EnvFactory automatically builds executable tool environments and natural-sounding training conversations. With 85 environments, Qwen3 models beat baselines trained on far larger sets on average.

TL;DR

  • EnvFactory, from HKUST's LARK lab, Huawei and partners, automatically builds tested tool environments and realistic training conversations for language-model agents [^1].
  • With 85 environments and 2,575 conversations, it lifted Qwen3 models more on average than baselines trained on up to 526 environments [^1].

Background

Tool-use agents are language models that call external tools, such as a booking system or a database, instead of only writing text. Training them with reinforcement learning means letting the model attempt tasks in an environment and rewarding what works. The EnvFactory authors see two bottlenecks [^1]. Real APIs are costly to scale and their network latency destabilizes training, while tools simulated by a language model hallucinate. And synthetic training conversations tend to read like instruction lists, not real requests [^1].

What happened

On May 18, researchers from the LARK lab at HKUST, the University of Cambridge, UCL and Huawei posted EnvFactory on arXiv [^1]. Its first part, EnvGen, uses three cooperating agents. A Search Agent looks for gaps in the existing pool of environments and grounds new proposals in real online material such as API documentation and usage examples. A Code Agent turns each proposal into a stateful database plus Python code for every tool, exposed through the Model Context Protocol (MCP), a standard interface for tools. A Test Agent writes unit tests, checks that the tools run and change the database correctly, and sends error reports back until the tests pass or a revision budget runs out [^1]. The result was 85 verified environments with 842 tools across seven domains, from commerce and finance to travel and office work [^1].

The second part writes the training conversations. EnvFactory links tools whose outputs can feed other tools' inputs, then samples chains in which every required input comes either from the user or from an earlier tool call. A hotel_id for book_hotel, for example, has to come from get_hotel_list, because a user is unlikely to know it [^1]. A refinement step then makes the requests sound more human: it replaces explicit identifiers with references, drops steps that can be inferred and adds reasonable ambiguity [^1]. Agents work through each request with a simulated user, and the best of several attempts becomes the reference. In reinforcement learning, the reward combines a match against that reference sequence of tool calls, a check of the final database state and a penalty for needlessly long sequences [^1].

The team trained Qwen3 models with 1.7, 4 and 8 billion parameters, first with supervised fine-tuning on 1,622 conversations, then with reinforcement learning on 953 more [^1]. Averaged over four benchmarks, the 4B model rose from 24.09 to 30.77 and the 8B model from 29.23 to 33.40 [^1]. On the multi-turn part of the BFCL benchmark, the 4B model climbed from 33.50 to 48.50 [^1].

Why it matters

The paper's main claim is efficiency. The two comparison systems used far more material: AWM 526 environments and 3,315 training tasks, EnvScaler 191 environments and 11,572 tasks [^1]. EnvFactory had the best average at every model size, but not the best score on every benchmark: EnvScaler did better on BFCL multi-turn with the 1.7B and 8B models [^1]. More environments still helped. Training subsets of 50 and 75 environments scored lower on BFCL multi-turn, although the gain from 75 to 85 was smaller than the gain from 50 to 75 [^1].

The paper also documents its limits. Because of network connectivity problems, the MCP-Atlas results cover 30 of the benchmark's 36 servers and 291 of its 500 tasks [^1]. Only Qwen3 models up to 8B were trained, and reinforcement learning without the fine-tuning stage gave smaller and less stable gains [^1]. Since the environments keep state, each conversation needs its own connection, which the authors call a throughput bottleneck for large-scale synthesis [^1]. They also warn that the method could be misused to simulate fraudulent financial transactions or phishing campaigns, and say they released their artifacts under restrictive licenses [^1].

Practical example

Say Lena works at a small travel startup and wants a Qwen3-4B model that books hotels for customers in a chat. Training against the live booking API is costly to scale and its network delays make training unstable, and letting another language model play the API risks invented responses [^1]. Following EnvFactory's recipe, Lena's team instead gets a hotel environment written as real Python code with its own database, tested before it is used [^1].

A training request might simply ask to book the cheaper of two hotels near the station for Friday. The customer never names a hotel ID, because the simulated user only knows what a real person would, such as preferences, places and times [^1]. To succeed, the model has to call get_hotel_list first, pick the right result and pass its hotel_id to book_hotel [^1]. The reward then checks both the tool calls and whether the booking actually ended up in the database. That matters because valid solutions differ: two read-only lookups can run in either order and still be correct [^1].

The compute bill is modest by the paper's numbers. Generating 1,000 conversations took about 20 GPU hours, fine-tuning the 4B model about 10 and reinforcement learning about 20, on 80 GB GPUs [^1]. Lena should still test against the real booking system before launch, since the paper measures its gains on benchmarks.

Related gear

We recommend this book because it explains reinforcement learning from the ground up, the method EnvFactory uses in its second training stage.

AdvertisementAmazon

Reinforcement Learning: An Introduction

Sources

  1. [1]arXiv — EnvFactory: Scaling Tool-Use Agents via Executable Environments Synthesis and Robust RL