2026-07-10 · 11 min · llm · agents · reinforcement-learning · code-generation · explainer
A "coding model" usually means a next-token predictor you paste a function stub into. KAT-Coder-V2.5, from the Kwaipilot / Kuaishou team, is trained for a different job: to act — to open a real repository, run its tests, read the failures, edit files, and iterate until the tests pass, across dozens of turns. Once that's the target, the model stops being the hard part. The hard part is manufacturing enough precisely specified, executable, objectively verifiable tasks to train on, and building an RL loop that survives long, sparse-reward trajectories. This report is mostly about that manufacturing stack. It pairs with our pieces on agent harnesses and on near-frontier code RL; KAT-Coder is a full-stack answer to the same question those raise.
The one idea to leave with: an autonomous coding agent is an environment-and-data problem before it is a modeling problem. Everything below — AutoBuilder, the data flywheel, harness randomization, the asymmetric critic, multi-teacher distillation — exists to feed a policy verifiable practice inside realistic scaffolds, without letting it overfit any single one.

AutoBuilder: turning real repos into verifiable sandboxes
The raw material is public repositories, but an issue title and a merged PR are not a task. Two problems have to be solved. First, task mining: raw issue/PR text is ambiguous and often misaligned with what actually got merged, so AutoBuilder regenerates a structured spec from the golden patch and test patch — a problem statement (from the golden patch), requirements (from the test patch), and interface constraints (from both) — then runs a clarity check to ensure it's self-contained.
Second, environment construction: a build agent writes a configuration script and a separate verification agent runs it in an isolated sandbox, accepting the environment only when it can collect >90% of the expected tests with reproducible fail-to-pass and pass-to-pass outcomes (exit codes and log-scraping are explicitly rejected as too easy to fool). Combining base images, language templates, and retrievable build recipes, this reaches a 57.2% environment-construction success rate (up from a 16.5% starting point) and yields >100,000 verifiable environments across 12 languages. That corpus of executable tasks is the substrate everything else trains on.
The data flywheel: recovering near-misses without leaking hints
Verifiable environments are necessary but not sufficient: on genuinely hard tasks the model's raw pass rate is near zero, so rollouts produce no learning signal. KAT-Coder's answer is a two-stage recovery loop. First, inject process-level hints to lift near-misses over the line, raising the pass rate from ~0% to ~20%. But a trajectory that only succeeds because it was handed a hint teaches the model to expect hints it won't have at deployment — so the second stage replays the same tasks hint-free and keeps only the trajectories that still recover. The final data carries no hint leakage and stays faithful to the original distribution. Drag the hint strength and step the stages:
Stage 1, the raw rollout, has essentially no passing trajectories — a dead gradient. Stage 2 injects process-level hints that recover near-misses, lifting the pass rate from ~0% to about 20%. But hint-conditioned trajectories would teach the model to expect hints it will never get at test time, so stage 3 replays the same tasks hint-free and keeps only the ones that still recover (the crossed-out cells are hint-dependent and discarded — no leakage). Stage 4’s process-score filter then drops exploitative or unstable trajectories. What survives is a small set of verified patches that look like ordinary, hint-free work.
What survives then passes a process-score filter that scores each trajectory on exploration, localization, pre-edit reasoning, specification fidelity, repository conventions, patch minimality, verification quality, recovery, and honesty — down-weighting exploitative or unstable behavior even when the tests happen to pass. A parallel harness-robustness step randomizes tool names, argument conventions, and output formats and injects realistic perturbations (missing dependencies, transient failures, truncated outputs, noisy logs), so trajectories don't encode a single scaffold's quirks.
KwaiClawEnv: general agentic tool use
Repository work isn't the only skill. KwaiClawEnv is a three-layer pipeline that manufactures general tool-use trajectories: a Service layer builds callable capabilities from human-authored Skills and LLM-generated Services (>90% generation success from open-source community Skills), a Task layer expands real task seeds into variants with configurable difficulty and tool-chain length, and an Eval layer converts rollouts into SFT-ready samples and feeds quality signals back upstream. It yields >100,000 high-quality instances with an average of 15 tool calls per task and the longest exceeding 100 steps — genuinely long-horizon agentic data, validated through a three-stage checker (service reachability, task-schema legality, sandboxed execution) and two-layer filtering (hard rules plus LLM-as-judge).
Reinforcement learning, hardened for long horizons
Harness randomization
An agentic policy trained inside one fixed scaffold overfits the surface of that scaffold, not the task. The report names three failure modes: format overfitting (anchoring to one action format, so parsing breaks when the protocol changes), context-structure overfitting (depending on how history is concatenated), and control-flow overfitting (relying on a fixed reflection/stop schedule). The fix is to train across many harnesses that vary along three axes — tool-invocation protocol, context management, and control flow — spanning white-box harnesses (like mini-swe-agent: simple, uncompressed, clean signal) and black-box production harnesses (Claude Code, Codex, OpenClaw, OpenHands: with compression and context reorganization). Flip the axes and watch the rendered action change while the task — and its reward — stay put:
{ "name": "edit_file",
"args": { "path": "app.py" } }full history · ReAct
white-box (clean signal)
A policy trained inside one scaffold learns that scaffold: parsing breaks the moment the action format changes, behavior depends on how history was concatenated, reflection fires on a fixed schedule. By randomizing the protocol, context strategy, and control flow, KAT-Coder forces the model to solve the underlying task — the reward is tied to the outcome, identical across all 18 surfaces. white-box harnesses (simple, uncompressed) give clean training signals; black-box harnesses (Claude Code, Codex, OpenHands…) add the compression and reorganization of real deployments.
Underneath, the sandbox itself had to be hardened: container-image and environment-variable bugs meant ~16% of trajectories initially failed for reasons unrelated to the model. Fixing disk pressure (95% → 60% usage) and timeouts drove sandbox-related failures to below 2%, and invalid-rollout rates from 6–7% to under 1%.
Asymmetric PPO with a hindsight critic
Long-horizon tasks are sparse-reward: the signal lands only at the end, when the tests pass or fail. That makes the critic's job — estimating the value of an intermediate state — brutally high-variance, and a noisy value function means a noisy advantage, which destabilizes training. KAT-Coder's move is an asymmetric actor–critic: the actor sees only the normal harness state (so it behaves identically in training and deployment), while the critic is given a privileged hindsight context — the eventual reward, test outcomes, coverage signals, patch-level diffs, trajectory statistics, and subsequent turns. Scrub the turn and toggle hindsight to see the value estimate tighten:
The actor only ever reads the visible state sₜ, so it behaves identically in training and deployment. The critic is fed a privileged hindsight context cₜ — the eventual reward, test outcomes, coverage, patch diffs, and later turns — which flows backward in time (dashed arrows) and never touches the actor. Turn hindsight off and the value estimate has to be guessed from the present: its uncertainty band balloons early in the trajectory, far from the sparse end-of-episode reward. That extra variance is exactly what destabilizes long-horizon credit assignment.
Concretely, the standard clipped PPO objective is optimized:
with advantages from GAE, and . The asymmetry is entirely in the value function: the critic conditions on the hindsight context, so its regression target uses rather than :
Because contains information the actor can't see, the value estimate is far less of a blind guess — lowering advantage variance without ever contaminating the deployed policy. Reward itself is a two-part framework: a rule-based reward with a core task score (all fail-to-pass and pass-to-pass tests must pass for full credit), eight behavioral constraints (duplication, garbled output, tool-call accuracy and placement, redundant calls, parallelism, debug-artifact cleanup), and failure-path incentives (file-search , unit-test pass rate); plus a model-based generative reward model scoring fault diagnosis, post-fix validation, and execution strategy. The reported SWE training curve rises stably throughout.

