← Latest papers
🤖 AI

In Line with Context: Repository-Level Code Generation via Context Inlining

This contribution introduces InlineCoder, a novel framework that improves repository-level code generation by integrating the call graph of an unfinished function—comprising a generated anchor, upstream calling functions, and downstream called functions—into the prompt to transform the complex understanding of an entire repository into a more manageable task level at the function level.

Original authors: Chao Hu, Wenhao Zeng, Yuling Shi, Beijun Shen, Xiaodong Gu

Published 2026-05-07
📖 5 min read🧠 Deep dive

Original authors: Chao Hu, Wenhao Zeng, Yuling Shi, Beijun Shen, Xiaodong Gu

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

The Big Idea: Writing Code with a "Call-Stack" Perspective

Imagine you are a new employee hired to write a specific function for a massive software company. In the past, when you asked for help, you might have received only a list of similarly looking sentences from other parts of the office. You would see words like "calculate" or "user" and try to guess what to do. This often led to errors because you didn't know who asked you to do the work or which tools were available in the room.

InlineCoder is a new system that changes how AI writes code for these large projects. Instead of showing the AI just a list of similar sentences, it physically rewrites the story to show the AI exactly where the new code fits in the real world.

Here is how it works, broken down into simple steps:

1. The Problem: The Trap of the "Isolated Room"

When the AI tries to write a code section for a massive software project (a "repository"), it usually gets stuck in an "isolated room."

  • The Old Way: The AI receives the job description (the function signature) and some random, similarly looking documents from the project. It is like trying to repair a car engine while blindfolded, holding only a picture of a similarly looking engine from another car. You might put the screws in the right place, but you don't know which direction the belt runs or who is driving the car.
  • The Result: The AI writes code that looks okay in isolation but destroys the entire system because it doesn't know how the new code connects with the rest of the project.

2. The Solution: "Context Inlining"

The authors of this paper, InlineCoder, realized that to understand a task, you must see two things:

  1. Who is calling you? (The "Upstream" context: The boss requesting the work).
  2. Who are you calling? (The "Downstream" context: The tools or helpers you need to get the work done).

InlineCoder uses a clever trick called Inlining. Imagine you are writing a script for a play. Instead of just giving the actor their lines, you take the script and physically insert the actor's lines into the scenes where the other actors speak to them. Suddenly, the actor sees exactly what tone of voice to use, which props are handed to them, and how their lines fit into the flow of the conversation.

3. How InlineCoder Works (The 3-Step Dance)

Step 1: The "Draft" (The Anchor)
First, the AI makes a quick, rough estimate of the code. It is not perfect, but it is a starting point. Think of it as the AI saying: "Here is my best guess at what this function should look like."

Step 2: The "Upstream" Inlining (Seeing the Boss)
The system takes this rough estimate and inserts it directly into the code of the functions that call it.

  • Analogy: Imagine you are a chef. Instead of just being told "Make a soup," the system shows you the exact moment the waiter hands you the order, which ingredients the waiter is holding, and how the soup is served.
  • Why it helps: The AI now sees exactly what data is coming in and what format the result must be in. It stops guessing and starts meeting the specific needs of the "caller."

Step 3: The "Downstream" Retrieval (Finding the Tools)
The system examines the rough draft to see which tools (other functions) the AI attempted to use. It then goes into the project's library and fetches the actual code for those tools to ensure the AI uses the correct version.

  • Analogy: If the chef's draft says "Use the blender," the system finds the exact blender in the kitchen and shows the chef how to use it, rather than letting the chef guess which device to grab.

4. The "Trust Check"

The system is smart enough to know when it is uncertain. It calculates a "trust score" based on how easy the draft was to write.

  • High trust score: "That looks good, just polish it."
  • Low trust score: "That looks risky. Throw away the draft and start over with the new context."
    This prevents the AI from stubbornly sticking to a bad idea just because it wrote it first.

5. The Results: Why It Matters

The paper tested this on two massive benchmarks (DevEval and RepoExec) using various AI models.

  • The Result: InlineCoder beat almost every other method by a wide margin.
  • The Gains: It improved code accuracy in some metrics by nearly 30% compared to the best previous methods.
  • The Insight: By showing the AI the "Call Graph" (who talks to whom) instead of just a list of similar words, the AI writes code that actually works within the complex network of a real software project.

Summary

Think of InlineCoder as a translator that translates not just words, but relationships. It stops treating code as isolated sentences and starts treating it as a conversation. By physically embedding the new code into the conversations happening around it (the callers) and into the tools it relies on (the callees), it ensures the AI writes code that fits perfectly into the existing software ecosystem.

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 →