Manuscript Offprint

arXiv:2610.11858

Trajectory-Guided Fault Localization for Agent Skill Evolution

Yu Ge, Linna Xie, Zhong Li, Yu Pei, Tian Zhang

Abstract

Agent skills provide reusable guidance for code agents, but incomplete or unsuitable guidance can impair task execution. To reduce the manual effort of skill refinement, recent approaches use LLMs to generate revisions from execution feedback. However, grounding these revisions in explicit behavioral evidence remains challenging. To address this gap, we propose SKILLMORPH, a skill-evolution approach based on trajectory-guided fault localization in agent skills. Its core idea is to link execution evidence to specific skill contents before generating revisions. Specifically, SKILLMORPH compares failure and success evidence in abstracted trajectories across repeated runs and tasks, incorporating changes between evolution loops to identify suspicious actions. It then uses these suspicious actions to localize edit sites in the skills and generate corresponding revisions. Experiments on SWE-Skills-Bench and CannBot show that the skills evolved by SKILLMORPH consistently achieve higher trial-level accuracy and execution consistency than the original skills and those from four existing skill-evolution methods. We have also applied SKILLMORPH to automated kernel generation with an AI operator-development team, which has accepted 6 skill-revision pull requests.

Keywords: Agent Skills, Skill Evolution, Fault Localization, Trajectory Analysis

1 Introduction

Agent Skills have become a common paradigm for supporting large language model (LLM)-based agents in domain-specific tasks such as software engineering [12], data analysis [15], and document processing [47]. Specifically, a skill packages reusable instructions, scripts, and reference materials for a specialized workflow. When carrying out a task, the agent loads the relevant skills and takes actions under their guidance, leveraging the experience encoded in those skills to solve the task more effectively. In practice, however, incomplete guidance or unsuitable workflows can lead the agent to take unsuitable actions, which limits skill effectiveness or even impairs task execution [10, 12]. Addressing these deficiencies generally relies on domain experts to inspect the agent's actions, trace the problematic ones back to the skill content that guided them, and iteratively revise and evaluate the guidance [1, 47]. This manual process makes skill refinement costly and time-consuming, and difficult to scale as task and skill collections grow.

To reduce manual effort, several approaches have recently been proposed for skill evolution, which aims to improve agent performance by automatically refining skills based on execution feedback [44,46,1,33,23,31,48][44, 46, 1, 33, 23, 31, 48]. Most of these techniques follow an iterative process with two steps: (1) executing a set of evolution tasks using the current skill set to collect execution feedback, and (2) prompting an LLM with this feedback to produce a revision of the skill content. Despite the effectiveness of existing skill-evolution approaches, three challenges remain.

First, it is challenging to ground skill revision in explicit behavioral evidence. Existing approaches generally prompt an LLM to generate revisions directly from execution feedback, such as task outcomes, case-level scores, or whole trajectories [44,17,1,10,49][44, 17, 1, 10, 49]. Consequently, which behaviors are problematic is implicitly determined by the LLM as it reads the feedback and writes the revision, leaving no record for later inspection or comparison. This results in two consequences. On the one hand, without an

∗^{*}Corresponding author.

†^{\dagger}Emails for all authors: yuge@smail.nju.edu.cn, xieln@smail.nju.edu.cn, lizhong@nju.edu.cn, yupei@polyu.edu.hk, ztluck@nju.edu.cn.

explicit link between problematic behaviors and the skill content that needs correction, the revisions are likely to alter content that merely appears relevant to the observed problem while leaving the content requiring correction unchanged. Recently, ContractSkill [24] achieved explicit localization by representing a skill as an ordered sequence of steps with postconditions and using a deterministic verifier to identify the failing step. However, it assumes that the skill can be expressed in such a structured form and that a suitable verifier is available, which limits its general applicability. On the other hand, without explicit behavioral evidence, earlier revisions are difficult to reassess when a problem recurs. Several recent approaches retain historical records across evolution loops, but these records capture only scores or task-level status rather than linking targeted behaviors to edited regions [44, 17]. Such coarse records are insufficient to distinguish an incorrect edit location from an insufficient correction at the right location. As a result, later loops may repeatedly modify the same content without resolving the deficiency, or fail to notice a regression introduced by an earlier revision.

Second, it is challenging to distinguish deficiencies of the skills from incidental behaviors of the agent. A deficiency is a property of the skills themselves and is shared by every execution under them, whereas agent behavior is stochastic and tasks differ in their conditions. However, existing approaches typically attribute problems from limited evidence. For example, SkillAdaptor attributes a failed trajectory to its earliest actionable step [46], and other approaches prompt an LLM to reflect on a minibatch of rollouts [44, 17]. In both cases, the LLM has to judge which observed problems are real, without a measure of how consistently a behavior is associated with failures across independent runs. Consequently, revisions can fit individual cases without addressing deficiencies shared by other tasks of the same class, which limits the improvement on unseen tasks.

