[KongchangAI]
· 1 min read· 892 words

JET Fine-Tuning: Teaching Codebase Q&A Agents to Know When to Stop

JET Fine-Tuning: Teaching Codebase Q&A Agents to Know When to Stop

JET fine-tuning trains codebase Q&A agents to stop tool calls timely via trajectory truncation and rationale enhancement, reducing over-exploration.

This article introduces JET, a fine-tuning method addressing over-exploration in repository-level QA LLM agents. Over-exploration refers to agents continuing to call tools when information is already sufficient, increasing inference costs. JET truncates expert trajectories at the point of sufficient information, inserts text explaining stopping rationale with higher loss weights, training agents to stop timely. Experiments show JET reduces tool calls by 11%-33% while maintaining task scores, mitigating SFT's propagation of over-exploration behavior with generalization potential.

In repository-level question answering tasks, LLM-based agents need to call tools to explore code repositories and provide answers once sufficient information is gathered. However, a common problem persists: agents often continue calling tools even when information is already sufficient, causing unnecessary overhead. Recently, a paper titled "JET: Just-Enough Exploration Tuning for Efficient Tool-Calling Agents in Repository-Level Question Answering" proposed a fine-tuning method called "Just-Enough Exploration Tuning" (JET), aimed at training agents to learn "when to stop"—stopping exploration and answering questions promptly when information is sufficient.

JET paper source screenshot

Problem: Over-exploration

The paper points out that in repository-level QA, agents explore codebases through tools (such as code search, file reading, etc.). Ideally, once the collected information is sufficient to answer the question, the agent should stop calling tools and generate an answer. But in practice, LLM agents often continue calling tools after information is already sufficient—a phenomenon known as "over-exploration."

Over-exploration not only increases the number of tool calls but also extends reasoning time, leading to higher inference costs. More critically, while existing supervised fine-tuning (SFT) methods can improve task performance, SFT trained on expert trajectories also "infects" agents with the over-exploration behavior present in those trajectories, thereby exacerbating the problem.

Supervised fine-tuning (SFT) is a common method for training LLM agents, which uses maximum likelihood estimation on expert trajectories (i.e., correct action sequences generated by humans or strong models) to make models imitate expert behavior. However, expert trajectories themselves may contain redundant operations (such as repeated searches, unnecessary file reads), and SFT learns these inefficient behaviors as well, causing agents to over-explore during inference. Moreover, SFT's loss function treats every token in the trajectory equally, unable to distinguish critical decision points (such as when to stop) from ordinary operations, making it difficult to correct over-exploration. JET essentially introduces emphasis on key decisions within the SFT framework by truncating trajectories and inserting rationales with higher loss weights, thereby alleviating SFT's shortcomings.

JET Method: Truncation and Rationale Enhancement

To address over-exploration, JET's core idea is to teach agents "when to stop" during the training phase. Specifically, JET truncates each training trajectory: stopping at the step where information becomes sufficient, rather than letting the trajectory continue to its natural end. Then, JET inserts a "rationale" explaining why the information at that step is already sufficient to answer the question. During fine-tuning, JET assigns higher loss weights to this rationale, thereby reinforcing the agent's learning of "stopping conditions."

This approach differs from simple early-stopping strategies—through explicit rationale explanations, it lets the model understand the meaning of "sufficient" rather than merely truncating mechanically. JET's training process is still based on expert trajectories, but through truncation and rationale enhancement, it avoids propagating over-exploration behavior.

Loss weight is a coefficient that weights each token's loss value during training, used to emphasize certain key parts. In standard SFT, all tokens have the same loss weight; JET assigns higher weights to the inserted rationale portions, making the model focus more on these texts explaining "why to stop" during training, thereby reinforcing learning of stopping conditions. This weighting strategy belongs to cost-sensitive learning, guiding the model to prioritize learning important information by adjusting the loss function. Similarly, reinforcement learning also has methods that emphasize key behaviors through reward shaping, but JET achieves efficiency optimization solely through supervised signals without requiring environment interaction.

Experimental Results: Significant Reduction in Tool Calls

The paper conducted experiments on two repository-level QA benchmarks using two open-source 8-billion-parameter models. Results show that on self-generated trajectories, JET reduced tool calls by 11% to 33% while largely maintaining task scores. In comparison with SFT, JET achieved 18% to 28% fewer tool calls than SFT on expert trajectories while retaining most of SFT's score improvements. In both cases, JET reduced inference costs.

These results demonstrate that JET can effectively mitigate the over-exploration problem, improving efficiency with almost no performance loss. Particularly interesting is that JET's effectiveness in reducing tool calls is consistent across different models and benchmarks, showing its generalization ability.

Repository-level QA requires agents to understand the structure, dependencies, and logic of an entire codebase, rather than merely answering questions about a single file. Common benchmarks include RepoQA, CodeRepoQA, etc., which typically provide real code repositories and natural language questions, evaluating the agent's ability to locate relevant code and generate answers. Such tasks require multi-step tool calls (such as searching function definitions, examining call relationships, reading documentation), making exploration efficiency crucial. JET's experiments on these benchmarks show that reducing tool calls does not significantly affect answer quality, indicating that it is feasible for agents to stop when information is sufficient.

Implications and Outlook

JET's proposal provides new ideas for building more efficient codebase Q&A agents. While traditional SFT methods can improve performance, they inherit inefficient behaviors from data; JET actively corrects this bias through truncation and rationale enhancement. In the future, similar methods may be extended to other scenarios requiring multi-step tool calls, such as web navigation and API calling.

Furthermore, JET reminds us that when training agents, we should focus not only on the correctness of final answers but also on the efficiency of the reasoning process. As LLM agents are increasingly applied to complex tasks, how to make them "stop smartly" will become an important research direction.

Paper information: JET: Just-Enough Exploration Tuning for Efficient Tool-Calling Agents in Repository-Level Question Answering (Source: rss)

#JET fine-tuning#repository-level QA#tool-calling agents#over-exploration#supervised fine-tuning
Share:

Related articles