Multi-Teacher On-Policy Distillation
Rather than run five separate RL specialists and hope they compose, KAT-Coder fuses them with Multi-Teacher On-Policy Distillation (MOPD): the student generates on-policy, and for each domain its distribution is pulled toward that domain's expert teacher under a reverse-KL objective —
fusing five experts — agentic software engineering, general agentic reasoning, terminal use, web coding, and general knowledge — into one model without the usual "see-saw" of gains in one domain costing another. Two stabilizers make on-policy distillation behave: an off-policy cold start (ordinary teacher-forced cross-entropy on teacher samples) to bootstrap before going on-policy, and drift-aware dynamic truncation that measures the top- overlap between teacher and student predictions and truncates where they diverge too far.
The numbers
Evaluated under a unified Claude Code harness against a panel of frontier models (GLM-5.1, GLM-5.2, Kimi-K2.6, and Opus 4.8), KAT-Coder-V2.5 posts the top score on PinchBench (94.9) and ranks second only to Opus 4.8 on repository-level SWE — SWE-Bench Pro 65.2 (Opus 4.8 leads at 69.2) and the team's own KAT Code Bench 53.1 (Opus 4.8 57.3):
The picture is not uniform. On tool-use and repo-level SWE, KAT-Coder is at or near the frontier; on Terminal-Bench 2.1 it scores 60.7 — behind GLM-5.2 (77.9), Kimi-K2.6 (73.0), and Opus 4.8 (84.6) — and on SciCode 50.3, behind GLM-5.2 (50.5) and both Kimi-K2.6 and Opus 4.8 (53.5). On KAT Claw Bench it reaches 85.5, with GLM-5.2 (86.8) and Opus 4.8 (90.7) ahead. The efficiency of the training stack — not inference — is the story; the paper reports no wall-clock or cost comparison against the frontier panel.

The take
KAT-Coder-V2.5 is best read not as a model but as a recipe for the surrounding machine. Its most transferable ideas are architectural in the systems sense: verify environments by actually collecting tests (not scraping logs), recover near-misses with hints and then strip the hints so the data stays honest, randomize the harness so the policy learns the task instead of the scaffold, and hand the critic — but never the actor — a view of the future to tame sparse-reward variance. Set against rollout-stability work like Routing Replay and cheaper frontier RL, the throughline is the same: at long horizons, most of the win is in the plumbing, not the loss function. Whether the fixed recipe generalizes past the team's own repositories and benchmarks — and closes the terminal and scientific gaps — is the open question; but as an account of what it takes to make a coding model live inside a repository, it's unusually complete.
Built on the KAT-Coder-V2.5 Technical Report (Huang, Li, Xu et al.; Kwaipilot / Kuaishou, 2026). All benchmark values are quoted from the paper's Table 4 (unified Claude Code harness); the interactive diagrams are illustrations of the mechanism, not measured traces. PinchBench averages are the paper's, retrieved from pinchbench.com on 2026-07-02.