Radar · 21/07/2026 · happened on 19/07/2026 · research

SWE-Pruner Pro: the coding agent already knows what to cut from context

A ByteDance research team shows that coding agents already have an internal map of what matters in the code they read. You don’t need an external classifier to decide what to keep and what to discard: a small head that reads the model’s internal representations and decides, line by line, whether to keep or prune it is enough.

SWE-Pruner Pro works like this: when the agent reads tool output, a lightweight head transforms its internal representations into a “keep” or “prune” label for each line, with an embedding that accounts for output length. On two open-weight models and four multi-turn benchmarks, the savings reach 39% of prompt and completion tokens while maintaining quality (figures claimed in the paper, not verified by us). On MiMo-V2-Flash pruning actually improves results: +3.8% on SWE-Bench Verified and +2.2 points on Oolong.

Why it matters to you. If you use coding agents on long codebases, context is the bottleneck. Every file read, every tool output accumulates in the window and costs tokens. A system that prunes context from inside the model, without weighing down the pipeline with a separate classifier, cuts costs and latencies where they hurt most. It’s particularly relevant for those doing refactoring or debugging on large projects, where sessions stretch out and context grows until the window saturates. Token overhead in coding agents is a concrete problem we’ve already seen up close.

The code is public on GitHub, but we haven’t tested it.

The detail

What came before.

Coding agents working on real codebases accumulate context at every step. The agent reads a file, runs a search, inspects a directory: every output lands in the context window and stays there for the rest of the session. On large projects, the window saturates fast, costs climb and reasoning quality drops, because the model has to untangle thousands of lines, many of them irrelevant.

The existing solution, called SWE-Pruner, hooks an external classifier to the model: a separate model reads the tool output and decides what to keep and what to discard. It works, but adds another component, with its own costs and latencies.

What changes.

ByteDance researchers discovered that the main model, the one acting as agent, already encodes an indication of relevance in its internal representations. When it reads tool output, its intermediate layers “know” which lines matter and which don’t. All you need is a lightweight head, a small module added on top of the existing model, that reads those representations and produces a binary label for each line: keep or prune.

The head also includes a length-sensitive embedding, because the judgment on what’s relevant changes if the tool returns 10 lines or 1,000. This detail counts: an external classifier treated all outputs the same way, while the agent adapts its own filter to the scale of the material.

The numbers, in context.

The paper tests SWE-Pruner Pro on two open-weight backbones and four multi-turn benchmarks. The maximum savings claimed is 39% of prompt and completion tokens, with inference overhead that researchers describe as “limited” without quantifying it in a way we can verify from the abstract. On MiMo-V2-Flash, one of the two backbones, pruning doesn’t just save: it improves results, with +3.8% on SWE-Bench Verified and +2.2 points on Oolong, a long-context benchmark.

The fact that pruning context improves quality isn’t as counterintuitive as it sounds. A context cluttered with irrelevant lines distracts the model and worsens its decisions. Less noise, cleaner signal.

How much to trust.

The numbers come from the paper, not from independent evaluation. The benchmarks are four, the backbones two: a respectable sample for a research paper, but it doesn’t say how it would behave on a different model or on a codebase with different characteristics. Inference overhead is described as “limited” but not quantified in a verifiable way in the abstract. The code is public on GitHub, so anyone can reproduce or verify.

What to do with it.

If you build or configure coding agents for real use, the practical point is that context needs to be managed downstream too: prune what the agent has already read and no longer needs, not just decide upstream what to have it read. SWE-Pruner Pro suggests that the model itself is the best source for that judgment, and that an external classifier can be redundant. For those using off-the-shelf coding agents, the lesson stays useful even without implementing the system: when a session stretches out, compacting context manually (summarizing what emerged and discarding raw outputs) is the move that this paper automates from the inside.

Type to search across course, playbooks, skills, papers…