← Latest papers
💬 NLP

Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches

This survey provides a comprehensive review of Retrieval-Augmented Code Generation (RACG) with a specific focus on repository-level approaches, offering a unified analytical framework to examine retrieval strategies, autonomous agents, and key challenges in enabling large language models to generate coherent code across entire software repositories.

Original authors: Yicheng Tao, Yuante Li, Yao Qin, Yepang Liu

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

Original authors: Yicheng Tao, Yuante Li, Yao Qin, Yepang Liu

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 Picture: From Writing a Sentence to Building a City

Imagine you are a master architect.

  • Old Code Generation (Function Level): This is like being asked to write a single, perfect sentence for a novel. You just need to know the grammar and the immediate story.
  • Repository-Level Code Generation (RLCG): This is like being asked to redesign an entire city. You can't just look at one street; you have to understand how the subway connects to the power grid, how the new park affects traffic in a different district, and how the water pipes run under the old library.

The paper argues that while AI is great at writing single sentences (code functions), it struggles with the "city" (the whole software project) because real software is messy, huge, and full of hidden connections between different files.

The Solution: The "Super Librarian" (RACG)

To help the AI architect build the city, the paper introduces a concept called Retrieval-Augmented Code Generation (RACG).

Think of the AI not as a genius who memorized every book in the world, but as a brilliant student who needs to use a library.

  • The Problem: If you ask the student to fix a leak in the plumbing, they might guess wrong because they don't know where the pipes are.
  • The Solution (RAG): Before the student writes the fix, they go to the library, find the blueprints for this specific building, and read the relevant pages. Then, they use that fresh information to write the code.

The paper says this isn't just a one-time trip to the library. It's a dynamic process where the student keeps checking the blueprints, asking new questions, and adjusting their plan as they work.

The Two Main Ways to Organize the Library

The survey categorizes how these "Super Librarians" find information into two main styles:

1. The "Flat Pile" Approach (Non-Graph-Based)

Imagine the library has a giant pile of books. To find what you need, you search for keywords (like "pipe" or "leak").

  • How it works: The AI looks for words that match the problem.
  • The Catch: It might find a book about "pipes" in a plumbing manual, but miss the fact that in this specific building, the pipes are made of a weird material mentioned in a different file. It's good for simple searches but can miss deep connections.

2. The "Map" Approach (Graph-Based)

Imagine the library has a giant, 3D map of the city. The books aren't just piled up; they are connected by strings.

  • How it works: The AI sees that "File A" is connected to "File B" because one calls the other. It follows the strings (like a subway map) to find exactly where the problem is.
  • The Catch: Building this map takes a lot of time and effort. If the city changes (new code is added), the map has to be redrawn. Also, different cities (programming languages) need different map styles.

The Evolution: From Robot to Detective

The paper tracks how these systems have gotten smarter, moving through three "Levels of Autonomy":

  • Level 0: The Static Robot. The robot gets a question, looks up one answer, and writes code. It never changes its mind, even if it makes a mistake.
  • Level 1: The Self-Correcting Student. The student writes a draft, checks it, realizes it's wrong, looks up more info, and tries again. It's a loop of "Try -> Check -> Fix."
  • Level 2: The Detective Agent. This is the full detective. The agent doesn't just wait for a question. It walks around the city (the code repository), opens doors, checks the basement, talks to the "tools" (like a terminal or a compiler), and decides for itself what to look at next. It plans its own investigation.

The Toolkit: What Do They Use?

The paper also looks at the tools these systems use:

  • The Databases: They don't just use the code files. They also use bug reports, user comments, and even how developers have fixed similar problems in the past.
  • The Brains (Models): They use different "minds" for the job. Some are small and fast (good for simple tasks), while others are massive and expensive (good for complex reasoning). Interestingly, the paper notes that many researchers still use smaller, open-source models because they are cheaper to run, even though the big "proprietary" models (like the ones from OpenAI or Google) are very powerful.

The Big Questions and Challenges

The paper ends by asking some tough questions:

  1. Is the Librarian Necessary? If the AI student has a memory big enough to hold the entire city in their head (a "Long-Context" model), do they still need the librarian? The paper says: Yes, but it depends. For a small house, you might not need a librarian. But for a massive metropolis, the librarian is still faster and more efficient than trying to memorize everything.
  2. Safety: If the library is poisoned with fake blueprints, the AI might build a dangerous building. The paper warns that hackers could trick the system into retrieving bad code.
  3. The "Real World" Gap: Most tests are done on small, perfect examples. The paper argues we need to test these systems on messy, real-world projects that change every day, just like real software does.

Summary

In short, this paper is a map of how AI is learning to build software not just by guessing, but by reading the whole project, understanding the connections, and acting like a detective to solve problems. It moves us from "AI that writes a line of code" to "AI that can navigate and fix a whole software company's codebase."

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 →