WorksComputer Science
CoT-Factory: Synthesizing the Missing Reasoning in Agent Trajectories
Abstract
Progress in long-horizon agents depends on scalable, high-quality interaction trajectories. However, trajectories generated by proprietary models typically lack accessible internal reasoning, while human interaction traces lack explicit chain-of-thought (CoT), limiting the reuse of existing data for agent training and iterative improvement. To unlock this underutilized supervision, we introduce CoT-Factory, a framework for training specialized CoT synthesis models that reconstruct reasoning from recorded histories and target actions without rebuilding or replaying interaction environments. Specifically, we adapt Tree-SFT to reduce redundant history computation and enable scalable training of synthesis models. Turning to the sampling stage, we introduce a new structured quality control scheme to improve reasoning quality, alongside action-conditioned guidance to improve action compatibility. On Terminal-Bench 2.1, our method improves Qwen3.5-4B to an average success rate of 26.96%, approaching the ideal upper bound of 28.46% achieved with original CoT. Across multiple agent benchmarks, our method consistently outperforms the compared CoT synthesis methods. These results demonstrate that CoT-Factory converts existing action trajectories into effective reasoning supervision, advancing inverse CoT synthesis for long-horizon agent training.
Introduction
Frontier long-horizon agents are advancing from tool use [21, 25] toward autonomous task completion [2, 4, 9, 17, 38]. Their progress increasingly depends on large-scale, high-quality interaction trajectories, collected through rollouts in newly constructed environments or curated from existing human activity records [29, 37, 50]. Yet a major challenge in expanding these datasets is obtaining the reasoning behind recorded actions. For example, collecting successful trajectories in challenging synthetic sandboxes often requires frontier models [20, 39], whose internal chain-of-
Figure 1. Overview of CoT-Factory’s performance on Terminal-Bench 2.1. Real CoT represents the ideal performance upper bound for synthesis methods. While the baseline degrades model performance, CoT-Factory provides high-quality synthetic data that progressively improves agent capabilities with training and approaches this ideal upper bound.
thought (CoT) is frequently withheld for safety reasons [8], while open-source models may struggle to produce successful trajectories. Meanwhile, human web interactions and code commits provide abundant action records [3, 16, 19], but lack explicit CoT annotations and available environments for reconstruction. Together, these factors create a substantial imbalance between actions and high-quality CoT in public data, limiting our ability to unlock the potential of existing trajectories for agent training.
In multi-turn agents, CoT connects historical observations to the next action by identifying relevant information, diagnosing environment feedback, and weighing alternative plans [27, 35, 41]. Action-only supervision tends to teach the surface form of an action rather than why it should be selected in the current state. Thus, how to synthesize effective CoT from existing context and target actions without access to the original environment is central to recovering the training value of existing trajectories, yet remains insufficiently studied for long-horizon agents.
Existing CoT completion approaches fall into two categories, both with limitations in long-horizon settings. Forward rejection sampling asks an open-source model to regenerate reasoning and an action from the same history, retaining only samples that match the recorded action [28, 43]. Matching complex tool calls or code operations is constrained by the open-source model’s capabilities, requiring repeated sampling and leaving many steps uncompleted. Action-conditioned inverse CoT synthesis follows two routes. Prompt-based methods directly instruct an LLM to generate CoT [6, 34], but often produce limited diversity and overly simple reasoning. Methods such as RLT [1] and Trace Inversion [46] instead train specialized CoT synthesis models to generate reasoning conditioned on target outputs. However, applying these models to long-horizon agent trajectories introduces three practical challenges: low compatibility between generated reasoning and target actions; prohibitive training costs from repeatedly encoding histories of hundreds of thousands of tokens; and unreliable quality assessment, because action likelihood measures how predictable an action is without identifying factual errors or logical inconsistencies in the generated reasoning.
In this work, we introduce CoT-Factory, a framework that turns existing action trajectories into reasoning-augmented data for agent training without reconstructing their environments. CoT-Factory first trains a synthesis model to infer CoT from recorded context and target actions, then uses this model to complete missing CoT in existing trajectories for downstream student training. To make synthesis-model training efficient on long context, we collect teacher-generated CoT–action pairs at recorded steps and use Tree-SFT to share repeated history computation [32, 45]. During CoT synthesis, action-conditioned classifier-free guidance (CFG) improves compatibility with given actions, while structured quality control checks the generated CoT against historical evidence. The resulting trajectories provide reasoning supervision for training the student agent.
Experiments demonstrate that CoT-Factory improves efficiency and reduces costs during training and sampling compared with existing synthesis and rejection-sampling methods. Moreover, evaluations across multiple widely-used agent benchmarks show that data produced by CoT-Factory yields substantially stronger downstream performance than other synthesis baselines, approaching the ideal upper bound on several metrics and recovering an average of 68% of the performance gains from original-CoT data across all benchmarks.
Our main contributions are as follows:
We systematically study reasoning completion for long-horizon action trajectories without CoT, analyze the limitations of forward sampling and existing CoT synthesis methods, and validate a replay-free completion pipeline through downstream agent training experiments.
We adapt Tree-SFT to action-conditioned CoT synthesis, reducing training costs for more than 70,000 steps with paths up to 262,144 tokens.
We combine history-grounded structured quality control with action-conditioned CFG to increase candidate acceptance while reducing synthesis cost.
We establish a practical recipe for large-scale, replay-free reasoning completion, showing how synthesis-training scale, structured verification, and reasoning diversity jointly support effective downstream supervision.
Related Work
Scalable Agent Data
Synthetic data. SWE-Gym, SWE-smith, and Terminal-Horizon [20, 39, 50] scale software tasks and trajectories, while OS-Genesis and ComputerRL [12, 30] extend GUI task generation and online RL. AgentOhana [44] unifies heterogeneous agent trajectories for training, while OS-ATLAS [36] scales GUI grounding data and action modeling. Such data can provide verifiable outcomes without accessible teacher reasoning.
Real-world data. Mind2Web and WebLINX [3, 16] collect human web demonstrations; Android in the Wild and AndroidControl [14, 23] cover mobile interactions, and OctoPack [19] uses code commits. These records often lack decision-time CoT. We recover reasoning supervision from both synthetic and real-world action records without environment replay.
Inverse CoT Synthesis
Prompt-based synthesis. OpenCUA [34] synthesizes reflective reasoning for recorded state–action pairs, while WebSTAR [6] augments action trajectories with intermediate thoughts and applies step-level filtering.
Trained synthesis models. Trace Inversion, RLT, and VR [1, 46, 49] train models to recover reasoning from known outputs or student feedback. We study this direction in long-horizon agent trajectories, where reasoning must connect extensive interaction histories to recorded actions. In this setting, making the target action likely does not ensure that the reconstructed reasoning is consistent with the preceding observations.
Method: CoT-Factory
CoT-Factory combines Tree-SFT, teacher-branch training data, action-conditioned CFG, and historical verification to complete reasoning without reconstructing or replaying the recorded interaction environments (Figure 2).
Figure 2. CoT-Factory overview. Tree-SFT learns the CoT synthesis model, action-conditioned CFG improves sampling compatibility, and structured quality control verifies problems, plans, and their analyses against recorded history.
Preliminaries
Let be the task instruction, the recorded action at step , and the observation returned after executing in a -step trajectory. The trajectory without CoT is . Before action , the recorded history is , with .
The synthesis model , with parameters , generates CoT conditioned on and , without access to or later observations. Each step uses only recorded information, enabling parallel completion without environment replay or previously synthesized reasoning.
Prior methods use answer likelihood to optimize teachers or learn reasoning posteriors [1, 49]. Let be the scoring model with parameters . Omitting the step index, is action token , and its prefix. For an action of tokens, its negative log-likelihood is
This measures action predictability rather than factual reasoning. A meaning-preserving transformation can change token probabilities: if each absolute log-probability ratio is bounded by , the total deviation satisfies . Length normalization preserves candidate rankings for a fixed action. Figure 3 shows lower-NLL candidates containing arithmetic or state-analysis errors, motivating explicit checks against historical evidence alongside the likelihood assigned to the corresponding target action under each candidate explanation.
Figure 3. Lower action NLL does not guarantee correct reasoning. In each case, CoT 2 has lower NLL than the ground-truth CoT 1 but contains arithmetic or state-analysis errors. Orange, purple, and blue indicate problems, analyses, and plans.
Algorithm 1 Tree-SFT forward and backward
Require: Histories , branches , parameters
; ,
for each branch do
end for
return
Tree-SFT
Given paired data , denotes reasoning token and its prefix. The loss supervises only these tokens, including termination, with denoting the batch’s supervised-token count:
Writing for a history segment and for concatenation, independent expansion repeats growing histories: prefixes , , and each encode the same initial prefix , recomputing identical history separately for each of the three supervised examples.
Inspired by Tree Training [32] and AReaL-DTA [45], we apply shared-prefix training to action-conditioned CoT synthesis on long-horizon agent trajectories. We refer to this application as Tree-SFT. Tree-SFT encodes shared history as one trunk and attaches action-conditioned reasoning leaves at each step. A leaf reads only the preceding trunk and its own causal prefix; positions continue from the attachment depth, preserving the same conditioning as independently processed training examples.
For hybrid architectures [40], attention layers reuse trunk KV, recurrent layers inherit attachment-state snapshots, and local convolutions copy their required context windows. Backpropagation scatter-adds leaf contributions to trunk KV, states, and convolution context before completing the trunk backward pass. Leaves are processed in bounded chunks to control memory (Algorithm 1).
With prefix length and leaf length in tokens, independent expansion and Tree-SFT process and tokens:
Prefix reuse accelerates inference [10, 48]; Tree-SFT additionally preserves training gradients and all supervised leaves. Token counts include repeated split boundaries,
Figure 4. Illustration of how Tree-SFT reduces redundant token computation. H denotes action–observation history accumulated along the trunk, A the action, and R the CoT target. Shared history is computed once; only CoT tokens receive direct supervision during training.
and measured runtime includes attention computation and scheduling costs for the supervised reasoning branches.
In Algorithm 1, branch attaches at with action and target . Shared states are restricted to that prefix by . Accumulated gradients and update parameters and trunk states; leaf gradients are summed before trunk backpropagation, preserving the combined loss gradient and each branch’s causal context.
Teacher Branches Along Recorded Trajectories
Training a CoT synthesis model first requires high-quality history–action–reasoning pairs. Requiring the teacher to reproduce the recorded action would reduce this process to costly forward rejection sampling. Instead, at each history prefix in an auxiliary trajectory subset, an open-source teacher policy samples reasoning and action in one forward branch sample:
Training the CoT synthesis model requires a coherent reasoning–action pair under the same history, not reproduction of . We filter malformed actions, empty or truncated reasoning, repetition, and action-protocol leakage. Reversing the sampled pair to provides training data for Tree-SFT while retaining the teacher’s reasoning distribution.
Figure 5 illustrates this distinction: at step 16, the recorded action writes a release audit, whereas the teacher first inspects commit history and feature records. This alternative reasoning–action pair provides training data for the CoT synthesis model without replacing the recorded action or modifying the recorded history for subsequent steps.
Figure 5. Tree sampling for CoT synthesis model training. A teacher generates independent CoT–action pairs as leaves from trunk histories containing actions and observations, but no CoT. These pairs need not match the ground truth; they train a CoT synthesis model to generate CoT conditioned on history and action.
Action-Conditioned CFG Sampling
For histories containing hundreds of thousands of tokens, the history prior can dilute the comparatively short target action condition, causing ordinary autoregressive samples to drift away from that action. Inspired by diffusion CFG [7] and its autoregressive extension [24], we drop the current action condition in a fraction of training branches. The same model thus supports both action-conditioned and action-unconditioned prediction. At reasoning token , conditional logits and unconditional logits are combined by extrapolation using a guidance weight , where is the guided logit vector, the sampling temperature, and the sampled token:
The difference isolates the contribution of the action condition from the shared history, emphasizing decision evidence relevant to . For , CFG strengthens target-action conditioning without training a separate model and increases single-sample compatibility.
Structured Verification of Reasoning Paths
Action compatibility does not ensure correct intermediate reasoning. Expressed reasoning need not faithfully reflect model computation [13, 31]. In our initial experiment with normal LLM-based QC on free-form CoT, whose problems, analyses, and plans are interleaved (Figure 3), we observed inconsistent judgments across repeated evaluations of the same candidate—alternately accepting it or flagging hallucinations—leading to unstable candidate selection. Inspired by process supervision [15, 42], Structured QC first rejects empty, truncated, repetitive, or extensively copied action text. A semantic matcher then checks whether the candidate can reasonably lead to the target action under history .
An extractor produces a set of units, each with type , statement , and supporting analysis :
Here, is the statement and the explicitly expressed analysis; absent analysis is . The verifier checks historical support, factual and arithmetic consistency, and whether plans misrepresent anticipated outcomes as observations. The Boolean acceptance gate requires
We retain the first passing candidate within a sampling budget of attempts. Unresolved steps preserve observations and actions, but their unverified reasoning is masked— from student loss. Verification uses neither reference CoT nor future observations and requires no replay. Empirical Pass@ measures coverage: Structured QC screens the reasoning candidates, while CFG improves their acceptance rate and increases the fraction of recorded interaction steps covered by accepted reasoning.
Experiments
Settings
Data and training. We reconstruct reasoning for TerminalHorizon-3k trajectories [50], withholding original CoT from reconstruction and retaining it for the Real and mask-CoT references. We sample reasoning–action pairs with DeepSeek-V4.1-Flash at 70,724 valid steps from 1,341 auxiliary trajectories to train the CoT synthesis model. We use Qwen3.5-4B [22] for CoT synthesis and evaluate Qwen3.5-4B and 9B students. Synthesis uses guidance weight , temperature , and Qwen3.8-27B for structured quality control, allowing at most eight generation attempts to complete reasoning at each recorded step.
Benchmarks. We report avg@3 and pass@3 on Terminal-Bench 1.0 and 2.1 (TB-1.0/2.1) [17], and success rates on GAIA [18], VITA-Cross [5], AutomationBench [26], and DeepPlanning [47]. Following konakona [11], Terminal-Bench uses six times the default agent time limits. To reduce ablation costs, TB-subset selects 50 TB-2.1 tasks whose time limits under this setting are at most 1.5 hours.
Gain recovery measures how much of the rollout performance gain from original-CoT training (Real) is recovered by synthetic CoT: , where is the evaluated score and references use the same model size. We take the arithmetic mean over all eight metrics in Table 1, including both avg@3 and pass@3 for TB-1.0 and TB-2.1. Recovery is 0% at or below Base and 100% when matching the corresponding Real reference.
| Method | TB-1.0 avg@3 | TB-1.0 pass@3 | TB-2.1 avg@3 | TB-2.1 pass@3 | GAIA | VITA-Cross | Automation Bench | Deep Planning | Gain recovery |
| References | |||||||||
| Qwen3.5-4B (Base) [22] | 28.75 | 41.25 | 18.35 | 31.46 | 44.85 | 10.00 | 19.71 | 21.25 | 0.00 |
| Qwen3.5-9B (Base) [22] | 35.00 | 47.50 | 22.10 | 34.83 | 49.30 | 14.50 | 28.65 | 21.46 | 0.00 |
| mask-CoT [50] | 10.00 | 16.30 | 19.48 | 33.71 | 43.64 | 10.25 | 21.15 | 24.59 | 12.59 |
| Real (4B) [50] | 36.67 | 48.75 | 28.46 | 40.44 | 47.88 | 18.50 | 27.61 | 28.96 | 100.00 |
| Real (9B) [50] | 40.00 | 51.25 | 34.08 | 50.56 | 53.33 | 21.50 | 41.46 | 27.71 | 100.00 |
| Experimental methods | |||||||||
| Trace Inversion [46] | 27.08 | 38.75 | 13.48 | 24.71 | 35.15 | 8.75 | 17.10 | 5.41 | 0.00 |
| RLT [1] | 22.92 | 37.50 | 10.48 | 15.73 | 30.30 | 4.50 | 8.61 | 13.33 | 0.00 |
| VR [49] | 25.83 | 37.50 | 13.10 | 26.96 | 33.93 | 9.50 | 18.86 | 5.83 | 0.00 |
| CoT-Factory-4B (Ours) | 34.58 | 45.00 | 26.96 | 40.44 | 43.03 | 19.00 | 27.23 | 23.96 | 68.12 |
| CoT-Factory-9B (Ours) | 38.33 | 50.00 | 30.71 | 48.31 | 45.42 | 20.25 | 36.46 | 26.46 | 64.24 |
Table 1. Downstream performance (%). References and experimental methods are separated; blue and orange name cells denote 4B and 9B models, respectively. Superscripts show percentage-point changes from the corresponding Base. Gain recovery summarizes the fraction of Real-over-Base improvement recovered averaged equally over all eight reported metrics.
Baselines. Base denotes the untuned model, while Real uses original-CoT supervision. mask-CoT retains original reasoning as context but supervises only action tokens. We reproduce Trace Inversion [46] and evaluate RLT [1] and VR [49] under the same SFT GPU-hour budget as our synthesis model. RLT additionally optimizes the synthesis teacher through RL using student target-action log-likelihood, while VR selects candidates by action likelihood. Trace Inversion and VR use the same eight-candidate budget per step for filtering and selection.
Quantitative Analysis
Preliminary no-CoT training, supervising actions with reasoning removed, yields only 3.33% TB-2.1 avg@3—an expected catastrophic collapse motivating reasoning supervision. We therefore omit other benchmarks for this setting. Retaining reasoning as context mitigates this collapse, but mask-CoT still lowers TB-1.0 avg@3 from 28.75% to 10.00% (Table 1).
The quality of reconstructed reasoning is equally consequential. Under the same synthesis budget, Trace Inversion’s lower acceptance rate leaves trajectories incompletely reconstructed (Table 2), and even training on its accepted CoT underperforms Base across all benchmarks. VR-style likelihood filtering likewise fails to improve downstream performance, suggesting that action likelihood alone is insufficient to identify useful reasoning supervision. For RLT, rewards increase during continued RL while reasoning entropy and instruction following deteriorate, leaving the student at only 10.48% avg@3 on TB-2.1.
| Method | Pass@1 | Pass@8 | GPU h |
| Forward | 40.74 | 73.73 | 1243 |
| Trace Inversion | 58.79 | 82.53 | 891 |
| RLT | 35.52 | 65.97 | 1391 |
| Tree-SFT | 69.54 | 88.18 | 697 |
| Tree-SFT + CFG | 89.36 | 99.84 | 623 |
Table 2. Candidate acceptance (%) and synthesis cost. GPU hours include failed candidates and retries.
In contrast, large-scale synthesis training and structured quality control produce useful reasoning supervision. CoT-Factory-4B improves TB-2.1 avg@3 by 8.61 points and matches Real’s 40.44% pass@3, while exceeding or approaching Real on VITA-Cross and AutomationBench, respectively. These gains extend to the 9B student, which also improves TB-2.1 avg@3 by 8.61 points and gains on both general-agent benchmarks. Across all eight metrics, mean gain recovery reaches 68.12% and 64.24% for the 4B and 9B students, demonstrating the value of synthesized reasoning at both model scales.
GAIA exhibits an unexpected decline at both scales. Inspection identifies an intrinsic bias in the synthesized data: under the GAIA harness, models can fail to submit a final answer. Addressing this mismatch between synthesized interaction patterns and benchmark-specific answer submission is a direction for future work.
Candidate Acceptance, Cost, and Component Ablations
We compare single-attempt acceptance (Pass@1), cumulative acceptance within eight attempts (Pass@8), and GPU hours required to complete the full dataset under the same quality criteria (Table 2). Costs include failed candidates and retries. VR is excluded because it is a posterior selection mechanism.
Forward rejection sampling must find matching actions in a large action space, achieving only 40.74% Pass@1 and leaving 26.27% of steps unresolved after eight attempts, at a cost of 1,243 GPU hours. RLT’s hallucinated reasoning lowers single-attempt acceptance to 35.52%, costing 1,391 GPU hours. Our synthesis model trained on 70k steps achieves 69.54% Pass@1 and reduces synthesis cost to 697 GPU hours. Adding action-conditioned CFG raises Pass@1 by almost 20 points to 89.36% and Pass@8 to 99.84%. The high acceptance rate reduces repeated failures enough to lower total GPU time further, even after accounting for CFG’s decoding overhead.
Robustness under long contexts. Figure 6(a) groups 6,619 validation steps by context length. Without CFG, Pass@1 falls from 85.4% for histories shorter than 16k tokens to 63.3% at 64–128k tokens as the action condition is diluted. CFG with improves all five length groups, including a 23.9-point gain at 64–128k tokens, and maintains similar acceptance across several groups. These results support
Figure 6. CFG, training efficiency, and student learning. (a) Candidate acceptance across context lengths. (b) Training cost across supervision scales. (c) Rolling mean student loss with local min–max bands.
stronger action conditioning and instruction following when reasoning is generated from long interaction histories.
Training scale and verification. Table 3 evaluates synthesis-training scale, verification, and action-conditioned CFG on TB-subset. The first two rows use the first format-valid candidate and compare 10k with 70k synthesis-training steps. Tree-SFT preserves the per-example training objective through shared-prefix computation; this comparison evaluates the larger training scale it enables, while its computational benefit is evaluated separately at matched training scales in § 4.4. Normal QC directly asks an LLM to assess free-form CoT, whereas Structured QC extracts and verifies reasoning units. These are alternative filters applied to the same 70k synthesis model; the final row adds CFG with guidance weight to Structured QC.
| Configuration | avg@3 | pass@3 |
| SFT-10k | 23.3 | 38.0 |
| + SFT-70k | 31.3 | 46.0 |
| + Normal QC | 30.6 | 46.0 |
| + Structured QC | 37.3 | 54.0 |
| + CFG | 38.0 | 58.0 |
Table 3. Training scale and verification ablations on TB-subset (%). Normal QC and Structured QC are alternative filters applied to the 70k synthesis model; CFG is added to Structured QC with guidance weight 2.
Scaling synthesis training from 10k to 70k steps raises downstream avg@3 from 23.3% to 31.3%. Normal QC provides no improvement, whereas Structured QC increases avg@3 to 37.3%, supporting the value of structured verification. Consistent with this difference, qualitative checks reveal that direct LLM evaluations of the same CoT alternate between acceptance and hallucination flags, making candidate selection unstable. Adding CFG primarily improves synthesis efficiency, as shown above, while maintaining comparable downstream performance at 38.0% avg@3.
Tree-SFT Efficiency
We compare independently expanded training with Tree-SFT on the training set of 1,341 long trajectories and 70,724 synthesis steps. Root-to-leaf paths reach 262,144 tokens; training runs for three epochs on 16 NVIDIA B200 GPUs. Accounting retains all 70,724 supervised leaves and includes repeated boundary prefixes required to split trajectories that exceed the maximum supported context length.
Independent expansion processes 4.576B tokens per epoch, whereas trunk reuse reduces this to 397.70M, an observed 11.51× compression. Over the full three-epoch training run, Tree-SFT requires 85.89 GPU hours, compared with 471 GPU hours for independent expansion without prefix sharing (Figure 6(b)). Across four supervision scales from 10k to 70k steps, the savings remain between 4.65× and 5.49×, substantially reducing the computational bottleneck in long-horizon inverse CoT synthesis.
Table 4 groups the trajectories by valid synthesis-step count, illustrating the reduction of historical redundancy from quadratic to linear growth. Longer trajectories contain more shared prefixes and benefit more from Tree-SFT. As trajectory length increases from 11–20 to over 60 steps, independently expanded token volume increases from 412.1K to 9.45M per trajectory, whereas Tree-SFT requires only 685.7K in the longest group. Compression rises from 4.65× to 13.77×, and the calibrated speed ratio increases from 2.22× to 6.57×. Trajectories longer than 20 steps constitute 92.3% of this TH-3k-derived set, highlighting the importance of Tree-SFT for reasoning synthesis models trained on long-horizon interaction trajectories.
| Steps | Linear | Tree | Comp. | Speedup | |
| 1–10 | 2 | 152.6K | 50.7K | 3.01× | 1.43× |
| 11–20 | 101 | 412.1K | 88.6K | 4.65× | 2.22× |
| 21–40 | 584 | 1.07M | 148.1K | 7.25× | 3.46× |
| 41–60 | 318 | 2.31M | 225.7K | 10.21× | 4.87× |
| > 60 | 336 | 9.45M | 685.7K | 13.77× | 6.57× |
| All | 1,341 | 3.41M | 296.6K | 11.51× | 5.49× |
Table 4. Tree-SFT efficiency. Linear and Tree give mean tokens per trajectory per epoch; compression is measured and speedup is calibrated from measured linear-baseline throughput at the corresponding trajectory lengths.
Student Loss and Sampling Temperature
Diversity collapse and temperature ablation. We observe that the diversity of synthesized CoT is closely related to student-loss dynamics and downstream generalization. Figure 6(c) compares students trained on Real CoT, CoT-Factory, and RLT data over approximately 2.4B tokens. RLT’s strong optimization toward single-step action likelihood is associated with diversity collapse: its initial loss is approximately 0.95, unusually below that of real data. We also investigate sampling temperature to assess reasoning diversity (Table 5). Under greedy decoding, resampling cannot escape deterministic local errors, and QC Pass@8 is only 67.3%. Higher temperatures progressively improve downstream performance. From onward, candidates at all tested temperatures largely pass quality control, yet increasing temperature yields 6.6 additional points on TB-subset avg@3. We interpret this as evidence that the synthesis model captures multiple valid reasoning paths: low temperatures concentrate on a few paths, whereas higher temperatures sample a broader range of correct explanations, providing richer supervision for complex trajectories, consistent with the value of diverse reasoning paths [33].
| Temperature | avg@3 | pass@3 | QC Pass@8 |
| 0.0 | 18.7 | 36.0 | 67.3 |
| 0.3 | 31.3 | 50.0 | 99.5 |
| 0.5 | 32.7 | 52.0 | 98.7 |
| 0.7 | 36.7 | 54.0 | 99.2 |
| 1.0 | 38.0 | 58.0 | 99.8 |
Table 5. Temperature ablation on TB-subset (%). CoT sampling temperature strongly affects downstream performance through reasoning diversity, while QC acceptance remains nearly unchanged except under greedy decoding.
Conclusion
We present CoT-Factory, a framework for recovering learnable reasoning supervision from long-horizon agent trajectories without environment replay. By combining Tree-SFT, structured quality control, and action-conditioned guidance, CoT-Factory enables efficient CoT synthesis model training and high-quality reasoning synthesis. On Terminal-Bench, VITA-Cross, and AutomationBench, the synthesized supervision recovers substantial gains from original CoT and outperforms the compared CoT synthesis methods across benchmarks. Component ablations and extended experiments across model scales further validate the effectiveness and feasibility of the framework. These findings provide a scalable route to converting existing action records into reasoning supervision, extending inverse CoT synthesis to long-horizon agent learning.
LLM Usage Statement
We used generative AI tools to assist with English translation, language polishing, and the presentation of figures and tables. This assistance included refining wording, improving clarity, and adjusting captions and layouts.
References
- [1]Edoardo Cetin, Tianyu Zhao, and Yujin Tang. Reinforcement Learning Teachers of Test Time Scaling. arXiv preprint arXiv:2506.08388, 2025. 2, 3, 6, 7arxiv.org/abs/2506.08388
- [2]Thibault Le Sellier De Chezelles, Maxime Gasse, Alexandre Drouin, et al. The BrowserGym Ecosystem for Web Agent Research. arXiv preprint arXiv:2412.05467, 2024. 1arxiv.org/abs/2412.05467
- [3]Xiang Deng, Yu Gu, Boyuan Zheng, et al. Mind2Web: Towards a Generalist Agent for the Web. arXiv preprint arXiv:2306.06070, 2023. 1, 2arxiv.org/abs/2306.06070
- [4]Alexandre Drouin, Maxime Gasse, Massimo Caccia, et al. WorkArena: How Capable Are Web Agents at Solving Common Knowledge Work Tasks? arXiv preprint arXiv:2403.07718, 2024. 1arxiv.org/abs/2403.07718
- [5]Wei He, Yueqing Sun, Hongyan Hao, et al. VitaBench: Benchmarking LLM Agents with Versatile Interactive Tasks in Real-world Applications. arXiv preprint arXiv:2509.26490, 2025. 6arxiv.org/abs/2509.26490
- [6]Yifei He, Pranit Chawla, Yaser Souri, et al. WebSTAR: Scalable Data Synthesis for Computer Use Agents with Step-Level Filtering. arXiv preprint arXiv:2512.10962, 2025. 2arxiv.org/abs/2512.10962
- [7]Jonathan Ho and Tim Salimans. Classifier-Free Diffusion Guidance. arXiv preprint arXiv:2207.12598, 2022. 5arxiv.org/abs/2207.12598
- [8]israellaguan. Codex Tool-Use Trajectories. Hugging Face dataset card, 2026. Community dataset; accessed November 12, 2026. 1
- [9]Carlos E. Jimenez, John Yang, Alexander Wettig, et al. SWE-bench: Can Language Models Resolve Real-World GitHub Issues? arXiv preprint arXiv:2310.06770, 2023. 1arxiv.org/abs/2310.06770
- [10]Jordan Juravsky, Bradley Brown, Ryan Ehrlich, et al. Hydragen: High-Throughput LLM Inference with Shared Prefixes. arXiv preprint arXiv:2402.05099, 2024. 4arxiv.org/abs/2402.05099
- [11]konakona. Qwen3.8-27B Terminal-Bench 2.1 Reproduction: Environment, Workflow, and Lessons. https://blog.konakona.dev/zh/posts/qwen3.8-terminal-bench-21-reproduction/, 2026. 6
- [12]Hanyu Lai, Xiao Liu, Yanxiao Zhao, et al. ComputerRL: Scaling End-to-End Online Reinforcement Learning for Computer Use Agents. arXiv preprint arXiv:2508.14040, 2025. 2arxiv.org/abs/2508.14040
- [13]Tamera Lanham, Anna Chen, Ansh Radhakrishnan, et al. Measuring Faithfulness in Chain-of-Thought Reasoning. arXiv preprint arXiv:2307.13702, 2023. 5arxiv.org/abs/2307.13702
- [14]Wei Li, William Bishop, Alice Li, et al. On the Effects of Data Scale on UI Control Agents. arXiv preprint arXiv:2406.03679, 2024. 2arxiv.org/abs/2406.03679
- [15]Hunter Lightman, Vineet Kosaraju, Yura Burda, et al. Let’s Verify Step by Step. arXiv preprint arXiv:2305.20050, 2023. 5arxiv.org/abs/2305.20050
- [16]Xing Han Lü, Zdeněk Kasner, and Siva Reddy. WebLINX: Real-World Website Navigation with Multi-Turn Dialogue. arXiv preprint arXiv:2402.05930, 2024. 1, 2
- [17]Mike A. Merrill, Alexander G. Shaw, Nicholas Carlini, et al. Terminal-Bench: Benchmarking Agents on Hard, Realistic Tasks in Command Line Interfaces. arXiv preprint arXiv:2601.11868, 2026. 1, 6arxiv.org/abs/2601.11868
- [18]Grégoire Mialon, Clémentine Fourrier, Craig Swift, Thomas Wolf, Yann LeCun, and Thomas Scialom. Gaia: a benchmark for general ai assistants. arXiv preprint arXiv:2311.12983, 2023. 6arxiv.org/abs/2311.12983
- [19]Niklas Muennighoff, Qian Liu, Armel Zebaze, et al. OctoPack: Instruction Tuning Code Large Language Models. arXiv preprint arXiv:2308.07124, 2023. 1, 2arxiv.org/abs/2308.07124
- [20]Jiayi Pan, Xingyao Wang, Graham Neubig, et al. Training Software Engineering Agents and Verifiers with SWE-Gym. arXiv preprint arXiv:2412.21139, 2024. 1, 2arxiv.org/abs/2412.21139
- [21]Yujia Qin, Shihao Liang, Yining Ye, et al. ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIs. arXiv preprint arXiv:2307.16789, 2023. 1arxiv.org/abs/2307.16789
- [22]Qwen Team. Qwen3.5: Towards Native Multimodal Agents, 2026. 6, 7
- [23]Christopher Rawles, Alice Li, Daniel Rodriguez, et al. Android in the Wild: A Large-Scale Dataset for Android Device Control. arXiv preprint arXiv:2307.10088, 2023. 2arxiv.org/abs/2307.10088
- [24]Guillaume Sanchez, Honglu Fan, Alexander Spangher, et al. Stay on topic with Classifier-Free Guidance. arXiv preprint arXiv:2306.17806, 2023. 5arxiv.org/abs/2306.17806
- [25]Timo Schick, Jane Dwivedi-Yu, Roberto Dessi, et al. Toolformer: Language Models Can Teach Themselves to Use Tools. arXiv preprint arXiv:2302.04761, 2023. 1arxiv.org/abs/2302.04761
- [26]Daniel Shepard and Robin Salimans. AutomationBench. arXiv preprint arXiv:2604.18934, 2026. 6arxiv.org/abs/2604.18934
- [27]Noah Shinn, Federico Cassano, Edward Berman, et al. Reflexion: Language Agents with Verbal Reinforcement Learning. arXiv preprint arXiv:2303.11366, 2023. 1arxiv.org/abs/2303.11366
- [28]Avi Singh, John D. Co-Reyes, Rishabh Agarwal, et al. Beyond Human Data: Scaling Self-Training for Problem-Solving with Language Models. arXiv preprint arXiv:2312.06585, 2023. 2arxiv.org/abs/2312.06585
- [29]Yifan Song, Weimin Xiong, Xiutian Zhao, et al. Agent-Bank: Towards Generalized LLM Agents via Fine-Tuning on 50000+ Interaction Trajectories. arXiv preprint arXiv:2410.07706, 2024. 1arxiv.org/abs/2410.07706
- [30]Qiushi Sun, Kanzhi Cheng, Zichen Ding, et al. OS-Genesis: Automating GUI Agent Trajectory Construction via Reverse Task Synthesis. arXiv preprint arXiv:2412.19723, 2024. 2arxiv.org/abs/2412.19723
- [31]Miles Turpin, Julian Michael, Ethan Perez, et al. Language Models Don’t Always Say What They Think: Unfaithful Explanations in Chain-of-Thought Prompting. arXiv preprint arXiv:2305.04388, 2023. 5arxiv.org/abs/2305.04388
- [32]Jinghui Wang, Shaojie Wang, Yinghan Cui, et al. Tree Training: Accelerating Agentic LLMs Training via Shared Prefix Reuse. arXiv preprint arXiv:2511.00413, 2025. 2, 4arxiv.org/abs/2511.00413
- [33]Xuezhi Wang, Jason Wei, Dale Schuurmans, et al. Self-Consistency Improves Chain of Thought Reasoning in Language Models. arXiv preprint arXiv:2203.11171, 2022. 8arxiv.org/abs/2203.11171
- [34]Xinyuan Wang, Bowen Wang, Dunjie Lu, et al. OpenCUA: Open Foundations for Computer-Use Agents. arXiv preprint arXiv:2508.09123, 2025. 2arxiv.org/abs/2508.09123
- [35]Jason Wei, Xuezhi Wang, Dale Schuurmans, et al. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. arXiv preprint arXiv:2201.11903, 2022. 1arxiv.org/abs/2201.11903
- [36]Zhiyong Wu, Zhenyu Wu, Fangzhi Xu, et al. OS-ATLAS: A Foundation Action Model for Generalist GUI Agents. arXiv preprint arXiv:2410.23218, 2024. 2arxiv.org/abs/2410.23218
- [37]Zhiheng Xi, Yiwen Ding, Wenxiang Chen, et al. Agent-Gym: Evolving Large Language Model-based Agents across Diverse Environments. arXiv preprint arXiv:2406.04151, 2024. 1arxiv.org/abs/2406.04151
- [38]Tianbao Xie, Danyang Zhang, Jixuan Chen, et al. OS-World: Benchmarking Multimodal Agents for Open-Ended Tasks in Real Computer Environments. arXiv preprint arXiv:2404.07972, 2024. 1arxiv.org/abs/2404.07972
- [39]John Yang, Kilian Lieret, Carlos E. Jimenez, et al. SWEs-mith: Scaling Data for Software Engineering Agents. arXiv preprint arXiv:2504.21798, 2025. 1, 2arxiv.org/abs/2504.21798
- [40]Songlin Yang, Jan Kautz, and Ali Hatamizadeh. Gated Delta Networks: Improving Mamba2 with Delta Rule. arXiv preprint arXiv:2412.06464, 2024. 4arxiv.org/abs/2412.06464
- [41]Shunyu Yao, Jeffrey Zhao, Dian Yu, et al. ReAct: Synergizing Reasoning and Acting in Language Models. arXiv preprint arXiv:2210.03629, 2022. 1arxiv.org/abs/2210.03629
- [42]Shunyu Yao, Dian Yu, Jeffrey Zhao, et al. Tree of Thoughts: Deliberate Problem Solving with Large Language Models. arXiv preprint arXiv:2305.10601, 2023. 5arxiv.org/abs/2305.10601
- [43]Eric Zelikman, Yuhuai Wu, Jesse Mu, et al. STaR: Bootstrapping Reasoning With Reasoning. arXiv preprint arXiv:2203.14465, 2022. 2arxiv.org/abs/2203.14465
- [44]Jianguo Zhang, Tian Lan, Rithesh Murthy, et al. AgentOhana: Design Unified Data and Training Pipeline for Effective Agent Learning. arXiv preprint arXiv:2402.15506, 2024. 2arxiv.org/abs/2402.15506
- [45]Jiarui Zhang, Yuchen Yang, Ran Yan, et al. AReaL-DTA: Dynamic Tree Attention for Efficient Reinforcement Learning of Large Language Models. arXiv preprint arXiv:2602.00482, 2026. 2, 4arxiv.org/abs/2602.00482
- [46]Tingwei Zhang, John X. Morris, and Vitaly Shmatikov. How to Steal Reasoning Without Reasoning Traces. arXiv preprint arXiv:2603.07267, 2026. 2, 6, 7arxiv.org/abs/2603.07267
- [47]Yinger Zhang, Shutong Jiang, Renhao Li, Jianhong Tu, Yang Su, Lianghao Deng, Xudong Guo, Chenxu Lv, and Junyang Lin. Deepplanning: Benchmarking long-horizon agentic planning with verifiable constraints. arXiv preprint arXiv:2601.18137, 2026. 6arxiv.org/abs/2601.18137
- [48]Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, et al. SGLang: Efficient Execution of Structured Language Model Programs. arXiv preprint arXiv:2312.07104, 2023. 4arxiv.org/abs/2312.07104
- [49]Xiangxin Zhou, Zichen Liu, Haonan Wang, et al. Variational Reasoning for Language Models. arXiv preprint arXiv:2509.22637, 2025. 2, 3, 6, 7arxiv.org/abs/2509.22637
- [50]Shun Zou, Ziyu Ma, Yi Zou, et al. Scaling Agentic Data for Long-Horizon Terminal Intelligence. arXiv preprint arXiv:2610.13166, 2026. 1, 2, 6, 7arxiv.org/abs/2610.13166
AI tools statement
This work lists 1 AI tool.
generative AI tools · AI tool
- Roles
- VisualizationWriting — review & editing
- Verification
- self-declared at submission
Recorded on the work at submission, not per version. Names and roles are shown as submitted; roles use the CRediT taxonomy.





