← Latest papers
🤖 AI

Context Pruning for Coding Agents via Multi-Rubric Latent Reasoning

The paper introduces LaMR, a structured context pruning framework that decomposes code relevance into semantic and dependency dimensions using multi-rubric latent reasoning and AST-based supervision to significantly reduce token usage while maintaining or improving coding agent performance.

Original authors: Jingjing Wang, Xiwen Chen, Wenhui Zhu, Huayu Li, Zhengxiao He, Feiyang Cai, Ana S. Carreon-Rascon, Xuanzhao Dong, Feng Luo

Published 2026-05-18
📖 4 min read☕ Coffee break read

Original authors: Jingjing Wang, Xiwen Chen, Wenhui Zhu, Huayu Li, Zhengxiao He, Feiyang Cai, Ana S. Carreon-Rascon, Xuanzhao Dong, Feng Luo

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a brilliant detective (the AI coding agent) trying to solve a complex case (fixing a bug in a software project). To solve the case, you need to read through thousands of pages of police reports, witness statements, and evidence files (the code repository).

The Problem: The "Too Much Paper" Trap
Currently, these AI detectives spend most of their time and energy just reading the files. They get overwhelmed by the sheer volume of text.

  • The Issue: They read everything, including irrelevant pages like old coffee stains on a report or a witness's lunch order. This wastes their "brain power" (token budget) and makes it harder to find the crucial clues.
  • The Old Fix: Previous tools tried to cut down the reading list by simply deleting anything that didn't seem immediately important. But they were too blunt. They would delete a page just because it didn't mention the main crime, even if that page contained the key to understanding the crime scene (like a map or a list of suspects). This left the detective with a broken puzzle, forcing them to go back and ask for the missing pages, which wasted even more time.

The New Solution: LaMR (The Smart Librarian)
The paper introduces LaMR (Latent Multi-Rubric), which acts like a super-smart, specialized librarian who helps the detective organize the files before they start reading.

Instead of using a single rule to decide what to keep, LaMR uses two different sets of glasses to look at every line of code:

  1. The "Semantic" Glasses (What does it say?):

    • This looks for lines that directly answer the detective's question.
    • Analogy: If the detective asks, "Who stole the cookie?", this glasses highlights the sentence "John took the cookie."
    • Old Problem: If a line just said "John" (a definition) or "import John" (a setup), the old tools might delete it because it doesn't explicitly say "stole."
  2. The "Dependency" Glasses (What does it need to make sense?):

    • This looks for the structural glue that holds the story together.
    • Analogy: Even if the sentence "John took the cookie" is the main clue, you also need the page that says "John is a suspect" or the map showing where John lives. Without these, the clue makes no sense.
    • The Innovation: LaMR realizes that some lines are important only because they support other lines. It keeps these "supporting" lines even if they don't seem exciting on their own.

How It Works: The Two-Step Process

  1. The Dual-Team Review:
    LaMR doesn't just ask one question. It runs two separate checks simultaneously. One team checks for "direct evidence," and the other team checks for "structural support."

    • Metaphor: Imagine a film editor. One editor cuts out boring scenes (Semantic), while another editor makes sure the movie still flows logically and doesn't have jump cuts (Dependency).
  2. The "Query-Adaptive" Gatekeeper:
    Depending on what the detective is asking, LaMR decides how much weight to give each team.

    • If the detective asks, "What is the logic for the login?" LaMR leans heavily on the Semantic team.
    • If the detective asks, "Why is the app crashing?" LaMR leans on the Dependency team to ensure all the necessary setup code (imports, error handlers) is kept so the crash makes sense.
  3. The "Clean-Up" Crew (AST Repair):
    Sometimes, even with two teams, a line might get accidentally cut. LaMR has a final safety net. It uses a "blueprint" of the code (called an AST) to check: "Hey, we deleted the 'If' statement, but we kept the 'Else' part. That's broken!" It automatically puts the missing structural pieces back in, ensuring the code remains valid.

The Results: Faster, Smarter, Cheaper
The paper tested this system on real-world coding tasks (like fixing bugs in big software projects).

  • Less Reading: LaMR helped the AI read 30% fewer pages (tokens) while solving the same problems.
  • Better Results: Because the AI wasn't distracted by irrelevant noise and didn't lose the structural "glue," it actually solved problems better or at least just as well as when reading everything.
  • No More "Backtracking": The old tools often deleted a necessary line, forcing the AI to realize it was stuck and ask for the file again. LaMR prevents this, saving time and money.

In Summary
LaMR is like a smart assistant who doesn't just throw away "boring" papers. Instead, it understands that a boring-looking page might be the key to understanding the exciting page next to it. By separating "what is said" from "what is needed to make sense," it gives the AI detective a lean, clean, and perfectly organized case file, allowing them to solve crimes faster and with less effort.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →