From Data to Tools: A Tool-Centric Framework for Cross-Environment Agent Synthesis

    Training AI agents on synthetic environments has become the default way to build long-horizon tool-use capability, but the common data-first approach tends to produce distorted tool definitions, weakly grounded tool combinations, and tasks confined to a single environment. This article introduces a tool-centric framework that reverses the process: reconstruct tools from real execution traces, cluster them into environments based on their execution relationships, and synthesize verifiable cross-environment tasks through state-aware walks on a tool graph. It covers the two-phase methodology, the engineering infrastructure needed for tool registration, state storage, and sandbox execution, the training and evaluation pipeline, and the reported results, limitations, and future directions. Agent platform engineers will find a reusable, verifiable, and extensible pattern for building training data and evaluation benchmarks on shared foundations.

    1. The Problem: Why Data-First Synthesis Fails to Produce Realistic Workflows

    In agent training, an “environment” is a sandbox where the agent can observe state, call tools, and receive feedback—for example, a business system with a database, a set of callable APIs, and their validation rules. High-quality synthetic environments are the source of long-horizon tool-use capability, but where you start building the environment determines the ceiling of what can be generated.

    A common industry approach is data-driven: generate a database schema and business data first, then define scenarios, and finally work backward to infer which tools are needed and what tasks to issue. This works well for single systems and short workflows, but when scaled to real business operations, three structural gaps emerge.

    1. Distorted tool definitions. Tools are inferred from preset scenarios rather than taken from real APIs, so parameter names, type constraints, return structures, and even error codes may diverge from production systems. The agent learns “illustrative interfaces” and must repeatedly trial-and-error on unfamiliar parameter semantics when migrating to real systems.

    2. Combinations lack execution grounding. “After tool A, you can call tool B” is often a human judgment call, unsupported by call data. The generated combinations may miss preconditions or even be infeasible at the execution level.

    3. Tasks are trapped in a single environment. Because environments map one-to-one with tools, tasks can hardly cross environment boundaries.

    Real business is the opposite—cross-environment operation is the norm. Take “a customer requests a refund” as an example. The complete chain may include:

    • Verifying the request in the customer service system;
    • Querying the transaction and checking refund eligibility in the order system;
    • Initiating the refund in the payment system;
    • Recording the outcome in the ticketing system;
    • Sending a notification to the customer.

    Any of these steps involves cross-system data transfer (e.g., writing an order ID into a payment request), state handoff (e.g., a ticket can only be closed after the refund succeeds), and tool orchestration (e.g., switching to a manual review branch on failure). If training data covers only single-system operations, the agent learns isolated actions rather than an end-to-end method.

    To address this, a research team led by one university and joined by two others proposed a tool-centric framework for cross-environment agent environment synthesis (referred to below as the tool-space method). It changes the approach at its root: instead of “define the scenario, then build the tools,” it first reconstructs the tools, then weaves out the environments, and finally walks tasks across the tool graph.

    2. Core Idea: Tools as the Fundamental Unit Connecting Environments

    The tool-space method treats the tool as the fundamental unit through which an agent executes tasks. Its overall flow can be summarized as:

    1. Execution traces ──► Tool composition graph ──► Cluster by tool relations ──► Environments (tools + underlying data)
    2. │
    3. ▼
    4. Executable cross-environment task ◄── State-aware random walk
    5. │
    6. ▼
    7. Natural-language task + verification script ──► Training data / evaluation benchmark

    The judgment behind this design is that an environment should not be predefined but should “grow” out of the execution relationships between tools. Compared with this, the data-driven mode has three fundamental limitations:

    Dimension Data-driven mode Tool-centric mode
    Starting point Preset database and business scenarios Tools from real execution traces
    Tool definition Inferred from scenarios, prone to distortion Taken from real tools, semantics preserved
    Tool combination Relies on human experience Grounded in real call relationships from traces
    Task scope Usually limited to a single environment Can span multiple environments
    State and verification Mainly designed by hand State data filled in on demand, call chains replayable and verifiable

    3. Phase One: Tool Space Exploration—Making Tool Connections Evidence-Based

    The first phase answers two questions: what real connections actually exist between tools? Which tools should be grouped into the same environment?

    3.1 Reconstructing Tools from Execution Traces

    The raw material is real or high-fidelity simulated task execution traces, including each step’s tool call, inputs, return values, and error messages. The system parses tool nodes from them, abstracts adjacent or related calls into directed connections, and ultimately produces a tool composition graph. Traces may come from manual operation logs or from successful execution records of existing agents. Whichever the source, three principles should hold:

    • Preserve the original call parameters and return structures, avoiding manual simplification that causes semantic drift;
    • Record tool versions consistently, and refresh the graph promptly after interface upgrades;
    • Record failure traces, which contain the negative signal of “which tools cannot connect.”

    3.2 Defining Tool Connections with Execution Evidence

    In the tool composition graph, a connection is valid only when it has execution evidence. At minimum, it should satisfy:

    • Temporal precedence: tool A is called earlier in time than tool B;
    • State handoff: A’s return value or side effect (e.g., an order ID or session ID) is a required input for B;
    • Frequency threshold: the transition recurs stably across multiple traces, ruling out incidental noise.

    Illustrative code:

    1. # Build a tool composition graph from traces (illustrative logic, not real APIs)
    2. edge_count, param_flow, fail_count = Counter(), defaultdict(set), Counter()
    3. for traj in trajectories: # each trajectory is a time-ordered sequence of call records
    4. for prev, curr in consecutive_calls(traj):
    5. if share_flow_variable(prev, curr): # data or state is passed between them
    6. edge_count[(prev.name, curr.name)] += 1
    7. param_flow[(prev.name, curr.name)].update(shared_fields(prev, curr))
    8. if curr.status == "error": # failure info is valuable evidence too
    9. fail_count[(prev.name, curr.name)] += 1
    10. tool_graph = build_graph(
    11. edge_count,
    12. min_support=MIN_FREQ, # frequency threshold to filter incidental co-occurrence
    13. max_fail_ratio=0.2, # high failure ratio means an unstable linkage
    14. param_flow=param_flow,
    15. )

    This shows that tool connections are not subjectively designed but statistically derived from calls that have “actually run through.” This provides a traceable execution basis for the subsequent task synthesis.

    3.3 Organizing Environments by Tool Relations and Filling In Persistent State

    Given the tool graph, the system clusters tools by connection strength; tightly related tools are organized into an environment. Environments connect to one another through cross-environment connections, forming an interlinked set of environments.

    Meanwhile, some operations must maintain state across multiple calls—for example, you can pay only after placing an order, or fill in a ticket’s resolution only after putting it on hold. For such operations, the system fills in the underlying data according to state requirements, giving the environment a “persistent and traceable” capability. Illustrated as:

    1. @dataclass
    2. class Environment:
    3. env_id: str
    4. tools: list[str] # set of tools belonging to this environment
    5. state_schema: dict # state structures to persist, e.g., order table, ticket table
    6. seed_builder: Callable # seed data builder, initialized on demand

    At this point, changes to persistent state within an environment themselves become a bridge connecting different environments: a refund record in the payment environment can serve as the basis for closing a complaint in the ticketing environment.

    4. Phase Two: Cross-Environment Verifiable Task Synthesis

    4.1 State-Aware Random Walk

    The system performs a state-aware random walk over the tool graph. “State-aware” means that when choosing the next tool, it not only looks at the connections in the graph but also judges:

    1. Whether the current state satisfies the tool’s preconditions;
    2. Whether the new state produced after the call can support subsequent tools;
    3. Whether it helps extend the task into a new environment, increasing the task’s span.

    Illustrative code:

    1. def state_aware_walk(tool_graph, state, max_steps=12):
    2. path = []
    3. for _ in range(max_steps):
    4. candidates = [t for t in tool_graph.successors(state.current)
    5. if preconditions_met(t, state)] # state-aware filtering
    6. if not candidates:
    7. break
    8. nxt = weighted_choice(candidates, bias="cross_env") # mild bias toward cross-environment jumps
    9. result = invoke(nxt, state) # actually execute in the sandbox
    10. state.apply(result)
    11. path.append((nxt.name, result))
    12. if is_goal_state(state):
    13. break
    14. return path, state

    Unlike “connecting nodes by probability” on a static graph, every step in the walk is actually executed in the sandbox. Branches that don’t work are pruned early, and only call chains that run through proceed to the next stage.

    4.2 Converting Call Chains into Tasks and Verification Scripts

    A call chain that runs through contains complete inputs, the tool sequence, and the final state, and can be mechanically converted into three parts:

    • Natural-language task: describes the user goal but gives only the starting information without exposing the call chain details, avoiding “prompt leakage”;
    • Initial state: a snapshot of the environment state when the task is issued;
    • Verification script: assertions over the final state, such as whether the order status changed, whether amounts reconcile, and whether the ticket flowed according to rules.

    Illustrated as:

    1. def build_sample(chain, final_state):
    2. task = Task(
    3. instruction=render_user_query(chain.start_state), # describe only the goal, do not leak the call chain
    4. init_state=snapshot(chain.start_state),
    5. verify=lambda s: all(a.check(s) for a in derive_assertions(final_state)),
    6. meta={"env_span": chain.env_span(), "steps": len(chain), "tools": chain.tool_names()},
    7. )
    8. return task

    The verification script is generated automatically from state diffing—comparing key fields before and after execution—rather than relying on manual, line-by-line authoring. This greatly reduces synthesis cost and gives an objective basis for judging “whether the task is complete.”

    4.3 Difficulty Stratification and Replayable Filtering

    Not all walk results are worth entering the training set. The system filters replayable samples by two metrics:

    • Difficulty: mainly the number of call steps, the number of distinct tool types, and whether it involves branching and error recovery;
    • Cross-environment scope: how many environments the task spans and how many environment switches it goes through.

    Only samples that can be replayed stably and pass the verification script are kept. Illustrated as:

    1. def difficulty(task):
    2. m = task.meta
    3. return m["steps"] + 2 * (m["env_span"] - 1) + len(set(m["tools"])) * 0.5
    4. selected = [t for t in tasks
    5. if replayable(t, times=3) and t.verify(snapshot(t.init_state)) is False]
    6. selected = stratified_sample(selected, by=["difficulty", "env_span"])

    The t.verify(init_state) is False above corresponds to an important quality-control principle: the verification script must return “fail” on the initial state where the task has not yet been executed. Otherwise, the script cannot distinguish “complete” from “incomplete” and would produce false positives.

    5. Engineering Implementation: Treat the “Environment” as Infrastructure

    The effectiveness of the tool-space method depends not only on the algorithm but also on how solid the underlying infrastructure is. The following points are worth attention during implementation.

    5.1 Unified Tool Registration and Semantic Validation

    All tools should be registered uniformly with a structured description, including name, owning environment, parameter schema, return structure, and side-effect declarations:

    1. {
    2. "name": "issue_refund",
    3. "env": "payment",
    4. "parameters": {
    5. "type": "object",
    6. "properties": {"order_id": {"type": "string"}, "amount": {"type": "number"}},
    7. "required": ["order_id", "amount"]
    8. },
    9. "returns": {"refund_id": "string", "status": "string"},
    10. "side_effects": ["refund_record", "order_status"]
    11. }

    The tool description can directly drive parameter validation, precondition checks during the walk, and interface-constraint hints during training.

    5.2 State Storage and Data Initialization

    Persistent state is best stored in a relational or document database, combined with the following design:

    • An independent data namespace for each environment;
    • One-click reset and snapshot restore;
    • Seed data templates that keep initial conditions controllable and reproducible across different tasks.

    5.3 Sandbox Execution and Concurrency Isolation

    The walk and replay require a large number of concurrent tool calls, so it is recommended to:

    • Package each environment instance as an independent container, scheduled and elastically scaled by a container platform;
    • Restrict filesystem and network permissions inside the instance to prevent out-of-bounds side effects from synthesis scripts;
    • Use simulated implementations for any tools involving sensitive operations such as real funds or accounts, and never connect to production systems.

    5.4 Observability Support

    It is recommended to collect execution logs uniformly, covering each call’s inputs, returns, latency, and error codes. Combined with logging services and monitoring/alerting, you can quickly locate whether a walk failure lies in the tool implementation, a state constraint, or the graph structure itself, providing a basis for iterating on the graph.

    In practice, teams can build the execution and replay cluster on cloud infrastructure—using managed containers, databases, and logging/monitoring services from providers such as Baidu AI Cloud—so they can concentrate their effort on graph construction and task synthesis logic.

    6. From Synthetic Data to Model Capabilities: Training and Validation

    6.1 Training Stage

    • Cold start: use verified high-quality trajectories for supervised fine-tuning, so the model masters the tool-calling format and basic cross-environment handoff patterns;
    • Rejection sampling: have the model attempt the same task multiple times, keep only the execution trajectories that pass the verification script, and feed them iteratively back into the training set;
    • Reinforcement learning: use the verification script’s output as a verifiable reward signal, adopting methods such as Group Relative Policy Optimization (GRPO) to encourage the model to learn long-horizon strategies like “query before writing, fall back on failure, and reconcile across environments.”

    It is worth emphasizing that rewards in long-horizon tool tasks are very sparse: the model may not trigger its first state error until the ninth step. Verifiable step-by-step assertions are precisely the key to mitigating this problem—they break down “whether the final result is correct” into multiple observable checkpoints.

    6.2 Validation Stage

    The same synthesis pipeline can also build “upgraded” evaluation benchmarks. For example, building on general benchmarks oriented to workflow automation and to multi-domain business dialogue, one can construct more challenging Pro versions that add more environments, lengthen the call chains, and introduce exception branches and distractor tools, to test an agent’s continuous execution ability in complex workflows.

    Evaluation should adhere to three principles:

    1. Train–eval isolation: the tool seeds, walk paths, and state templates used for evaluation must not overlap with the training set;
    2. Multi-dimensional metrics: besides task pass rate, separately track cross-environment handoff success rate, average number of call steps, and the proportion of invalid calls;
    3. Leakage checks: task descriptions must not contain call-chain hints, and verification scripts must not hardcode matching against a specific model’s output.

    7. Results, Limitations, and Outlook

    According to publicly released results from the research team:

    • After training on data synthesized with this framework, performance improved across seven long-horizon tool benchmarks;
    • A Mixture-of-Experts (MoE) model with about 744B total parameters and about 40B active parameters improved its composite performance from 44.6 to 56.6, on par with mainstream frontier closed-source models;
    • The team also built upgraded versions of two long-horizon tool benchmarks to evaluate agents’ continuous execution ability in complex workflows.

    The method has boundaries that deserve honest acknowledgment:

    • Dependence on trace quality: the completeness of the tool graph depends on the coverage of the original traces, and long-tail tools may have sparse connections;
    • Parameter sensitivity: clustering granularity and frequency thresholds affect how environments are partitioned, requiring tuning in combination with business semantics;
    • Difficulty of modeling side effects: implicit side effects are hard to fully capture with a state model, so a case may pass the verification script while the business outcome is not truly completed;
    • Not cheap: the walk and replay need substantial sandbox resources, and large-scale synthesis places heavy demands on compute and scheduling.

    Future directions for improvement include: continuously feeding real user interaction feedback back into the tool graph to form a closed loop of dynamic graph updates; introducing diversity and deduplication constraints on synthetic tasks to avoid homogeneous training data; and introducing human-in-the-loop review in security-sensitive scenarios to double-confirm tasks involving funds or compliance.

    Conclusion: The core lesson of the tool-space method is that an agent’s environment need not start from a preset data table but can start from the execution relationships that genuinely exist between tools. By connecting tools into a “map of the universe” and then carving out environments and generating tasks from it as needed, training data and evaluation benchmarks can share the same underlying logic. For teams building agent training platforms, this path offers a reusable, verifiable, and extensible engineering paradigm.