TL;DR
Current tool-integrated large language models (LLMs) execute code blocks immediately upon generation, which often breaks their chain of thought and limits reasoning flexibility. This paper introduces IH-GRPO, a reinforcement learning approach that decouples tool invocation from execution, allowing the model to autonomously decide exactly when to run its code. By mathematically mimicking an explicit hierarchical controller using a novel surrogate loss, it achieves significant reasoning gains across multiple math benchmarks without adding any architectural or inference overhead.
What Problem Does This Paper Address?
In tool-integrated reasoning (TIR), LLMs write and execute code (typically Python) to solve complex mathematical problems. However, standard frameworks rely on "coupled tool invocation" or eager execution: the moment a code block is detected in the model's output, the environment immediately runs it and feeds the result back to the model.
The authors identify two major flaws with this rigid approach:
- Disrupted Coherence: Eager execution can prematurely interrupt the model's internal deliberation. For instance, if a model is simply defining an intermediate helper function or variable, executing it immediately yields an empty or irrelevant output (e.g.,
None), which can confuse the model and cause it to hallucinate or terminate early. - Rigid Reasoning Patterns: Tightly coupling generation with execution forces each code block to be a self-contained, fully executable unit. This prevents the model from flexibly interleaving textual reasoning across multiple partial code fragments before demanding external feedback.
To solve this, the paper formalizes the problem of decoupling tool invocation from execution, giving the model the strategic flexibility to delay execution until a critical reasoning juncture is reached.
Methods
The authors introduce a Hierarchical Control Framework where a high-level policy decides whether to continue reasoning (C) or execute the accumulated code (E), while a low-level policy handles token-level text and code generation.
To avoid the massive training and inference overhead of running two separate explicit models (a controller and a generator), the authors propose an Implicit Hierarchical Policy. In a standard autoregressive language model, the tool-execution token (e.g., <tool_call>) is treated just like any other token, naturally forming an implicit hierarchy.
The core mathematical contribution is the derivation of a Surrogate Loss ($L'_I$). Through policy-gradient analysis, the authors prove that optimizing a single autoregressive model with this specific surrogate loss function yields the exact same parameter updates and probability distributions as an explicit, dual-policy hierarchical system. This theoretical breakthrough allows the model to learn endogenous hierarchical control purely through an objective-level correction.
This correction term is integrated into Group Relative Policy Optimization (GRPO), creating the IH-GRPO algorithm.
Datasets
- Training: The models were trained on a mixture of mathematical datasets, specifically Math3-5 (from SimpleRL) and Deepscaler, using a sandboxed Jupyter runtime that preserves intermediate states across multi-turn interactions.
- Evaluation:
- Out-of-Domain Math Benchmarks: MATH500, AIME24, AIME25, AMC23, Hmmt Feb 25, and Olympiad.
- General Out-of-Domain Benchmarks: MMLU-Pro, LogiQA, and three reasoning tasks from BIG-Bench Hard (Date Understanding, Formal Fallacies, and Logical Deduction).
Key Insights and Ideas
- Eager Execution is a Cognitive Trap: Forcing a model to receive feedback immediately after writing any code block often causes it to trip over its own feet. Decoupling allows the model to "verify and reflect" on its code before committing to execution.
- Hierarchy Without the Overhead: Instead of deploying external controller models or complex, hand-crafted prompt workflows—which often hurt reasoning continuity and scalability—IH-GRPO achieves structural planning entirely through a modified loss function.
- A Shift in Tool-Use Behavior: Statistical analysis revealed that when models are freed from eager execution, their tool-use patterns shift. Instead of using code merely at the very end of a prompt for "redundant verification," they naturally interleave code to handle substantive, intermediate computational steps.
Key Results
- Significant Accuracy Gains: IH-GRPO achieved absolute accuracy improvements of 1.87% on Qwen3-1.7B, 2.16% on Qwen3-4B, and 2.53% on Qwen3-8B across six out-of-domain mathematical benchmarks compared to the strongest baseline (SimpleTIR).
- Enhanced Inference Coherence: In coupled settings, unexpected external returns interrupted and corrupted the model's reasoning path 4.98% of the time. With IH-GRPO's delayed execution, this interruption rate plummeted to just 0.68%.
- Preserved General Capabilities: Unlike many specialized reinforcement learning methods that suffer from alignment tax or performance degradation in non-target domains, IH-GRPO consistently improved performance on non-math out-of-domain tasks like LogiQA and MMLU-Pro.
Limitations and Future Work
- Scale Constraints: Due to computational limits, the authors only evaluated relatively small-scale models ranging from 1.7B to 8B parameters. Validating IH-GRPO on larger frontier models remains an open task.
- Single-Tool Focus: The experimental validation was strictly confined to Python code tools for mathematical reasoning. While the authors note that the framework could theoretically generalize to multi-tool environments (e.g., where the output of one tool serves directly as the input to another without immediate execution), this was not explicitly implemented or tested.
Summary updated