Function-Aware Fill-in-the-Middle as Mid-Training for Coding Agent Foundation Models

Yubo Wang, Jiarong Liang, Yuxuan Zhang, Xuye Liu, Cong Wei, Yuyu Zhang, Ping Nie, Wenhu Chen

arXiv:2607.12463 · 2026-07-16 공개 · arXiv · PDF

code-generation self-supervised-learning swe-bench coding-agents mid-training inductive-bias tool-use-benchmarks function-aware-fim

Abstract

Coding agents must integrate external tool returns into ongoing reasoning - a capability that standard left-to-right pretraining on code exposes only in its forward direction. We observe that the action-observation-continuation loop of a coding agent is structurally isomorphic to a function call site, where a caller binds arguments, a callee returns a value computed elsewhere, and downstream code consumes that value. This conditioning structure exists at internet scale in ordinary code. We exploit it through function-aware fill-in-the-middle (FIM) mid-training: a self-supervised objective that masks functions selected via program dependency graph analysis and a complexity-inferability double criterion. We mid-train Qwen2.5-Coder-Instruct (7B/14B) and Qwen3-8B on a 2.6B-token decontaminated corpus drawn from 968 GitHub repositories, then apply existing agentic post-training pipelines. Mid-training improves SWE-Bench-Verified by +2.8/+3.0 at 7B/14B and by +3.2 on Qwen3-8B; SWE-Bench-Lite gains are +3.7/+4.0/+5.4 on the same models. The improvement holds across two post-training pipelines (R2E-Gym, SWE-Smith) and on a non-Qwen2.5 base (Qwen3-8B with SWE-Lego). Beyond in-domain gains, mid-training also mitigates the capability erosion that agentic post-training otherwise inflicts on non-agent coding (e.g., LiveCodeBench) and non-coding tool-use benchmarks (tau-bench, BFCL): although the mid-training corpus contains Python code only, the function-call inductive bias survives post-training and yields consistent gains.

한국어 요약

한 줄 요약

코딩 에이전트의 기능 인식 능력을 향상시키기 위해 함수 기반 FIM 중간 훈련을 제안하며, SWE-Bench-Verified에서 +3.2%p 개선을 달성.

핵심 기여도

핵심 아이디어

기존의 왼쪽에서 오른쪽으로 훈련된 코드 모델은 함수 호출 구조를 학습하지 못해, 에이전트가 외부 도구의 결과를 추론에 통합하는 능력이 제한된다. 본 연구는 **action → observation → continuation** 루프가 **caller → callee → downstream code** 구조와 구조적으로 동일하다는 점을 발견하고, 이를 기반으로 **function-aware FIM**을 도입한다. 이는 **self-supervised** 방식으로, **PDG 분석**과 **complexity–inferability** 기준을 사용해 함수 단위로 마스킹 대상을 선택한다. 또한, **chain-of-thought (CoT)** 추론을 FIM 중간 구간에 내장하여, 에이전트의 추론 패턴과 일치하는 학습을 유도한다.

기술적 접근법

주요 결과

의의 및 한계

실용적 활용