Teaching Thinking Models to Reason with Tools: A Full-Pipeline Recipe for Tool-Integrated Reasoning

Qianjia Cheng, Yuchen Zhang, Zhilin Wang, Yuxin Zuo, Shunkai Zhang, Yuchen Fan, Yu Qiao, Bowen Zhou, Ning Ding, Yu Cheng, Yun Luo, Ganqu CuiarXiv 2026

TL;DR

This paper introduces TRICE, a full-pipeline recipe for teaching large "thinking" models to naturally interleave natural-language reasoning with code execution (Tool-Integrated Reasoning). By carefully managing data curation, identifying an optimal "substance-focused" SFT checkpoint, and applying stable on-policy reinforcement learning, the authors achieve state-of-the-art math reasoning performance (e.g., 99.2% on AIME 2025) without degrading the models' native text-only capabilities.

What Problem Does This Paper Address?

Large language models with deep reasoning capabilities (like long Chain-of-Thought models) excel at complex tasks but struggle with precise numerical computation, symbolic manipulation, and systematic case enumeration. While giving these models access to a code executor (like a Python sandbox) seems like an obvious fix, naively doing so often breaks their internal reasoning logic.

Instead of seamlessly interleaving text and code, models either ignore the tool entirely or use it as a "final-pass verifier" at the very end of a flawed reasoning chain—a phenomenon known as the "delayed-code" pattern. This paper addresses how to successfully inject natural, multi-turn tool-use behavior into strong thinking models without causing catastrophic forgetting of their text-only reasoning skills.

Figure 1: The same problem, two policies for invoking the tool. Grey boxes denote text-only reasoning; In[k] cells indicate tool calls, and Out[k] cells represent tool responses. Left: Qwen3- 30B-Thinking-2507 treats the Python sandbox as a final-pass verifier. After a text-only Burnside derivation yields the inconsistent value 2420/32 = 75.625, it makes a single late-stage call that hard-codes the flawed assumptions (e.g. reflections_fixed = 16*C[8]). A silent integer floor masks the error, leading to the incorrect result 75 ✗. Right: TRICE-30B interleaves textual reasoning with code execution, feeding each intermediate result back into the same Burnside framework, and correctly obtains 88 ✓.

Methods

The authors propose a comprehensive pipeline spanning three main stages:

  1. Data Engineering: They select a teacher model (GPT-OSS-120B) that demonstrates a high-frequency, lightweight tool-use pattern (short, incremental code snippets) rather than a heavyweight, self-contained program style, finding the former much more learnable for student models. They filter for "tool-advantaged" problems and mix tool-use trajectories with text-only trajectories to preserve native reasoning capabilities.
  2. Stage Coordination: They discover that SFT training follows a distinct form-substance-noise progression. Instead of picking a checkpoint based on the lowest training loss, they use pass@k and response length to identify the exact moment the model has mastered the "substance" of tool use before it starts overfitting to teacher-side noise.
  3. Stable Reinforcement Learning: To prevent training collapse under sparse, outcome-based rewards, they implement a stable Reinforcement Learning with Verifiable Rewards (RLVR) stage using Group-Sorted Policy Optimization (GSPO). Crucially, they use fully on-policy updates and Rollout Routing Replay ($R^3$) to handle the off-policy nature of external tool returns.

Datasets

  • SFT Training: Curated from Nemotron-Math-v2 (~347K mathematical problems), filtered down to high-quality subsets (16K–32K trajectories) based on tool advantage and length constraints (<16K tokens).
  • RLVR Training: A newly constructed dataset of 4,325 challenging, IMO-level math QA examples designed to provide a strong functional incentive for tool invocation.
  • Evaluation Benchmarks: Evaluated on five competition-level math benchmarks: AIME 2025, HMMT 2025, BeyondAIME, IMOAnswerBench, and APEX 2025.
  • Generalization Benchmarks: FrontierScience (scientific computation), GPQA-Diamond (knowledge-intensive QA), and LiveCodeBench (coding).

Key Insights and Ideas

  • The "Delayed-Code" Trap: Naive models treat code executors as an afterthought rather than an active reasoning partner, often hard-coding flawed assumptions into a final verification step.
  • Form $\rightarrow$ Substance $\rightarrow$ Noise: During SFT, models first mimic the form of tool use (leading to inefficient loops and drops in accuracy), then internalize the substance (where accuracy peaks), and finally overfit to teacher noise (increasing train-inference mismatch).
Figure 2: TIR SFT dynamics of the 30B model. We perform SFT on Qwen3-30B-A3B-Thinking- 2507 using expert data generated by GPT-OSS-120B. The observed learning curve (measured on BeyondAIME) demonstrates a "form–substance–noise" progression.
  • Code as a Cognitive Tool: Analysis reveals that the code executor isn't just used as a calculator; in over 50% of solved cases, it is used for empirical discovery (pattern finding) and algorithmic search, which parameter scaling alone cannot replicate.

Key Results

  • State-of-the-Art Performance: The resulting models, TRICE-4B and TRICE-30B, achieve state-of-the-art performance among open-source models of similar scale. TRICE-30B achieved an outstanding 99.2% on AIME 2025 and 92.5% on HMMT 2025, outperforming significantly larger text-only models like DeepSeek-V3.2-Thinking.
  • Token Efficiency: TRICE consistently yields shorter overall responses than text-only baselines because code execution cleanly compresses lengthy manual arithmetic into concise snippets.
  • Cross-Domain Generalization: Despite being trained only on math, TRICE showed strong performance gains on non-math benchmarks, including a +14.5% boost on FrontierScience for the 4B model.

Limitations and Future Work

This work primarily focuses on competition-level mathematics where outcomes are easily verifiable. The authors note that broader agentic settings—such as software engineering workflows and web interactions—remain underexplored. Additionally, the study was limited to 4B and 30B model scales; scaling up to substantially larger models might introduce different training dynamics or stability issues that require further systematic study.

Summary updated

BibTeX
@misc{cheng2026teaching,
  author = {Qianjia Cheng and Yuchen Zhang and Zhilin Wang and Yuxin Zuo and Shunkai Zhang and Yuchen Fan and Yu Qiao and Bowen Zhou and Ning Ding and Yu Cheng and Yun Luo and Ganqu Cui},
  title = {{Teaching Thinking Models to Reason with Tools: A Full-Pipeline Recipe for Tool-Integrated Reasoning}},
  year = {2026},
  eprint = {2605.06326},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.06326},
}
Figure