Why step-by-step tool calling is killing your agent's context window—and how a new paper from Shanghai Jiao Tong University fixes it.


The Problem Every Agent Developer Has Felt

You're building an LLM agent that uses tools. It needs to answer: "What's the distance between Tokyo and São Paulo?"

Simple enough. But under the hood, the agent has to:

  1. Call a geocoding tool for Tokyo → get coordinates, push them into the context
  2. Call a geocoding tool for São Paulo → get coordinates, push them into the context
  3. Call a distance calculator with both coordinate pairs → get the result

Three round-trips through the model. Three observations bloating the context. Three times the model has to re-engage its decision loop just to shuttle data between tools that could have been composed locally. The actual reasoning—"what does the user need?"—is two sentences. The intermediate coordinates? Noise. The model never needed to reason about them.

Now scale this up. A real-world agent working with dozens of tools across a complex task might accumulate hundreds of these atomic transitions. Each one costs a model forward pass, adds tokens to the context, and forces the model to manage low-level dataflow that should be invisible to it.

This is the execution-granularity mismatch: task-level operations are chains of low-level tool calls, but the agent's reasoning only cares about the composed result. The interface forces the model to micromanage what should be automated.

A new paper from Shanghai Jiao Tong University—"HyperTool: Beyond Step-Wise Tool Calls for Tool-Augmented Agents" (arXiv 2606.13663)—proposes a clean solution: let the model batch multiple tool invocations into a single executable code block, folding deterministic subroutines into one "hyper" call that returns only the task-relevant result to the main reasoning trace.


What HyperTool Actually Is

HyperTool introduces a new MCP-compatible tool interface. Instead of calling tools one at a time:

Call(geocode, {location: "Tokyo"})    → observation₁
Call(geocode, {location: "São Paulo"}) → observation₂
Call(haversine, {lat1: ..., lon1: ..., lat2: ..., lon2: ...}) → observation₃

The model writes a single code block:

# HyperTool block
tokyo_coords = call(geocode, location="Tokyo")
sp_coords = call(geocode, location="São Paulo")
result = call(haversine,
              lat1=tokyo_coords.lat,
              lon1=tokyo_coords.lon,
              lat2=sp_coords.lat,
              lon2=sp_coords.lon)

The HyperTool runtime executes this entire block. The model sees only the final observation—the distance in kilometers—returned to the main reasoning trace. No coordinate sprawl. No three round-trips. No context window pollution.

The key insight: HyperTool doesn't replace the existing MCP tool schema. It's exposed as an MCP tool itself. The model calls hypertool with a code block, and inside that block, existing tools are invoked through their original schemas. It's additive, not revolutionary—a wrapper pattern that changes the unit of execution without changing how tools are specified.

Inside a block, the model can:

  • Call existing tools through their original schemas
  • Store returned values as local variables and pass them between calls
  • Parse, filter, and transform intermediate observations
  • Perform lightweight computation (arithmetic, string manipulation)
  • Define temporary helper functions for reuse within the block

If a block contains just one tool call, HyperTool degrades gracefully to the standard atomic interface. Backwards compatible by design.


Why This Matters: Two Deep Problems, One Fix

Problem 1: Context Inflation

Every tool observation in a step-wise agent gets appended to the context window. Multi-step tasks with rich tool responses (API payloads, search results, database records) can easily consume 10,000+ tokens of context on intermediate data that the model only needs one or two fields from. This isn't just inefficient—it's a hard constraint that limits task horizon. Agents working on long workflows eventually exhaust their context and lose track of what they were doing.

HyperTool solves this at the source: only the block-level result enters the main trace. Intermediate observations stay inside the block's local scope and are discarded after execution. The context window sees the answer, not the work.

Problem 2: Reasoning Fragmentation

