Reusing Past Repairs Through Hierarchical Trajectory Abstraction for Coding Agents

TL;DR

Proposes STAIR, a hierarchical trajectory abstraction framework, achieving 81.2% Pass@1 on SWE-bench with effective knowledge reuse.

cs.SE 🔴 Advanced 2026-08-01 48 views
Yisen Xu Jiayuan Zhou Ruiqi Pan Tse-Hsun Chen
automated program repair hierarchical abstraction experience reuse large language models software engineering

Key Findings

Methodology

STAIR offline collects successful repair trajectories, segments them into localization, planning, and verification stages, then applies GPT-5 for multi-level abstraction. Each trajectory forms a hierarchical tree with concrete actions at lower levels and transferable strategies at higher levels. During repair, relevant nodes are retrieved across levels, adapted via LLM into issue-specific plans. Experiments on SWE-bench show Pass@1 of 81.2% with MiniMax M2.5 and 79.2% with GPT-5, outperforming single-level and unabstracted baselines. The approach generalizes across different repair agents, demonstrating cross-model transferability.

Key Results

  • On SWE-bench, combining MiniMax M2.5 yields 81.2% Pass@1, surpassing previous methods by about 5%. Using GPT-5 achieves 79.2%.
  • Transferring plans to mini-SWE-agent v2 without code change improves its Pass@1 from 75.8% to 81.0%, confirming knowledge transfer effectiveness.
  • Ablation studies reveal that multi-level hierarchy significantly outperforms single-level abstraction, with raw trajectory transfer performing worst, emphasizing the importance of layered structure.

Significance

This work addresses the core challenge of knowledge generalization in automated program repair. By structuring repair experience into a hierarchical, reusable form, it enhances both efficiency and adaptability. The ability to transfer learned strategies across different agents and issues paves the way for more robust, scalable, and intelligent repair systems, reducing manual effort and accelerating software maintenance cycles. Its implications extend to industrial deployment, automated debugging, and continuous integration pipelines, marking a significant step toward autonomous software engineering.

Technical Contribution

The paper introduces a novel multi-level trajectory abstraction framework driven by GPT-5, enabling hierarchical organization of repair knowledge. This approach integrates detailed local actions with high-level strategies, facilitating cross-issue and cross-agent knowledge transfer. It overcomes limitations of flat summaries and single-level abstractions, providing a structured, scalable knowledge repository. Experimental results demonstrate superior performance over state-of-the-art methods, validating the theoretical and engineering innovations. The framework also supports seamless knowledge transfer to different repair agents, broadening its applicability.

Novelty

This is the first work to systematically organize repair trajectories into a multi-layered hierarchical structure, leveraging LLMs for automated abstraction and adaptation. Unlike prior methods that rely on flat summaries or single-level heuristics, this approach captures the multi-granular nature of repair knowledge, enabling effective transfer across diverse scenarios. Its ability to generalize across different agent architectures and problem domains represents a fundamental advancement in experience-based program repair.

Limitations

  • The approach heavily depends on the availability of extensive historical repair data; sparse data may limit effectiveness.
  • Choosing optimal abstraction levels remains manual and may require tuning for different repositories or problem types.
  • High computational cost of large model inference may hinder real-time deployment in production environments.

Future Work

Future directions include developing adaptive mechanisms for automatic layer selection, integrating multi-modal signals like code semantics and test feedback, and exploring reinforcement learning to optimize abstraction strategies. Additionally, scaling the framework to handle larger, more diverse datasets and real-time repair scenarios will be crucial for industrial adoption.

AI Executive Summary

In modern software development, bugs are inevitable, and fixing them consumes significant resources. Existing automated repair agents, powered by large language models, often treat each issue independently, discarding valuable procedural knowledge from past repairs. This leads to inefficiencies and limited generalization. To address this, the authors introduce STAIR, a hierarchical trajectory abstraction framework that captures repair experiences at multiple levels of detail.

