Original title: Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation
Kefeng Duan, Dewu Zheng, Yanlin Wang, Terry Yue Zhuo +7 · September 2026
Writing code for large software projects is hard for large language models because the entire codebase is too big to fit into their input limits. To fix this, standard systems fetch helpful code snippets to guide the model. But they only fetch background information once at the start. When models write code piece by piece, errors usually start at a few decisive points. If the model makes a mistake on one of these "critical tokensSpecific positions in generated code where small mistakes lead to major functional failures.," the rest of the code follows the wrong path and completely fails. To solve this, researchers built ACToR. While the model writes, ACToR spots these decisive positions as they appear and immediately fetches the exact code needed right then. It also uses a weighting method to score and prioritize the most useful details. Across tests on two code benchmarks, ACToR beat existing methods, boosting performance by 8.4% on RepoExec and 15.4% on CoderEval.
Imagine you're packing for a camping trip, but you can only carry a small backpack. You need to choose items based on the weather forecast, but the forecast changes depending on which trail you take. In this paper, when generating code for a large project, the system can't access the entire repository at once, so it must decide what to retrieve. The necessary context shifts with each decision, especially at critical tokens. ACToR identifies these points and fetches only the specific repository context needed at that moment, instead of loading everything upfront.
When developers use AI to write code for large projects, mistakes often happen because the AI can't see the full context. This method helps the AI fetch the right pieces of the project at the exact moments they're needed, making the generated code more likely to work correctly the first time.
The abstract doesn't state explicit limitations, but based on scope, the work is evaluated only on two repository-level benchmarks (RepoExec and CoderEval), so it may not generalize to all programming languages or project sizes. It also assumes that critical tokens can be reliably identified during generation, which might not always hold.
Ask anything about this paper. Answers come from its abstract, and say so when the abstract doesn't cover your question.
Adaptive Critical Token-Aware Retrieval for Repository-Level Code Generation — Kefeng Duan, Dewu Zheng, Yanlin Wang et al.
Abstract licence: CC0
Explanation generated by Synthesis from the abstract — it is not the original paper. This is a preprint, so it hasn't necessarily been peer reviewed.