Step-wise calling forces the model to interleave high-level task reasoning with low-level procedural state transfer. Each time the model returns to the decision loop, it has to re-orient: "What was I doing? Oh right, I just got Tokyo's coordinates, now I need São Paulo's, then I need to call the distance function..." This isn't reasoning—it's bookkeeping. And it's bookkeeping that's fundamentally unnecessary when the intermediate steps are deterministic.

The paper formalizes this as a granularity mismatch: the natural unit of the task ("find the distance") doesn't match the unit of execution ("call geocode → call geocode → call haversine"). HyperTool aligns them. The model reasons at task granularity and delegates procedural execution to the block.


The Training Pipeline: Teaching Models to Compose

Defining the interface is only half the battle. The model needs to learn when to invoke a block, how to compose tools inside it, and when to return intermediate observations to the main trace (not everything should be hidden—some intermediate results are needed for reasoning).

The authors build a supervised fine-tuning pipeline:

  1. Synthesize cross-tool compositional tasks — Tasks that naturally require chaining multiple tools together.
  2. Roll out HyperTool-format trajectories in real MCP environments — The model generates candidate blocks, which are executed and validated.
  3. Local repair — During rollout, if a block fails partway through, the system can repair it locally (fix a parameter, retry) rather than restarting.
  4. Trajectory-level context compression — Compress the successful trajectory into a training example.
  5. Verify for execution correctness and evidence consistency — Only keep trajectories where the block actually executed correctly and the evidence supports the answer.

This is clever: the training data isn't just "here's a correct block." It's verified blocks that actually ran in real MCP environments. The model learns from executable, not hypothetical, tool compositions.


Results: From 10% to 33% on MCP-Universe

The evaluation is on MCP-Universe, a benchmark for tool-use agents. The numbers are striking:

Model Baseline + HyperTool Gain
Qwen3-8B 9.93% 33.33% +23.4pp
Qwen3-32B 15.69% 35.29% +19.6pp

The Qwen3-32B HyperTool model surpasses GPT-OSS and Kimi-k2.5 on average accuracy—models far larger and more expensive. A 32B parameter model with HyperTool beats proprietary frontiers on multi-step tool use. That's a statement.

The gains are consistent across task categories: single-tool, intra-domain multi-tool, and cross-domain multi-tool. The biggest improvements come on cross-domain multi-tool tasks, which are exactly the tasks where step-wise calling generates the most context noise and reasoning fragmentation.

Importantly, the authors show this isn't just about smaller context windows. Even when context isn't exhausted, the model's reasoning benefits from not having to manage low-level dataflow. The accuracy gains come from both efficiency (less context used) and effectiveness (better reasoning when the trace is clean).


How This Differs From Prior Work

The paper positions HyperTool against three existing approaches:

Trace-level compression (pruning, summarization, memory modules) reduces context after step-wise execution has already polluted the trace. You're compressing noise that shouldn't have been there. HyperTool prevents the noise from entering in the first place.

Subagent delegation hides execution from the main context, but at the cost of transparency—you can't inspect or recover from intermediate failures. HyperTool keeps execution visible as a block while hiding unnecessary internals.

Program-based agents (CodeAsPolicies, Voyager, etc.) use code as a general action language. HyperTool is more constrained: it wraps existing MCP tools rather than replacing them. The code inside the block calls tools through their schemas—it's not arbitrary code execution, it's structured composition.

The distinction matters: HyperTool is composable with existing tool ecosystems. You don't rewrite your tools. You add one meta-tool.


Practical Takeaways for Agent Builders

1. Batch deterministic workflows

Any sequence of tool calls where the model doesn't need to reason about intermediate results is a candidate for batching. Geocoding + distance, search + extraction, API calls + filtering—these are the patterns where HyperTool shines.

2. Keep reasoning-relevant steps visible

Not everything should go in a block. If the model needs to decide based on an intermediate result (e.g., "if the search returned no results, try a different query"), that decision point should stay in the main trace. HyperTool is for deterministic subroutines.

3. The interface pattern is implementable today