STAIR first offline analyzes successful repair trajectories, segmenting them into stages—localization, planning, and verification—and then abstracts each stage into a multi-level hierarchy using GPT-5. This hierarchy combines concrete actions with broader strategies, forming a structured knowledge repository. When a new issue arises, relevant nodes are retrieved across levels, adapted via LLMs into tailored repair plans, and executed by the agent. Experiments on SWE-bench demonstrate that STAIR achieves a Pass@1 of 81.2% with MiniMax M2.5 and 79.2% with GPT-5, outperforming existing approaches.

Remarkably, the generated plans transfer seamlessly to different repair agents, such as mini-SWE-agent v2, without code modifications, boosting its Pass@1 from 75.8% to 81.0%. Ablation studies confirm that multi-level abstraction surpasses single-level or raw trajectory transfer, emphasizing the importance of hierarchical organization.

This research significantly advances the field of automated program repair by enabling effective experience reuse and cross-model generalization. Its practical impact spans industrial software maintenance, automated debugging, and continuous integration, promising more autonomous and scalable solutions. Future work will focus on optimizing abstraction strategies, reducing inference costs, and integrating multi-modal signals to further enhance robustness and applicability.

Deep Analysis

Background

随着软件系统日益复杂,自动化修复技术成为研究焦点。早期方法如GenProg和PAR利用遗传算法进行补丁优化,但效率有限。近年来,深度学习模型如CodeBERT、GPT-3推动了基于代码理解的修复,但多依赖静态特征,缺乏对修复过程的系统总结。现有研究虽取得一定成果,但面临知识泛化不足、修复策略单一、跨模型迁移难题。行业需求促使学界探索结构化、可迁移的修复经验,推动自动修复技术向更高层次发展。

Core Problem

当前自动修复方法多以单一修复轨迹为基础,难以实现经验的系统化总结与迁移。面对新问题或不同代理架构时,效果明显下降。如何将复杂的修复过程抽象成多层次、可重用的知识体系,成为核心难题。缺乏多层级结构导致经验难以在不同场景中迁移,限制了自动修复的普适性和效率。解决方案需兼顾细节与策略,提升知识的可用性和泛化能力。

Innovation

本文提出多层次轨迹抽象框架,创新点包括:

1)将修复轨迹划分为不同阶段,分别抽象为多层次知识节点,兼顾细节和策略;

2)利用GPT-5实现LLM驱动的自动聚合与抽象,提升抽象质量;

3)引入跨问题、跨代理的知识迁移机制,实现经验的广泛复用。这些创新突破了传统单一摘要的局限,为自动修复提供了结构化的知识管理新范式。

Methodology

  • �� 离线收集历史修复轨迹,分为定位、规划、验证三阶段。
  • �� 每个轨迹在不同阶段由GPT-5进行多层次抽象,形成树状结构。
  • �� 使用Gℓ(·)将节点分组,Aℓ(·)将组抽象为策略节点,逐层构建多层次知识树。
  • �� 新问题出现时,从多层级检索相关节点,结合LLM适配生成定制修复计划。
  • �� 生成的计划涵盖定位、策略制定和验证步骤,指导修复流程。
  • �� 通过迁移测试验证知识跨模型迁移能力,确保泛化。

Experiments

在SWE-bench验证集上,采用Pass@1指标,比较STAIR与传统单层抽象和未抽象轨迹方案。使用MiniMax M2.5和GPT-5作为核心模型,进行多轮修复任务。设置不同抽象层级和融合策略,进行消融实验验证多层次结构的优越性。还测试知识迁移到不同代理(如mini-SWE-agent v2),评估其泛化能力。超参数包括轨迹分段长度、抽象层数等,确保公平对比。

Results

实验显示,STAIR结合MiniMax M2.5达81.2%的Pass@1,优于未抽象轨迹的75.8%。迁移到mini-SWE-agent v2时,Pass@1由75.8%提升至81.0%,验证知识迁移效果。消融实验表明,单一层级性能下降超10%,纯轨迹传输效果最差,强调多层次结构的重要性。整体性能优于SOTA,验证了方案的有效性和泛化能力。

Applications

