Manuscript Offprint

arXiv:2610.24824

Teaching Code Agents to Ask Without Leaking Private Code

Wenjia Jiang, Jieke Shi, Zhensu Sun, Chengran Yang, Shidong Pan, Peixin Zhang, Yifan Jia, James Hoang, Xiwei Xu, Zhenchang Xing, David Lo, Zhou Yang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Wenjia Jiang1,2,3^{1,2,3}, Jieke Shi1^{1}, Zhensu Sun1^{1}, Chengran Yang1^{1}, Shidong Pan4,5^{4,5}, Peixin Zhang1^{1}, Yifan Jia6,7^{6,7}, James Hoang8^{8}, Xiwei Xu8^{8}, Zhenchang Xing8^{8}, David Lo1^{1}, Zhou Yang2,3,†,†^{2,3,\dagger,\dagger}

1^{1}Singapore Management University, 2^{2}University of Alberta, 3^{3}Alberta Machine Intelligence Institute (Amii), 4^{4}Columbia University, 5^{5}New York University, 6^{6}Singapore University of Technology and Design, 7^{7}AIDX TECH, 8^{8}Commonwealth Scientific and Industrial Research Organisation (CSIRO), †^{\dagger}Canada CIFAR AI Chair, †^{\dagger}Corresponding author

Local coding agents can extend their reach by consulting a stronger cloud model. Such consultations, however, often expose the repository’s private identifiers, file paths, and source code. Host-side masking hides recognized identifiers but leaves the surrounding code and the agent’s phrasing unchanged, while training for less disclosure risks suppressing consultation or producing questions too vague to answer. We propose utility-verified abstraction (UVA), which teaches the agent to describe private entities by their role and type while retaining the technical details an expert needs. From solved repair trajectories, we rewrite each question into this form and keep the rewrite only if it discloses fewer private entities and the repair, replayed from the same execution state with the rewrite, still succeeds. We fine-tune the agent on the verified questions and ordinary repair trajectories. Across two benchmarks, the trained agent consults more often than before training. On repository-level issue repair, it solves 37.6% of issues, against 25.3% for the same model working alone, a gain from the training as a whole rather than from consultation alone. Its questions disclose 3.7-fold fewer private entities and 1.4-fold less verbatim code than the untrained agent’s questions to the same expert.

zy25@ualberta.ca, wjjiang@smu.edu.sg

https://github.com/jwj1342/UVA

Date: October 20, 2026

Figure

1 Introduction

Large language models (LLMs) have demonstrated strong capabilities in code generation and program repair (Jiang et al., 2026; Zhang et al., 2024b). Coding agents, which integrate LLMs with development tools, can iteratively inspect files, modify code, and execute tests to produce a patch given an issue description and a repository (Jimenez et al., 2024; Yang et al., 2024a). Their growing capabilities have led to increasing adoption in real-world software development (Robbes et al., 2026). However, many coding agents rely on proprietary LLMs hosted by external providers, which raises privacy concerns when repository content is sent outside the organization. Running a smaller model locally can keep repository operations within the organization, but may limit the agent's ability to resolve complex issues. To address this trade-off, local execution can be combined with remote consultation. A small student model runs on the machine that holds the repository and

Wenjia Jiang et al.

ami

Figure

(a) Untrained agents

Figure

(b) Trained agents (ours)

Figure 1. One consultation, asked two ways. A local coding agent works through a repair and, at one step, consults a third-party cloud expert. (a) The untrained agent quotes three private identifiers of the repository in its question. (b) Our trained agent describes the same entities by role and type. The expert gives both the same advice and both repairs succeed, so the abstract question gets the same help while the identifiers stay on the device.

performs all editing and testing, while a larger expert model provides advice remotely without directly accessing the repository. Prior work has explored how to allocate computation across models through cascades and routing (Chen et al., 2024b; Ong et al., 2025), and SWE-Protégé shows that a local student can learn when to consult a stronger expert (Kon et al., 2026).

