Agent Training Environment Synthesis: From Data-Driven to Tool-Driven

    \$\$This article explains why the bottleneck in agent training has shifted from data volume to environment design, and how tool-centric environment synthesis addresses the limitations of data-centric approaches. It covers tool space exploration, tool composition graphs backed by execution evidence, state-aware random walks, verifiable task generation, and replayable sample selection. It also summarizes training and evaluation results, practical deployment guidance, and the limitations of the approach.

    \$\$## 1. The Problem: Agents Lack Environments, Not Data

    Over the past year, agents have improved rapidly at tool calling, workflow automation, and similar tasks. Yet a recurring engineering challenge has emerged: the bottleneck in training data is no longer quantity, it is the environment. A model may have seen thousands of positive and negative tool-calling examples and still fail frequently in real business systems, because real environments have continuous state, side effects, and cross-system dependencies.

    Consider a typical scenario: an agent is asked to “reissue invoices for all overdue orders from last week and send the exception list to the finance group.” This task spans at least four environments: order management, invoicing, financial accounting, and messaging. The output of each step becomes the input of the next. If an agent is trained only on isolated examples from a single database and a single tool, it tends to exhibit skipped steps, state misalignment, fabricated arguments, and abandoned tasks in real workflows.

    This is why environment synthesis is becoming a critical part of agent training infrastructure. And how to synthesize an environment is itself a methodological fork.

    2. The Data-Centric Paradigm: Why It Falls Short

    The mainstream approach to environment synthesis is data-centric. Its typical pipeline is:

    1. Generate a business database (users, orders, inventory, and so on).
    2. Invent business scenarios and requirements around that data.
    3. Reverse-engineer tool interfaces and task descriptions from the data.

    This approach is highly efficient. It can produce large volumes of training samples in bulk. But it has three structural flaws.

    First, tool interfaces and argument logic easily drift from real definitions. When data comes first, tools are designed to fit the data. In the real world, tool interfaces are often the product of historical evolution: a parameter exists for backward compatibility, a field is valid only for a specific business line, or a call requires a prerequisite credential. Reverse-engineering from data smooths over these constraints. The model learns an idealized tool and then struggles with the real interface after deployment.

    Second, tool combinations lack a traceable basis for execution. When a synthesis pipeline asks for “tool A combined with tool B,” it often relies on semantic similarity (both are invoice-related) rather than real dependencies (A’s output is B’s input). The resulting combination chain looks reasonable on a static graph but fails at runtime because of mismatched arguments, insufficient permissions, or unmet state preconditions. Training on such examples as positives injects incorrect causal intuition directly into the model.

    Third, tasks are limited to a single environment. The natural boundary of the data-centric approach is one schema. Constructing cross-environment tasks requires merging multiple databases, and merging breaks the consistency and independence of the data. As a result, the training set is full of “long tasks within one database,” while real business workflows are full of “short chains across databases.” This distribution mismatch is the core problem.

    3. The Core Idea of Tool-Centric Synthesis

    A different path has been proposed in industry research: organize environments around tools and their execution dependencies, rather than around data. This can be described as a tool-centric, cross-environment environment synthesis framework. Its core principle is to treat tools as first-class citizens: a tool is both the organizing unit of an environment and a guarantee of task reachability.

    A complete implementation typically includes two core components: tool space exploration and cross-environment verifiable task synthesis. Together they form a closed loop. The former answers “what tools exist in the world and how do they interlock?” The latter answers “how do we walk along these interlocks to produce genuinely executable tasks?”

    Component 1: Tool Space Exploration

    (1) Extract tools from execution traces. The starting point is not a hand-designed interface inventory. It is real execution traces: logs, replay recordings, historical sessions, tool-call records from existing benchmarks, and even API signatures extracted from documentation and code repositories. During extraction, tool identity must be normalized. Aliases for the same functionality across systems should be merged, and overloaded methods should be distinguished by parameter signature.

    (2) Build a tool composition graph. This is the foundation of the entire framework. Nodes are tools. Edges represent composability. Edge attributes must carry traceable execution evidence: How many real traces observed this edge? What arguments were actually passed at call time? How was the return structure consumed downstream?

    1. {
    2. "tool": "invoice.issue",
    3. "domain": "finance",
    4. "requires": ["order.settled", "customer.kyc_passed"],
    5. "preconditions": {
    6. "db": "billing",
    7. "tables": ["invoices", "orders"],
    8. "state": {"invoice.status": "DRAFT"}
    9. },
    10. "postconditions": {
    11. "invoices.rows+": 1,
    12. "ledger.balance": "-=amount"
    13. },
    14. "evidence": [
    15. {"trace_id": "t-8842", "hits": 137, "avg_latency_ms": 210}
    16. ]
    17. }

    The key design here is the evidence field. An edge with evidence means the combination occurred in real execution, the arguments matched, and the state transitions connected. An edge without evidence can only be a low-confidence candidate and must not enter the positive sample pool. This fundamentally addresses the lack of execution basis for tool combinations.

    (3) Organize environments and underlying data around tool relationships. Instead of building one large, all-encompassing database, bind each tool (or tool family) to its own minimal environment unit: required tables, credentials, initial state, and scope of side effects. Environments are explicitly connected through the inputs and outputs of tool calls. In this way, “cross-environment” does not mean merging databases. It means letting state flow along the call chain, which mirrors how real business systems are organized.

    Component 2: Cross-Environment Verifiable Task Synthesis

    (1) State-aware random walk. When sampling paths on the tool graph, “state-aware” is the core idea: the candidate set for a walk is not all neighbors on the graph, but the successor tools that are actually executable in the current environment state. This requires maintaining an explicit environment state snapshot and updating it after each step.

    1. def sample_task(graph, env_pool, max_steps=8):
    2. state = env_pool.init_snapshot()
    3. chain, visited_envs = [], {state.env_id}
    4. while len(chain) < max_steps:
    5. # Keep only tools whose preconditions are satisfied under the current state
    6. frontier = [t for t in graph.successors(state)
    7. if env_pool.check_preconditions(t, state)]
    8. if not frontier:
    9. break
    10. # Favor rare tools and cross-environment edges to increase diversity and difficulty
    11. tool = weighted_sample(frontier, key="rarity_and_cross_env")
    12. args = bind_args(tool, state) # Arguments must come from state; fabrication is prohibited
    13. result = env_pool.execute(tool, args) # Real execution produces a real trace
    14. chain.append(Trace(tool, args, result))
    15. state = env_pool.advance(state, result)
    16. return chain, visited_envs

    The constraint on bind_args deserves emphasis: arguments can only be drawn from the current state and must not be generated by the model. This is essential for guaranteeing task executability, and it is the fundamental difference from the traditional “invent a task first, then find tools to fit it” approach.

    (2) Convert the call chain into a natural-language task and a verification script. A successful trace needs two-way translation:

    • Forward: Abstract the tool chain into a requirement phrased in natural human language. Vague references and implicit premises can be injected to improve realism.
    • Reverse: Compile the terminal state of the trace into an executable verification script, usually expressed as assertions that check state conditions.
    1. def verify_final_state(env, expected):
    2. checks = [
    3. ("invoices_created", env.count("invoices", status="ISSUED") == expected.n),
    4. ("ledger_consistent", env.balance("ledger") == expected.balance),
    5. ("no_extra_calls", env.calls_outside(expected.allowed) == 0),
    6. ("idempotent", env.replay_safe(expected.chain)),
    7. ]
    8. return all(ok for _, ok in checks)

    A good verification script checks not only “whether the result is correct” but also “whether the process has unnecessary side effects,” for example, duplicate invoicing or bypassing approval. Such constraints significantly suppress an agent’s tendency to “brute-force trial and error until it accidentally hits the right answer.”

    (3) Filter replayable samples by difficulty and cross-environment scope. Sampled traces need to be stratified along common dimensions: number of tool calls, number of environments crossed, presence of conditional branches and failure retries, and whether cross-environment data transfer is required. Only samples that satisfy “deterministic replay given an initial snapshot” are added to the dataset. Replayability is infrastructure for training and evaluation: it enables reward computation in RL, data cleaning for SFT, and failure reproduction for regression testing.

    4. Training and Evaluation Results

    The research team validated the approach in two directions, and the conclusions have direct practical value.

    Training side: broad improvements on long-horizon tool benchmarks. After training on data synthesized under this framework, a sparse model with approximately 744B total parameters and approximately 40B activated parameters achieved stable improvements across seven long-horizon tool-use benchmarks. The aggregate score rose from 44.6 to 56.6, placing it roughly on par with the state-of-the-art closed-source flagship models. Notably, the gains were not “overfitted improvements” concentrated on a few benchmarks. They were broad gains across benchmarks, which aligns with the expectation that “what improves is the environment distribution, not the answer distribution.” The implication for engineering teams is clear: if an existing agent is stuck on long-horizon tasks, prioritize checking the cross-system coverage of its training environments rather than piling on more same-distribution samples.

    Evaluation side: constructing harder upgraded benchmarks. Because the training distribution has become stronger, standard benchmarks are gradually saturating. The research further built upgraded benchmarks targeting automated office workflows and banking-domain tool calling. Compared with standard versions, these benchmarks are significantly harder in three ways: task chains are longer and include conditional branches; agents must transfer and transform data across multiple business systems; and more near-miss but incorrect tools are introduced as distractors. The value of such benchmarks lies in testing an agent’s continuous execution capability: not choosing the right tool at a single step, but maintaining goal fidelity and state consistency over dozens of steps.

    5. Implementation Notes and Common Pitfalls

    First, verifiability is the lifeline of an environment. An environment without a verification script is just data, not an environment. It is recommended to enforce the following in the metadata required for environment registration: initial snapshot, executor implementation, terminal-state assertions, and an idempotency declaration. An environment missing any of these should not be allowed into the training pool.

    Second, difficulty must be explicitly sampled, not left to natural distribution. In real traces, the vast majority are simple two-step or three-step calls. Sampling directly yields a large number of low-value samples. Instead, stratify sampling by path length on the tool graph, and deliberately retain failure samples (paths that cannot be completed) as negative examples or correction training data.

    Third, the evolution of the tool graph needs governance. In real systems, interfaces change and get deprecated. Introduce versions and confidence scores for tool nodes, periodically recompute edge evidence weights using new traces, and downweight or retire tools that have had zero calls for a long time.

    Fourth, cost control relies on architecture, not brute force. Environment execution is a resource-intensive operation. Recommended practices include: pooling environment instances and waking them on demand; storing state snapshots in object storage and reclaiming them by reference counting; decoupling asynchronous tool calls via message queues to avoid long-chain synchronous blocking; and instrumenting the full pipeline with logging services and monitoring alerts to locate the root cause of failed samples. For cloud deployment, container platforms can provide environment isolation and elastic scaling, object storage can hold snapshots, message queues can handle asynchronous execution, and logging plus monitoring can support observability. These are standard capabilities available on mainstream cloud platforms (including Baidu AI Cloud) and can be combined as needed.

    Fifth, beware of “environment overfitting.” No matter how rich the synthesized environments are, they are only a slice of the real system. It is recommended to reserve a real holdout set that never participates in synthesis for final evaluation, and to periodically feed real online failure cases back into the tool space, forming a “synthesize-evaluate-feedback” loop.

    6. Limitations and Outlook

    This approach also has clear boundaries. The quality ceiling of the tool space depends on the quality of execution traces. During cold start, if usable logs are unavailable, a round of tool onboarding and recording is required first. State-aware random walks place high demands on the determinism of executors. For external services with strong randomness, tolerances and multiple sampling need to be introduced in the verification script. The verification scripts for cross-environment tasks are themselves code assets that require maintenance, and their correctness issues translate directly into reward noise.

    Possible evolution directions include: linking the tool graph with code repositories and documentation knowledge bases to automatically generate interface drafts for missing tools; introducing curriculum learning so that difficulty adapts upward with model capability; and in multi-agent collaboration scenarios, extending the edges of the tool graph into ternary “agent-tool-agent” relationships.

    Overall, shifting from data-driven to tool-driven synthesis means moving the source of correctness in environment synthesis from “the trustworthiness of the generation model” to “the traceability of real execution.” This shift may look like a mere reordering of the pipeline, but it determines whether synthesized environments can support long-horizon, cross-system, verifiable agent training. It is the critical step from “being able to call tools” to “being able to complete work.”