HyperTool is essentially a code-execution tool that has access to other tools. If you're building an agent framework, you can prototype this pattern without waiting for a paper implementation. Define a hyper_tool that accepts a code block, execute it in a sandboxed runtime with tool access, and return only the final result to the main context.

4. Fine-tuning matters more than the interface alone

The paper shows that just adding the interface isn't enough—you need training data that teaches the model when and how to compose blocks. The verified trajectory synthesis pipeline is as important as the interface design. If you're deploying this pattern, invest in the training data.

5. Context efficiency compounds

For long workflows, the context savings from batching deterministic subroutines compound. Each block that hides 3–5 intermediate observations saves not just those tokens but the attention overhead the model would spend processing them. On tasks requiring 20+ tool calls, the difference between step-wise and batched execution could be the difference between completing the task and running out of context.

6. MCP compatibility is a feature, not a limitation

Because HyperTool is itself an MCP tool, it slots into existing tool servers and agent frameworks without architectural changes. You don't need a new runtime, a new protocol, or a new tool format. You need one additional tool in your tool list.


Limitations and Open Questions

The paper is honest about what HyperTool doesn't solve:

  • Error handling within blocks is still being explored. If a tool call fails mid-block, how should the model recover? The local repair mechanism in training helps, but runtime error recovery in blocks is a hard problem.
  • When to batch vs. when to stay atomic is learned through fine-tuning, not specified by a rule. This means the model can misjudge—batching when it should stay atomic (hiding a result it later needs to reason about) or staying atomic when it should batch (wasting context on intermediate noise).
  • Safety and sandboxing of the code blocks is acknowledged but not deeply explored. Allowing models to write executable code that calls real tools requires careful sandboxing, especially in production deployments.
  • The evaluation is on Qwen3 models only. Whether the gains generalize to other architectures (Llama, Mistral, proprietary models) remains to be seen. The pattern should transfer—the interface is model-agnostic—but the training pipeline may need adaptation.

The Bigger Picture: Execution Granularity as a First-Class Design Choice

HyperTool's deepest contribution isn't the code-block interface. It's the recognition that execution granularity is a first-class design choice for agent systems.

Today, almost every agent framework defaults to the finest granularity possible: one tool call per model turn. This is the simplest interface, and it's general—you can express anything with enough turns. But it's also wasteful. It forces models to manage dataflow that should be local, bloats context with intermediate observations, and fragments reasoning across unnecessary decision points.

HyperTool proposes a different default: let the model choose the granularity. Simple calls stay atomic. Composed operations batch into blocks. The interface is unified—you don't need two different calling conventions, just one tool that can do both.

This is the direction agent architectures should be moving. As tool ecosystems grow (MCP servers are proliferating fast), the gap between task-level operations and atomic tool calls will only widen. The model that can compose tools flexibly—batching when it makes sense, staying atomic when it doesn't—will outperform the model stuck in step-wise mode on every real-world task.

The paper proves the point with numbers: a 32B model with HyperTool beats frontier-scale models on tool-use benchmarks. That's not a small result. That's a design principle with empirical backing.


Bottom Line

HyperTool is the most practical advance in tool-calling architecture since MCP itself. It doesn't require new protocols or new tool formats. It requires one addition—code-block composition—and the training data to teach models when and how to use it. The results speak: 3–4x accuracy improvements on multi-step tool use, competitive with models far larger, achieved by simply changing the granularity at which tools are invoked.

If you're designing agent tool-calling schemas, read this paper. The pattern is implementable today, composable with existing ecosystems, and the efficiency gains are real.

Paper: arXiv 2606.13663 — "HyperTool: Beyond Step-Wise Tool Calls for Tool-Augmented Agents"

Authors: Yaxin Du, Yifan Zhou, Yujie Ge, Jiajun Wang, Xianghe Pang, Shuo Tang, Tuney Zheng, Bryan Dai, Jian Yang, Siheng Chen (Shanghai Jiao Tong University, IQuest Research, BUAA)

Date: June 2026