A Stanford team has released TRACE, an open-source system that converts repeated agent failures into specific training data. It is licensed under MIT. TRACE stands for Turning Recurrent Agent failures into Capability-targeted training Environments.
In this article
The core problem
Agentic LLMs repeat the same mistakes. They fail because they lack specific skills required for a task, such as retrieving a record or checking a precondition.
Standard fixes waste compute. Direct reinforcement learning or supervised fine-tuning provides sparse rewards that do not identify the missing skill. Broad synthetic data generation is untargeted, wasting budget on abilities the model already possesses.
TRACE operates on the observation that failures are not random. A small set of deficits accounts for most failed trajectories. Each recurring deficit becomes a dense, verifiable training signal.
The workflow
The system runs an automated four-step pipeline. An LLM agent drives every step using a markdown prompt.
Step 1: Contrastive capability analysis
The base agent generates rollouts in the target environment. An analysis agent splits them into successful and failed sets. It then labels every trajectory-capability pair as NA, PRESENT, or LACKING.
A capability is retained only when it is contrastive and high-coverage. Specifically, its contrastive gap must clear δ = 0.20 and coverage must clear ρ = 0.10. The pipeline keeps skills whose absence concentrates in failures.
Step 2: Targeted environment synthesis
A generation agent builds one synthetic environment per retained capability. Each environment isolates a single capability while preserving the target’s tool schemas and format.
Task instances are procedurally generated from random seeds. Because generation and verification are algorithmic, rewards need no human labels or LLM judge.
Step 3: Capability adapter training
Each capability gets one LoRA (Low-Rank Adaptation) adapter, trained on its synthetic environment. The training algorithm is GRPO (Group Relative Policy Optimization). The base model stays frozen throughout.
GRPO groups rollouts by shared seed, so scenarios are identical within a group. Rewards are then normalized within each group to isolate the policy’s contribution.
Step 4: MoE composition with token-level routing
TRACE composes the adapters into a Mixture-of-Experts (MoE) model. The backbone and adapters stay frozen, and only lightweight token-level gates are trained.
At inference, each token is routed top-1 to a single capability adapter. This lets the model switch experts mid-trajectory.
What it means
The method improves task success rates by focusing training on specific gaps rather than general capabilities. Results on the τ²-Bench show that targeted training and MoE composition beat prompt optimization and single-adapter baselines using the Qwen3-30B-A3B model.




