arXiv:2604.05407cs.AIcs.SE2026-04ACL被引 5

让代码智能体按语法结构操作,修复率提升近21%且更省计算资源。

CODESTRUCT: Code Agents over Structured Action Spaces

论文配图:CODESTRUCT: Code Agents over Structured Action Spaces
图 1 · 摘自论文原文
  • 用抽象语法树实体替代文本匹配,实现精准代码修改
  • 在SWE-Bench上平均准确率提升1.2%-5.0%,部分模型提升超20%
  • 适合常因格式变化出错的代码生成模型,尤其提升小型模型表现

基于大模型的代码智能体将代码库视为无结构文本,通过脆弱的字符串匹配进行编辑,常因格式变化或模式歧义失败。我们提出将代码库重构为结构化操作空间,使智能体在命名的抽象语法树(AST)实体上操作,而非文本片段。所提框架CODESTRUCT提供readCode用于检索完整语法单元,editCode用于对语义程序元素执行语法验证的转换。在SWE-Bench Verified上评估,六种大模型的Pass@1准确率提升1.2%-5.0%,多数模型的令牌消耗降低12%-38%。频繁在文本接口下产生无效补丁的模型受益最大:GPT-5-nano的准确率提升20.8%,空补丁失败率从46.6%降至7.2%。在CodeAssistBench上,准确率持续提升0.8%-4.4%,成本最高降低33%。结果表明,结构感知接口为代码智能体提供了更可靠的基底。

原文摘要 · Abstract (English)

LLM-based code agents treat repositories as unstructured text, applying edits through brittle string matching that frequently fails due to formatting drift or ambiguous patterns. We propose reframing the codebase as a structured action space where agents operate on named AST entities rather than text spans. Our framework, CODESTRUCT, provides readCode for retrieving complete syntactic units and editCode for applying syntax-validated transformations to semantic program elements. Evaluated on SWE-Bench Verified across six LLMs, CODESTRUCT improves Pass@1 accuracy by 1.2-5.0% while reducing token consumption by 12-38% for most models. Models that frequently fail to produce valid patches under text-based interfaces benefit most: GPT-5-nano improves by 20.8% as empty-patch failures drop from 46.6% to 7.2%. On CodeAssistBench, we observe consistent accuracy gains (+0.8-4.4%) with cost reductions up to 33%. Our results show that structure-aware interfaces offer a more reliable foundation for code agents.

代码生成结构化操作LLM应用AST

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。