Tool-Centric Environment Synthesis for Cross-Environment Agent Training
This article explains why agent training requires executable environments and why data-centric environment synthesis has structural limitations. It presents a tool-centric synthesis approach that starts from tools extracted from execution traces, builds a tool composition graph, organizes environments by tool relationships, and generates tasks through state-aware random walks. It also covers verification script design, sample filtering, evaluation design, engineering considerations, and the limitations of the approach. Readers will learn how to build agent training and evaluation environments that better reflect real tool interfaces and cross-environment workflows.
1. Background: Why Agent Training Needs Executable Environments
Agents complete tasks by calling tools, such as querying orders, updating inventory, or issuing refunds. These capabilities cannot be learned from plain text corpora alone. A model must repeatedly attempt tasks in an executable environment, observe returned results, and adjust its strategy based on state changes. A training environment therefore usually contains three parts: tool interfaces, underlying data that carries state, and verification rules that determine whether a task is complete.
Real business workflows rarely stay within a single system. A refund may involve an order service, a payment gateway, and a customer support ticketing system at the same time. If training tasks cover only a single environment, an agent often learns isolated calling patterns. When it encounters cross-system data passing, state transitions, and multi-step orchestration, its performance can drop noticeably. Training environments therefore need to cover tool collaboration relationships across environments.
2. Data-Centric Synthesis and Its Limitations
A common approach is to first generate databases and business scenarios, then design tools and tasks around the data. This route is straightforward to implement, but it has three structural problems.
First, interface definitions may deviate from real specifications. Tool parameter names, types, and value constraints are inferred manually, and they may be inconsistent with the conventions of real systems. Parameter habits learned in such environments can fail when transferred to real systems.
Second, tool combinations lack an execution basis. Whether two tools can be chained depends on whether the output of the first tool satisfies the input requirements of the second. If tools are connected only at the data level, the result may be call chains that no one has actually executed and that are semantically invalid.
Third, task scope is limited. Environments that start from data are often built around a single business domain. Cross-environment tasks require additional design, which is costly and unstable in coverage.
3. Tool-Centric Synthesis Approach
Conversely, tools can be treated as the starting point for environment construction. Tools are the basic units through which agents execute actions. Their definitions come from real systems, and their composition relationships can be observed from execution records. Based on this view, the synthesis process can be divided into two stages: first build the tool space and organize environments as needed, then explore the tool graph and generate tasks.
3.1 Extracting Tools from Execution Traces
Execution traces record the tool name, input parameters, returned results, and timestamps for each step an agent takes. Extracting tools requires three things:
- Normalize tool signatures, merging different representations of the same tool across traces into a single node.
- Infer parameter types and value ranges from observed calls to form interface descriptions.
- Label whether each tool produces persistent state, such as creating records or changing balances. Read-only tools and write tools are handled differently during environment construction.
The output of this step is a set of tool definitions backed by execution evidence, rather than interfaces designed from scratch.
3.2 Building a Tool Composition Graph
Connections between tools are established only when there is evidence in traces. There are two common types of evidence:
- Data dependency: an output field of the previous tool is used as an input by the next tool.
- State dependency: the previous tool modifies an entity, and the next tool reads or modifies the same entity.
Each edge can carry statistics such as co-occurrence counts and call success rates. These statistics help later steps distinguish common reasonable combinations from occasional anomalous ones.
3.3 Organizing Environments by Tool Relationships
After the tool graph is built, closely related tools are grouped into the same environment. The grouping criterion is connection density: tools within the same business domain usually reference each other more frequently and should belong to one environment; cross-domain tools are connected through only a few edges and are better treated as interfaces between environments.
For tools that require persistent state, the underlying data must also be completed. For example, if a query tool requires an order ID to exist, the corresponding order record must be preloaded in the environment. Data serves the execution needs of tools rather than being generated independently before tools.
3.4 State-Aware Random Walks
On the tool graph, the system starts from a starting tool and walks randomly along edges to generate candidate call chains. Unlike an ordinary random walk, this walk must maintain a simulated state that records currently existing entities, available identifiers, and completed write operations. The walk is allowed to move to a subsequent tool only when that tool’s preconditions are satisfied.
This constraint ensures that generated call chains do not contain errors such as “referencing a nonexistent object” or “querying before creation” during execution.
The following is a simplified illustration of this logic, omitting details such as parameter matching and exception handling:
import randomdef state_aware_walk(graph, start, state, max_len=6):"""Walk the tool graph and extend the call chain only when preconditions are met."""chain, current = [start], startfor _ in range(max_len - 1):candidates = [nxt for nxt in graph.get(current, [])if preconditions_met(nxt, state)]if not candidates:breakcurrent = random.choice(candidates)chain.append(current)state = apply_effects(current, state) # Update the simulated statereturn chain
3.5 Converting Call Chains into Tasks and Verification Scripts
An executable call chain needs to be converted into two things.
The first is a natural-language task. The task description should state the goal and constraints, but it should not reveal the specific call order; otherwise, the agent could pass simply by copying the steps.
The second is a verification script. Verification should not rely on the agent’s textual answer. Instead, it should check whether the post-execution environment state matches expectations, such as whether a record was updated or whether a cross-environment identifier was passed correctly. State comparison is more reliable than text comparison and harder to game with surface-level output.
3.6 Sample Filtering
Not all generated tasks are suitable for training or evaluation. They need to be filtered along three dimensions.
- Difficulty: Grade tasks by call chain length, number of branches, and complexity of conditional judgments, and ensure a balanced number of samples at each level.
- Cross-environment scope: Count the number of environments involved in a task, prioritizing samples that genuinely require cross-domain collaboration.
- Replayability: Repeat the same task in an isolated sandbox, and the results should be fully consistent. Samples that cannot be replayed stably usually indicate races or random dependencies in the environment and should be removed.
4. Evaluation Design: From Standard Benchmarks to Upgraded Benchmarks
The quality of training data is ultimately reflected through evaluation. For long-horizon tool use capabilities, upgraded versions can be built on top of standard benchmarks. The main methods include:
- Increasing the number of required steps so that the agent must maintain state consistency over longer chains.
- Increasing cross-environment data passing, for example requiring the output identifier of one environment to be used as input in another environment.
- Introducing mid-task constraint changes or anomalous returns to test the agent’s recovery ability.
Evaluation reports should include the following metrics together: task success rate, average number of tool calls, success rate on cross-environment tasks, and the misjudgment rate of verification scripts. Reporting only a single overall score makes it difficult to determine which types of scenarios the model fails in.
5. Engineering Considerations
Isolation and permissions. Synthetic environments and execution sandboxes should be fully isolated from production systems and should not connect to real credentials or real data. Tool execution permissions should be granted on a least-privilege basis, exposing only the interfaces required by the task.
Data desensitization. If underlying data references the structure of real business data, field values should be replaced or anonymized to avoid residual personal information.
Quality spot checks. After verification scripts are generated automatically, they should be checked through human sampling. If the verification logic itself is wrong, the model may be incorrectly rewarded or penalized, and the problem will be amplified during training.
Version management. Tool graphs, environment data, and task samples should all carry version numbers. When underlying tool definitions change, it should be possible to trace which samples have become invalid.
6. Limitations and Applicability
The effectiveness of this method depends heavily on trace quality. Only observed calls form edges, and reasonable combinations that do not appear in traces will be missed. Therefore, trace diversity directly determines the coverage of the tool graph. In addition, state-aware walks can guarantee preconditions only under the simulated state, and deviations may still exist between the simulated state and the real system. These need to be addressed through replay validation and human spot checks. Difficulty grading thresholds also need to be calibrated according to the capabilities of the target model; there is no universal fixed standard.
7. Conclusion
Tool-centric environment synthesis starts from real tool definitions and execution evidence, then organizes environments, generates tasks, and filters samples. Compared with the data-centric route, it stays closer to real interfaces, makes it easier to generate cross-environment tasks, and is easier to verify. For teams building agent training and evaluation systems, this approach can begin with trace extraction and tool graph construction, then gradually expand into a complete task synthesis pipeline.