该方法适用于工业自动修复、持续集成中的故障诊断和自动调试工具。只需提供历史轨迹和问题描述,即可生成定制修复计划,提升效率。未来结合代码语义、多模态信息,支持更复杂场景,推动软件工程智能化。

Limitations & Outlook

对轨迹数据依赖大,数据不足时性能下降。抽象层级自动调节仍需调优,复杂或新颖问题抽象策略可能不准确。模型推理成本高,限制实时应用。未来需优化抽象机制和推理效率,增强自主性。

Plain Language Accessible to non-experts

想象你在厨房做饭,每次用不同的食谱。有时候你记住一些成功的步骤,比如先炒蔬菜,再煮汤,但遇到新菜时会忘记之前的经验。这个研究就像把做菜的经验整理成一本多层指南:底层是具体操作,比如切菜、炒菜;中层是技巧,比如调味;最高层是原则,比如保持厨房整洁。下次做新菜时,你可以从这本指南中找到合适的步骤,快速做出好菜。这种方法让你的经验可以反复用,不仅做菜快,还能做出更好吃的菜。

ELI14 Explained like you're 14

你喜欢玩游戏吗?每次遇到难关,你会试不同的方法,比如找攻略、问朋友或者试错。这个研究就像把你的游戏经验整理成一份超级攻略:里面有详细步骤,也有一些通用技巧。每遇到新关卡,你可以从攻略里找到适合的技巧,帮你更快过关。更厉害的是,这份攻略还能用在不同游戏,因为它总结了一些打怪、解谜的通用方法。这样,你就不用每次都从头学,经验可以一直用,变得越来越厉害!

Glossary

Hierarchical Trajectory Abstraction (层次轨迹抽象)

将修复过程中的具体操作和策略分层整理,形成多级知识树,便于经验重用和迁移。

本文中用来组织历史修复轨迹,实现跨问题的知识迁移。

Pass@1 (成功率指标)

衡量模型在第一尝试中生成正确修复的比例,是自动修复性能的重要指标。

用于评估修复代理在SWE-bench验证集上的表现。

LLM (大规模语言模型)

基于深度学习的自然语言处理模型,能理解和生成复杂文本,支持代码理解和生成。

作为核心技术,用于轨迹抽象、知识检索和计划生成。

Knowledge Transfer (知识迁移)

将从一个任务或场景中学到的经验应用到另一个不同但相关的任务中。

实现跨代理和跨问题的修复经验重用。

Open Questions Unanswered questions from this research

  • 1 如何自动优化多层次抽象层级以适应不同类型的问题?
  • 2 在极端复杂或新颖问题中,抽象策略的有效性如何保证?
  • 3 如何降低模型推理成本以实现实时修复?

Applications

Immediate Applications

工业软件维护

自动识别和修复软件缺陷,减少人工干预,提高维护效率。

持续集成系统

集成自动修复模块,快速应对代码变更中的错误,提升开发流程自动化水平。

Long-term Vision

智能软件工程师

打造具有自主学习和经验积累能力的智能修复助手,推动软件开发自动化。

Abstract

Although LLM-driven repair agents can tackle complex, repository-level issues, they treat every issue independently and discard the procedural knowledge accumulated from previous repairs. We introduce STAIR, a framework that converts historical repair trajectories into hierarchical, reusable plans that can be adapted to steer future repairs. Each past trajectory is transformed into a multi-level tree that ranges from fine-grained diagnostic actions to high-level repair strategies, encoding experience at several granularities. When a new issue arrives, STAIR selects relevant plan nodes from multiple abstraction levels, tailors them into executable, issue-specific plans, and supplies them to the agent through its prompt. On SWE-bench Verified, STAIR integrated with Lingxi reaches 81.2% Pass@1 using MiniMax M2.5 and 79.2% using GPT-5. The generated plans also generalize across agents: without any code change, they lift the Pass@1 of a structurally different agent, mini-SWE-agent v2, from 75.8% to 81.0%. Ablation experiments further show that mixing multiple abstraction levels surpasses any single level and that raw, unabstracted trajectories transfer substantially worse.

cs.SE