Retrieving code by "how it is done" — ProjAgent and procedural similarity for repository-level code generation
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?
Why does it help code generation?
Sources (primary)
Source: arXiv (descriptive metadata is CC0 public domain). Summaries are our own; see arXiv for the original text and PDF.
- arXiv abstract page (original, official)
- PDF (arXiv)
- arXiv ID: 2607.08691