Statically Contextualizing Large Language Models with Typed Holes
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have reshaped the landscape of program synthesis. However, contemporary LLM-based code completion systems often hallucinate broken code because they lack appropriate context, particularly when working with definitions not in the training data nor near the cursor. This paper demonstrates that tight integration with the type and binding structure of a language, as exposed by its language server, can address this contextualization problem in a token-efficient manner. In short, we contend that AIs need IDEs, too! In particular, we integrate LLM code generation into the Hazel live program sketching environment. The Hazel Language Server identifies the type and typing context of the hole being filled, even in the presence of errors, ensuring that a meaningful program sketch is always available. This allows prompting with codebase-wide contextual information not lexically local to the cursor, nor necessarily in the same file, but that is likely to be semantically local to the developer's goal. Completions synthesized by the LLM are then iteratively refined via further dialog with the language server. To evaluate these techniques, we introduce MVUBench, a dataset of model-view-update (MVU) web applications. These applications serve as challenge problems due to their reliance on application-specific data structures. We find that contextualization with type definitions is particularly impactful. After introducing our ideas in the context of Hazel we duplicate our techniques and port MVUBench to TypeScript in order to validate the applicability of these methods to higher-resource languages. Finally, we outline ChatLSP, a conservative extension to the Language Server Protocol (LSP) that language servers can implement to expose capabilities that AI code completion systems of various designs can use to incorporate static context when generating prompts for an LLM.
Key facts. Cited by 9 papers in the map (data through 14 Oct 2026). Builds on 42 of its 86 references that are in the map. First posted on arXiv 2 Sep 2024.
Builds on
42 of 86 references.
References · 42
- 2023GPT-4 Technical Reportcited by 18,396
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,455
- 2022Training Compute-Optimal Large Language Modelscited by 3,019
- 2023Retrieval-Augmented Generation for Large Language Models: A Surveycited by 2,212
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2022A Systematic Evaluation of Large Language Models of Codecited by 363
- 2022Text and Code Embeddings by Contrastive Pre-Trainingcited by 361
30 more
- 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 353
- 2023NLP Evaluation in trouble: On the Need to Measure LLM Data Contamination for each Benchmarkcited by 348
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
- 2024Knowledge Conflicts for LLMs: A Surveycited by 283
- 2024AutoCodeRover: Autonomous Program Improvementcited by 278
- 2023The Impact of AI on Developer Productivity: Evidence from GitHub Copilotcited by 274
- 2022Grounded Copilot: How Programmers Interact with Code-Generating Modelscited by 218
- 2023LooGLE: Can Long-Context Language Models Understand Long Contexts?cited by 202
- 2023CrossCodeEval: A Diverse and Multilingual Benchmark for Cross-File Code Completioncited by 183
- 2024Same Task, More Tokens: the Impact of Input Length on the Reasoning Performance of Large Language Modelscited by 152
- 2023Stop Uploading Test Data in Plain Text: Practical Strategies for Mitigating Data Contamination by Evaluation Benchmarkscited by 142
- 2023An Empirical Study of the Non-determinism of ChatGPT in Code Generationcited by 137
- 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 119
- 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
- 2022Repair Is Nearly Generation: Multilingual Program Repair with LLMscited by 68
- 2022CoCoMIC: Code Completion By Jointly Modeling In-file and Cross-file Contextcited by 65
- 2023Copiloting the Copilots: Fusing Large Language Models with Completion Engines for Automated Program Repaircited by 55
- 2023What Makes Good In-context Demonstrations for Code Intelligence Tasks with LLMs?cited by 47
- 2023Knowledge Transfer from High-Resource to Low-Resource Programming Languages for Code LLMscited by 45
- 2024RLCoder: Reinforcement Learning for Repository-Level Code Completioncited by 44
- 2024STALL+: Boosting LLM-based Repository-level Code Completion with Static Analysiscited by 21
- 2024Towards Neural Synthesis for SMT-Assisted Proof-Oriented Programmingcited by 20
- 2023Better Context Makes Better Code Language Models: A Case Study on Function Call Argument Completioncited by 14
- 2024The Fact Selection Problem in LLM-Based Program Repaircited by 12
- 2024Enhancing LLM-Based Coding Tools through Native Integration of IDE-Derived Static Contextcited by 10
- 2016Hazelnut: A Bidirectionally Typed Structure Editor Calculuscited by 8
- 2018Live Functional Programming with Typed Holescited by 7
- 2024Context Composing for Full Line Code Completioncited by 4
- 2017Toward Semantic Foundations for Program Editorscited by 2
- 2018Merlin: A Language Server for OCaml (Experience Report)cited by 2
Built on by
Citing papers per year: 2025: 3; 2026: 6.
9 papers.
- 2025Type-Constrained Code Generation with Language Modelscited by 35
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approachescited by 23
- 2026Parallel-SFT: Improving Zero-Shot Cross-Programming-Language Transfer for Code RLcited by 2
- 2025Iterative Formalization and Planning in Partially Observable Environmentscited by 1
- 2026Implementing Grassroots Logic Programs with Multiagent Transition Systems and AI (Full Version)cited by 1
- 2026LACUNA: Safe Agents as Recursive Program Holescited by 1
- 2026Compiler-Guided Inference-Time Adaptation: Improving GPT-5 Programming Performance in Idriscited by 0
- 2026Hydra: Efficient, Correct Code Generation via Checkpoint-and-Rollback Supportcited by 0
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Codecited by 0
- 2026Generative Compilation: On-the-Fly Compiler Feedback as AI Generates Code15 Jul 2026
- 2026LACUNA: Safe Agents as Recursive Program Holes27 May 2026
- 2026Hydra: Efficient, Correct Code Generation via Checkpoint-and-Rollback Support14 May 2026
- 2026Parallel-SFT: Improving Zero-Shot Cross-Programming-Language Transfer for Code RL22 Apr 2026
- 2026Compiler-Guided Inference-Time Adaptation: Improving GPT-5 Programming Performance in Idris12 Feb 2026
- 2026Implementing Grassroots Logic Programs with Multiagent Transition Systems and AI (Full Version)6 Feb 2026
- 2025Retrieval-Augmented Code Generation: A Survey with Focus on Repository-Level Approaches6 Oct 2025
- 2025Iterative Formalization and Planning in Partially Observable Environments19 May 2025
- 2025Type-Constrained Code Generation with Language Models12 Apr 2025