However, keeping repository operations local does not fully address these privacy concerns. The student may still include private identifiers, file paths, or source code in its consultations, making this information visible to the external provider. Existing approaches can limit such disclosure through prompt-based redaction and abstraction (Siyan et al., 2025; Dou et al., 2024), which instruct the model to remove or generalize private information before the question is sent to an external model. The student must nevertheless determine which details can be removed without obscuring the problem, and a privacy instruction alone provides no task-level feedback on whether the resulting question retains the information needed for useful advice. Such an instruction may also lower the consultation rate rather than improve the questions, in which case a reduction in total disclosure reflects silence rather than safer consultation. Alternatively, a host-side sanitizer can replace recognized private strings with placeholders before transmitting the question. This hides the identifiers that the sanitizer recognizes, but the surrounding source code is still transmitted. String replacement alone also does not check whether the sanitized question preserves the context the expert needs to give useful repair advice. The central challenge is therefore to reduce the private information disclosed in a consultation while preserving the technical content needed for useful advice. Removing too little leaves repository content exposed, while removing too much may omit the conditions that determine the correct repair. Training the student to make these choices requires examples of questions that satisfy both requirements. Whether a rewritten question remains useful, however, can be judged only after the expert has answered it and the student has completed the repair, so such examples cannot be labeled from the question text alone.

In this paper, we present utility-verified abstraction (UVA), a training procedure that teaches local coding agents to formulate useful questions with less private information. UVA constructs training examples from the consultations of successful repair trajectories, retaining an abstract rewrite of a question only if it discloses fewer private entities and the replayed repair still succeeds. An offline teacher rewrites each original question given its interaction history, describing private

Teaching Code Agents to Ask Without Leaking Private Code

ami

entities by their roles and types while preserving the symptom, the relevant technical constraints, and the decision on which advice is sought (Figure 1). Each rewrite then undergoes two checks. First, we count the private entities in the original and rewritten questions, namely the identifiers, file and module names, and paths that the student has read locally and that are not standard-library or public names. Second, we restore the repository snapshot and interaction history at the original consultation, obtain the expert's answer to the rewritten question, and resume the student's repair with that answer under the same remaining budget. A rewrite enters training only if it discloses strictly fewer private entities and the replayed repair passes the task's tests. We then use LoRA-based supervised fine-tuning to train the student to generate each accepted rewrite from its original interaction history, mixing these examples with full repair trajectories to help preserve its repair capability. At deployment, the student decides when to consult and generates its own questions, without the offline teacher or any host-side rewriting.

We conduct experiments on SWE-bench Verified and Terminal-Bench using Qwen3.5-9B (Qwen Team, 2026) as the student. With DeepSeek-V3.2 (DeepSeek-AI et al., 2025) as the expert for both UVA and the untrained consulting baseline, UVA improves pass@1 on SWE-bench Verified from 24.6% to 37.6%, while reducing mean disclosure per consultation from 4.42 to 1.20 private entities and from 8.4 to 5.9 verbatim source-code 5-grams. These reductions are not obtained by consulting less, as the consultation rate rises from 4.8% to 7.4%. The gain in solve rate is attributable to the training as a whole rather than to consultation alone, as the trained student reaches 36.2% without an expert. Compared with the host sanitizer, UVA achieves a higher solve rate (37.6% versus 25.0%), although its private-entity disclosure remains higher (1.20 versus 0.97). With Claude Opus 4.8 (Anthropic, 2026) as the expert, the trained student achieves 40.6% pass@1 on SWE-bench Verified and 43.8% accuracy on Terminal-Bench. In ablations with Claude Opus 4.8 as the expert, removing the repair replay lowers pass@1 from 40.6% to 22.4%, below the same model working alone. We also observe privacy by silence on SWE-bench Verified, where a privacy prompt reduces the consultation rate without reducing mean disclosure per consultation. This finding indicates that evaluations of private consultation should report the consultation rate together with the disclosure per consultation. Our privacy claims concern literal disclosure and do not establish protection against information inferred from the transmitted content.

Our contributions are summarized as follows:

  • We propose UVA, a training procedure that builds supervision for consulting a cloud expert with less private information, keeping only role-and-type rewrites that pass a disclosure check and a repair replay.

• We identify privacy by silence on SWE-bench Verified, showing that a lower consultation rate can accompany an apparent privacy improvement without lower mean disclosure per consultation.

• We evaluate UVA on two benchmarks against no consultation, unrestricted consultation, a privacy prompt, and a deterministic host sanitizer, and release the source code.

References (98)