Third, existing approaches struggle to address deficiencies that span multiple skills. They generally revise only one skill or one document at a time. For example, SkillAdaptor revises only the highest-weighted skill identified by its attribution mechanism [46], and SkillOpt and SkillAdam edit a single skill document [44, 17]. In practice, however, a task often involves several skills whose contents jointly guide the agent's behavior. Consequently, updating one artifact in isolation can leave erroneous or conflicting content elsewhere, allowing the original problem to persist or recur.

Our Work. In this work, we propose to evolve skills via trajectory-guided fault localization, which identifies the skill contents that require revision. The key idea is that before generating any revision, we explicitly determine the edit-sites, i.e., the skill contents that should be revised, and ground this decision in behavioral evidence from execution trajectories. This idea draws on program repair, where evidence from passing and failing tests guides the localization of suspicious code before candidate patches are generated [38, 36]. Analogously, we treat each agent execution on a task as a test execution and the actions in its trajectory as the entities covered by that execution. We localize through actions rather than treating skill contents directly as covered entities, because natural-language guidance lacks the explicit execution semantics of code. Specifically, an agent loads a skill document as a whole, and whether and how it follows each instruction is left to its own interpretation, thus there is no observable notion of which contents an execution exercises. In contrast, actions are directly observable in trajectories, differ across executions, and are shaped by the skill content. Therefore, a deficiency in a skill manifests as suspicious actions, and the trajectory records the guidance the agent consulted when taking them, allowing these actions to be traced back to the responsible skill content. By recording these actions, the edit sites derived from them, and the evidence behind both, the localization decisions become inspectable and can be reassessed when later executions reveal a persistent problem. An action also provides a common anchor for locating regions across multiple skills that jointly guide it, thus enabling coordinated revisions to those contents.

We realize this idea in SKILLMORPH. SKILLMORPH first abstracts raw trajectories into sequences of state transitions, making actions and their observed effects explicit units for inspection and comparison across executions. Using these abstractions, SKILLMORPH localizes edit sites in two stages before generating each revision. The first stage identifies suspicious actions, i.e., those more likely to reflect deficiencies in the skills than incidental agent behaviors. Our key insight is that reliable skill evolution requires both stability, by building on effective revisions across evolution loops to avoid recurring failures, and generality, by targeting deficiencies that persist across executions and tasks. Accordingly, SKILLMORPH progressively aggregates behavioral evidence across executions, evolution loops, and tasks. Specifically, it first compares repeated executions of the same task and contrasts how each action occurs in failing and passing executions, where an action that introduces an error that is later recovered from in a successful execution also counts as failure evidence. It then examines how the evidence changes across evolution loops to reveal whether earlier revisions took effect, and finally aggregates the evidence across tasks to prioritize problems shared by multiple tasks. The second stage maps each suspicious action to edit sites in the skills. Our observation here is that although a trajectory does not directly reveal which instructions the agent followed, it records the skills and files consulted, narrowing the search for guidance that may have shaped an action. Based on this, an LLM-based agent uses the action's execution context to progressively narrow the search from skills to files to specific skill content, and outputs the edit sites along with a rationale linking the skill content to the action. Finally, the edit sites, their localization rationale, and the supporting behavioral and historical evidence guide the generation of revision proposals, which are evaluated and consolidated into a patch that evolves the skill set.

Results. We evaluate SKILLMORPH on a repository-level software engineering skill benchmark SWE-Skills-Bench and a complex kernel-generation skill system CannBot. Compared with the original skills, SKILLMORPH achieves relative improvements of 15.84% in pass@3 and 30.03% in pass 3^{3} on SWE-Skills-Bench, and 16.67% and 100% on CannBot, respectively. SKILLMORPH also achieves better overall performance than the four compared skill-evolution methods. Moreover, in a deployment with our collaboration partner, SKILLMORPH produced six skill-revision pull requests that have been accepted for future AI operator development, further showing its practical value.

Summary. The main contributions of this paper are as follows:

• Approach. We propose SKILLMORPH, a skill-evolution approach based on trajectory-guided edit-site localization that links execution evidence to skill contents before generating revisions.

• Evaluation. We conduct an empirical study on two software engineering skill benchmarks, demonstrating the effectiveness of SKILLMORPH. In particular, SKILLMORPH has been deployed in an AI operator development team, further confirming its practicality.

References (43)