cs.SE cs.AI cs.IR

Retrieving code by "how it is done" — ProjAgent and procedural similarity for repository-level code generation

cs.SE QiHong Chen, Aaron Imani, Iftekhar Ahmed Jul 2026

Repository-level code generation must implement a target function amid cross-file dependencies and project conventions. Existing retrieval relies on lexical, structural, or semantic similarity, missing functions with similar procedural logic. ProjAgent adds procedural similarity as an explicit signal: it decomposes the target into steps, retrieves similar procedures per step, merges them with semantic retrieval, and repairs code via static analysis — reaching 41.14% Pass@1 on REPOCOD.

Paper overview (our summary)

  • Field (arXiv category)cs.SE(+2)
  • AuthorsQiHong Chen, Aaron Imani, Iftekhar Ahmed
  • Submitted2026-07-09
  • arXiv ID2607.08691v1

Key points

  • Repository-level code generation must respect cross-file dependencies and project conventions
  • Existing retrieval (lexical/structural/semantic) overlooks functions with similar procedural logic
  • Introduces procedural similarity as an explicit signal: decompose the target into steps, retrieve similar procedures per step
  • Integrates procedural context with semantic retrieval; conservative compiler/static-analysis feedback loop repairs code
  • 41.14% Pass@1 on REPOCOD, beating retrieval-based baselines — procedural similarity is an effective, unexplored dimension

This work (ProjAgent) improves how AI code generation finds the existing code it references, from a new angle.

1What makes repository-level generation hard

Repository-level code generation must implement a target function while accounting for complex cross-file dependencies and project-specific conventions. Finding the right reference code is key, yet existing retrieval methods rely predominantly on lexical, structural, or semantic similarity.

As a result they often overlook functions that implement similar procedural logic — the best references — when identifiers or application domains differ.

2Procedural similarity as a retrieval signal

ProjAgent introduces this procedural similarity as an explicit retrieval signal. It first decomposes the target function into intermediate reasoning steps, then, for each step, uses an agentic workflow to retrieve repository functions that exhibit similar procedural behavior. The retrieved procedural context is integrated with conventional semantic retrieval to construct a richer repository context for code generation.

It also adds a conservative feedback loop that iteratively repairs generated code using compiler and static-analysis feedback.

341.14% Pass@1 on REPOCOD

Evaluated on the REPOCOD benchmark, ProjAgent achieves 41.14% Pass@1, outperforming existing retrieval-based baselines. These results demonstrate that procedural similarity is an effective, previously unexplored retrieval dimension for repository-level code generation.

Why it matters

Directly relevant to the retrieval design of AI coding assistants and repository-level code generation. Retrieving reference code by how it is done, plus self-repair via static analysis, is an implementation reference for developers of code-generation tools and RAG retrieval.

FAQ

What is procedural similarity?
Similarity in the steps and logic of the processing, even when variable names or domains differ. It is a new angle for finding genuinely useful reference code that name- or meaning-based retrieval misses.
Why does it help code generation?
Repository-level implementation must respect existing conventions and dependencies. Referencing functions that are procedurally similar gives the model more accurate context, improving generation quality.

Sources (primary)

Source: arXiv (descriptive metadata is CC0 public domain). Summaries are our own; see arXiv for the original text and PDF.

#AI#arXiv#Research paper#Code generation#Coding assistant#RAG
Disclaimer: This site independently summarizes and classifies information based on official data sources. Always verify the latest and accurate information with the official sources. Content on finance, health, legal, and security is information, not advice. This site is not an official website of the U.S. government.