The CITA Framework: Teaching AI Tool Calls to "Think Before You Act"

CITA trains a comparative inference model to estimate the long-horizon value of tool calls before execution, solving the credit assignment problem under sparse rewards.
In long-horizon tool-use tasks, final-outcome rewards alone struggle to assign credit across individual steps, while obtaining step-level supervision is costly. CITA (Comparative Inference for Tool-use Agents) reframes this as a comparative supervision problem: a Comparative Inference Model (CIM) estimates the relative probability that each candidate tool call supports task success before execution. CIM fuses three complementary signals — observed tool behavior, counterfactual samples from a Bayesian tool-graph simulator, and LLM semantic judgments — consistently improving Tool F1 and task success rates across three benchmarks and multiple backbone LLMs.
The Core Challenge of Long-Horizon Tool Use
When large language models (LLMs) tackle complex tasks, they increasingly rely on chains of tool calls. Whether it's search, computation, or external API calls, each invocation changes the task's current state and directly shapes subsequent decision paths. This "long-horizon tool use" scenario exposes a problem that has long frustrated researchers: how to effectively evaluate the value of each step in the chain.
When a task requires dozens of tool calls to complete, the reward signal derived from the final outcome alone is far too sparse. This "result-oriented" feedback struggles to perform accurate credit assignment — when a task fails, the model can't pinpoint which specific call went wrong; when it succeeds, it's hard to identify which intermediate decisions were genuinely critical.

Credit Assignment is a classic challenge in reinforcement learning: when a sequence of multi-step decisions produces a final outcome, how do you attribute success or failure to any specific step? In long-horizon tool use, this is especially thorny. Suppose a task fails after 20 tool calls — the failure might stem from a wrong search strategy at step 3, or a malformed API parameter at step 17. With only a final failure signal, the model can't distinguish between these cases. Unlike supervised learning, where each sample has a clear label, the "label" here (the reward) appears only once at the end of the sequence and is highly sparse. Sparse rewards combined with long time horizons cause gradient-based optimization signals to decay sharply during backpropagation, making it extremely difficult for the model to extract meaningful learning signals.
Why Step-Level Rewards Are Hard to Obtain
An intuitive solution is to introduce step-level rewards — more targeted feedback for each individual tool call. But this path comes at a significant cost.
Obtaining reliable step-level supervision typically requires human annotation, LLM judgments, or additional rollouts to estimate how a given intermediate decision impacts downstream outcomes. These approaches are either expensive or difficult to scale. More critically, there's a structural information gap: truly valuable supervision must be comparative — it should contrast which of several candidate tool calls is better in the same context. Yet recorded historical trajectories only preserve the call that was actually made; the consequences of all other candidate options are entirely absent.
This means models trained on historical data learn "what was done" but not "why this was better."
CITA's Core Insight: Choice Before Action
The paper's central argument is quite illuminating: an effective tool-use agent should estimate the long-horizon value of a tool call before executing it. In other words, the agent needs the ability to "think before it acts" — to anticipate a move's contribution to ultimate task success before committing to it.
Building on this goal, the researchers propose CITA (Comparative Inference for Tool-use Agents). Its key innovation is training a Comparative Inference Model (CIM) specifically designed to estimate "how likely a given candidate tool call is to support final task success in the current context."
This design cleverly sidesteps the difficulty of absolute value estimation and instead focuses on relative comparison — which is precisely what decision-making fundamentally requires.
How Three Signal Sources Train the Comparative Model
CIM training relies on paired signals, combining three complementary sources of supervision:
Observed Tool Behavior
The first signal comes from real recorded tool call behavior. This data reflects actual decision patterns during execution and serves as the foundational anchor for learning.
Bayesian Tool-Graph Simulator
To compensate for the fact that historical trajectories contain only a single chosen option, CITA introduces a Bayesian tool-graph simulator that provides scalable supervision signals. By modeling the dependency relationships between tools, the simulator can generate large numbers of contrastive samples showing "what would happen under different choices," effectively filling the counterfactual information gap.
The Bayesian Tool Graph models the call-dependency relationships between tools as a directed probabilistic graph: nodes represent individual tools, and edges represent the conditional probability of "calling B after calling A." This structure naturally captures sequential constraints and mutual-exclusion relationships in tool chains — for instance, "database query" typically precedes "result filtering," while "web search" and "local file read" may be alternatives to each other in certain contexts. By performing probabilistic inference over this graph, the simulator can estimate — without actually executing anything — how the downstream success probability would change if step k used tool X instead of tool Y. This is the key mechanism for generating counterfactual contrastive samples: it scalably compensates for the fundamental limitation that historical trajectories contain only a single execution path, providing CIM with abundant comparative signals from "parallel worlds."
LLM Semantic Judgment
The third signal comes from LLM-based semantic comparative judgments. By leveraging a large model to assess the contextual plausibility of candidate calls, training gains a richer dimension of semantic understanding.
The combination of these three signals gives CIM grounding in real data, scalable counterfactual supervision, and semantic-level plausibility reasoning — all at once.
Experimental Results and Value Estimation Accuracy
The researchers validated CITA on three tool-use benchmarks across multiple backbone LLMs. Results show consistent improvements in both Tool F1 and task success rate. This stable, cross-benchmark, cross-model improvement suggests the method has strong generalizability — it's not a narrow trick tuned for specific scenarios.
Further analysis confirms that CIM genuinely learns accurate step-level value estimates for comparative tool selection. This is particularly important: it demonstrates that the model isn't simply fitting to final outcomes, but has truly learned the relative value of intermediate decisions.
Tool F1 is a standard metric for evaluating tool call quality, combining Precision (how many of the tools the model invoked were actually necessary) and Recall (how many of the tools the task required were successfully invoked by the model). This metric is more fine-grained than raw task success rate and better reflects the model's precision in tool selection — especially useful for identifying redundant or missed calls in long-horizon settings. Task success rate provides the end-to-end final verdict. Together, the two metrics validate improvements in both local decision quality and overall task completion, avoiding one-sided conclusions like "final success but an inefficient path" or "locally precise but combinatorially failed."
Implications for Agent Research
CITA's significance extends beyond metric gains — it reframes the optimization objective for tool-use agents. By establishing "choice before action" as a core principle and recasting the problem from hard-to-obtain absolute value supervision into more tractable comparative supervision, it opens a new technical pathway for long-horizon decision tasks.
As AI agents take on increasingly complex task orchestration, the ability to weigh the long-horizon consequences of different options before executing becomes a critical determinant of reliability. With a single comparative inference model, CITA offers a compelling answer to that challenge.
Related articles

Free Unlimited Claude Code Solution: Agnes AI + CC Switch Setup Guide
No paid subscription needed — pair the free AI platform Agnes AI with the open-source tool CC Switch to provide a backend for Claude Code, enabling unlimited free calls to text, image, and video models. This guide covers the full setup, test results, and usage boundaries.

A Complete Zero-Cost Guide to Getting Started with Claude Code for Beginners in China
A beginner's guide to Claude Code for users in China: two installation methods (command line and IDE plugin), full configuration steps for replacing the official API with the free domestic LongCat model, and a hands-on demo of building a small tool with natural language, plus tips.

When the NSA Gets Involved: The AI Supply Chain Crisis Behind Open-Source CVEs and API Key Hijacking
Multiple open-source projects disclosed severe CVEs in one day, PHP flaws alarmed the FBI, and Railway and OpenCode were breached with API keys stolen. This article breaks down the vulnerability window, AI-accelerated exploitation, and the AI supply chain crisis behind the API key black market, with a developer defense checklist.