让编程智能体通过编译器和语言服务器反馈学习,避免胡乱改代码。
Reinforcement Learning from Compiler and Language Server Feedback
- 用编译器和语言服务器的诊断信息作为强化学习信号
- 改进后代码在测试中失败率降低47%,且编辑更安全
- 适合想提升自动化编程工具可靠性的开发者
编程智能体在缺乏程序事实支撑时容易产生错误:它们会虚构API、误选符号,并在无证据的情况下进行修改。编译器、类型检查器和语言服务器已具备必要的监督信号,如诊断信息、符号解析、类型数据、引用关系和重构条件,但这些信息以面向人类使用的IDE接口形式暴露。本文提出基于编译器与语言服务器反馈的强化学习(RLCSF),并设计Lanser-CLI这一以命令行为核心的协调层,将此类信号用于智能体训练与持续集成。RLCSF将每次工具交互视为状态转移,并根据诊断变化、选择器置信度和编辑安全性计算结构化奖励。Lanser-CLI则将短暂的LSP会话转换为可重放的分析包,包含固定环境元数据和稳定内容哈希。其核心机制包括超越文件:行:列的鲁棒选择器、确定性包归一化、预览优先的受控变更,以及可在冻结快照下重放的基于潜力的奖励函数。我们形式化了标准分析包的确定性,并证明在无折扣设置下,组件改善的转移将获得非负奖励。这些模块共同构建了一个可用于编程智能体过程监督的实用基础。
原文摘要 · Abstract (English)
Coding agents fail when text-level guesses outrun program facts: they hallucinate APIs, drift to the wrong symbol, and apply edits without evidence that the workspace remains valid. Compilers, type checkers, and language servers already compute the missing supervision signal, in the form of diagnostics, symbol resolution, type information, references, and refactoring preconditions, but expose it through interfaces designed for human-driven IDEs rather than learning loops. We introduce Reinforcement Learning from Compiler and Language Server Feedback (RLCSF) together with Lanser-CLI, a CLI-first orchestration layer that exposes this signal to agents and CI. RLCSF treats each tool interaction as a transition and computes a shaped process reward from deterministic changes in diagnostics, selector confidence, and edit safety. Lanser-CLI, in turn, converts ephemeral LSP sessions into replayable Analysis Bundles with pinned environment metadata and stable content hashes. Its core mechanisms are robust selectors that go beyond file:line:col, deterministic bundle normalization, preview-first guarded mutations, and a reward functional whose potential-based component is replayable under frozen snapshots. We formalize determinism for canonical bundles and prove that componentwise-improving transitions receive non-negative reward in the undiscounted setting. Together, these pieces yield a practical substrate for process supervision of coding agents.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。