SKILL-DISCO: Distilling and Compiling Agent Traces into Reusable Procedural Skills

arXiv cs.AI Papers

Summary

Skill-DisCo is a framework that distills reusable procedural skills from successful agent traces and compiles them into callable, executable programs. Experiments on ALFWorld and WebArena show improved success rates and reduced agent turns.

arXiv:2606.26669v1 Announce Type: new Abstract: Agents often repeatedly solve similar task instances from scratch, leading to unnecessary reasoning cost and long execution traces. Prior work has explored workflow reuse and executable skill induction, but it remains unclear which task scenarios admit procedural skills and how the shared procedural structure should be represented across successful traces. We study this problem in FSM-defined scenarios, where successful traces can be viewed as paths in an unknown transition graph, and formulate procedural skills as reusable parameterized control-flow subgraphs. Based on this view, we introduce SkillDisCo, a distillation-and-compilation framework that distills reusable PFSM subgraphs from successful traces and compiles them into callable, executable, and verifiable procedural skills. Experiments on ALFWorld and WebArena show that SkillDisCo improves success rates and reduces agent turns across benchmarks and model scales, demonstrating the benefits of representing shared experience as reusable execution structures.
Original Article
View Cached Full Text

Cached at: 06/26/26, 05:15 AM

# Skill-DisCo: Distilling and Compiling Agent Traces into Reusable Procedural Skills
Source: [https://arxiv.org/html/2606.26669](https://arxiv.org/html/2606.26669)
Zhongxin Guo1Danrui Qi1Hanwen Gu2Peng Cheng1Yongqiang Xiong1 1Microsoft Research2Beijing Foreign Studies University \{zhongxin\.guo, danruiqi\}@microsoft\.com

###### Abstract

Agents often repeatedly solve similar task instances from scratch, leading to unnecessary reasoning cost and long execution traces\. Prior work has explored workflow reuse and executable skill induction, but it remains unclear which task scenarios admit procedural skills and how the shared procedural structure should be represented across successful traces\. We study this problem in FSM\-defined scenarios, where successful traces can be viewed as paths in an unknown transition graph, and formulate procedural skills as reusable parameterized control\-flow subgraphs\. Based on this view, we introduceSkill\-DisCo, adistillation\-and\-compilation framework that distills reusable PFSM subgraphs from successful traces and compiles them into callable, executable, and verifiable procedural skills\. Experiments on ALFWorld and WebArena show thatSkill\-DisCoimproves success rates and reduces agent turns across benchmarks and model scales, demonstrating the benefits of representing shared experience as reusable execution structures\.

Skill\-DisCo: Distilling and Compiling Agent Traces into Reusable Procedural Skills

Zhongxin Guo1Danrui Qi1Hanwen Gu2Peng Cheng1Yongqiang Xiong11Microsoft Research2Beijing Foreign Studies University\{zhongxin\.guo, danruiqi\}@microsoft\.com

## 1Introduction

AlfworldTracesEP 1goto d1open d1→\\rightarrowgoto d2open d2→⋯→\\rightarrow\\\!\\cdots\\\!\\rightarrowgoto bedtake book★\\bigstar→⋯\\rightarrow\\\!\\cdotsEP 2goto sh1goto sh2→⋯→\\rightarrow\\\!\\cdots\\\!\\rightarrowgoto d3open d3take mug★\\bigstargoto micopen micheat mug→⋯\\rightarrow\\\!\\cdots★\\bigstar: observed targetNL experienceabstracted task summaryPrior skill inductionmacro\-action templatesSkill\-DisCocompiled PFSM skills with environment adaptation“To heat an object, find the target, then*take*it and*heat*it in the microwave\.” e\.g\.gotol1l\_\{1\}→\\toopenl1l\_\{1\}→\\to⋯\\cdots→\\totakeoo→\\togoto mic→\\toheatoocheck\(l\)\(l\): goto\(l\)→\(l\)\\\!\\rightarrow\\\!open\(l\)\(l\) heat\(o,mic\)\(o,\\mathrm\{mic\}\): goto\(mic\)→\(\\mathrm\{mic\}\)\\\!\\rightarrow\\\!open\(mic\)→\(\\mathrm\{mic\}\)\\\!\\rightarrow\\\!heat\(o\)\(o\)StartS1S2S3Endgo\_to\(ll\)if open valid:open\(ll\)ifoofound:take\(oo\)ifoonot found: go\_to\(nextll\)search\(\[locs\], obj\)StartS1S2S3Endgo\_to\(mic\)if open valid:open\(mic\)heat\(oo\)if already open: skipheat\(obj, mic\)can abstract, no guaranteefixed templates, non\-adaptiveexecutable programs, adaptive to environment

Figure 1:Skill\-DisCodistills environment\-adaptive PFSM skills that branch on observations, transfer across episodes and model scales without re\-induction\.LLM agents are increasingly used for interactive tasks that require many reasoning and acting steps\(Yao et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib19); Shinn et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib10); Wang et al\.,[2024b](https://arxiv.org/html/2606.26669#bib.bib14); Yang et al\.,[2024](https://arxiv.org/html/2606.26669#bib.bib18)\)\. Yet even with stronger action representations such as CodeAct\(Wang et al\.,[2024b](https://arxiv.org/html/2606.26669#bib.bib14)\), agents often solve each task independently, repeatedly rediscovering low\-level action patterns shared across related tasks \(Figure[1](https://arxiv.org/html/2606.26669#S1.F1)\)\. This increases reasoning cost, execution length, and generalization brittleness\(Wang et al\.,[2024c](https://arxiv.org/html/2606.26669#bib.bib16),[2025](https://arxiv.org/html/2606.26669#bib.bib15)\)\. Recent work on experience reuse addresses this issue by extracting reusable workflows from trajectories\(Wang et al\.,[2024c](https://arxiv.org/html/2606.26669#bib.bib16)\)or inducing executable skills that improve verifiability and composability\(Wang et al\.,[2025](https://arxiv.org/html/2606.26669#bib.bib15)\)\. These results suggest that agents should accumulate reusable procedures rather than solve each task from scratch\.

However, the foundations of procedural skill discovery remain under\-specified\. Reusable skills are meaningful when tasks share stable execution patterns, but become ill\-defined for open\-ended, instance\-specific generation\. Existing methods often synthesize skills directly from successful traces using LLMs\. Without an explicit notion of shared structure, the resulting libraries can become fragmented and redundant toward trace\-specific surface patterns rather than reusable procedural logic\.

We make the scope of procedural skill discovery explicit by focusing on*FSM\-defined scenarios*, where execution dynamics are described by finite states, admissible actions, and deterministic transitions\. In such scenarios, successful traces are paths in an unknown transition graph, and procedural skills correspond to repeated transition structures that help reach goal states\. If this graph were known, task completion would reduce to graph search\. In realistic agent settings, however, the graph is unavailable, and the agent only observes successful traces\.

To capture shared structure across traces, we formalize procedural skills through a*Parameterized Finite\-State Machine*\(PFSM\) view\. A PFSM abstracts concrete states and actions into parameterized states and operators, so traces with different objects, states, or lengths can instantiate the same execution pattern\. Under this view, each successful trace can be lifted into a parameterized trace graph, and a procedural skill is a reusable PFSM subgraph matched across traces under parameter binding\. Thus, a skill is not merely a textual routine or an LLM\-generated script, but a structurally grounded abstraction of shared execution logic\.

This formulation does not assume that the latent PFSM is directly observable\. In realistic agent environments, neither the full transition graph nor the lifting function from raw traces to PFSM subgraphs is given\.Skill\-DisCotherefore approximates PFSM\-based skill discovery by recovering reusable parameterized control\-flow patterns from successful traces and validating them through skill compilation\. This yields a distillation\-and\-compilation framework\. Distillation discovers compact, high\-coverage PFSM subgraphs that favor reusable structures over trace\-specific routines\. Compilation turns each discovered structure into a callable, executable, and verifiable skill through explicit specification and execution\-grounded verification\.

Our contributions are as follows:

\(C1\)We make explicit the scope of procedural skill discovery by focusing on FSM\-defined scenarios, where successful traces are paths in an unknown transition graph and reusable skills have well\-defined transition semantics\.

\(C2\)We formulate procedural skills as reusable parameterized control\-flow subgraphs that can match multiple successful traces under parameter binding\. This provides structural targets for skill discovery, rather than treating each successful trace as an independent routine\.

\(C3\)We introduceSkill\-DisCo, a distillation\-and\-compilation framework that approximates these structural targets and compiles them into verified and executable procedural skills\.

\(C4\)Extensive experiments show thatSkill\-DisCoimproves both success rate and efficiency across different benchmarks and model scales\. Further analysis shows that compact compiled skills reduce library redundancy, improve execution reliability, and transfer procedural knowledge from stronger induction models to smaller execution models\.

## 2Preliminaries

### 2\.1FSM\-Defined Scenarios

In this paper, we focus on scenarios whose execution dynamics can be formulated as finite\-state machines\. Such scenarios have a finite state space, a finite action space, and deterministic transitions: given a states∈𝒮s\\in\\mathcal\{S\}and an actiona∈𝒜a\\in\\mathcal\{A\}, the next state is uniquely determined byδ​\(s,a\)\\delta\(s,a\)\. We refer to such scenarios asFSM\-defined scenarios\.

###### Definition 1\(FSM\-Defined Scenario\)

A scenario is called an FSM\-defined scenario if its execution dynamics can be represented as a finite\-state machine

ℳ=\(𝒮,𝒜,δ,𝒮0,𝒮goal\),\\mathcal\{M\}=\(\\mathcal\{S\},\\mathcal\{A\},\\delta,\\mathcal\{S\}\_\{0\},\\mathcal\{S\}\_\{\\mathrm\{goal\}\}\),where𝒮\\mathcal\{S\}is a finite set of states,𝒜\\mathcal\{A\}is a finite set of actions,δ:𝒮×𝒜→𝒮\\delta:\\mathcal\{S\}\\times\\mathcal\{A\}\\rightarrow\\mathcal\{S\}is a deterministic transition function,𝒮0⊆𝒮\\mathcal\{S\}\_\{0\}\\subseteq\\mathcal\{S\}is the set of possible initial states, and𝒮goal⊆𝒮\\mathcal\{S\}\_\{\\mathrm\{goal\}\}\\subseteq\\mathcal\{S\}is the set of goal states\. The corresponding transition graph is defined asG∗=\(V∗,E∗\)G^\{\*\}=\(V^\{\*\},E^\{\*\}\), whereV∗=𝒮V^\{\*\}=\\mathcal\{S\}andE∗=\{\(s,a,s′\)∣s,s′∈𝒮,a∈𝒜,δ​\(s,a\)=s′\}\.E^\{\*\}=\\\{\(s,a,s^\{\\prime\}\)\\mid s,s^\{\\prime\}\\in\\mathcal\{S\},a\\in\\mathcal\{A\},\\delta\(s,a\)=s^\{\\prime\}\\\}\.

For an FSM\-defined scenario, if the complete transition graphG∗G^\{\*\}and the goal states are known, task completion can be reduced to finding a path from an initial state to a goal state onG∗G^\{\*\}\. However, the complete transition graph is unavailable in many agent settings\. Thus, we aim to infer reusable transition structures from past successful traces\.

###### Definition 2\(Primitive Operator\)

A primitive operator is a tuple

o​p=\(𝒳,𝒴,Pre,Post\),op=\(\\mathcal\{X\},\\mathcal\{Y\},\\mathrm\{Pre\},\\mathrm\{Post\}\),, where𝒳\\mathcal\{X\}is the input space,𝒴\\mathcal\{Y\}is the output space,Pre:𝒳→\{0,1\}\\mathrm\{Pre\}:\\mathcal\{X\}\\rightarrow\\\{0,1\\\}is a pre\-condition predicate, andPost:𝒳×𝒴→\{0,1\}\\mathrm\{Post\}:\\mathcal\{X\}\\times\\mathcal\{Y\}\\rightarrow\\\{0,1\\\}is a post\-evaluation predicate\. For any inputx∈𝒳x\\in\\mathcal\{X\}satisfyingPre​\(x\)=1\\mathrm\{Pre\}\(x\)=1, executingo​popproduces a unique outputy=o​p​\(x\)∈𝒴y=op\(x\)\\in\\mathcal\{Y\}such thatPost​\(x,y\)=1\.\\mathrm\{Post\}\(x,y\)=1\.

###### Definition 3\(Successful Trace\)

Given an FSM\-defined scenarioℳ=\(𝒮,𝒜,δ,𝒮0,𝒮goal\)\\mathcal\{M\}=\(\\mathcal\{S\},\\mathcal\{A\},\\delta,\\mathcal\{S\}\_\{0\},\\mathcal\{S\}\_\{\\mathrm\{goal\}\}\), an agent trace is a finite execution recordτ=\(o0,a0,o1,a1,…,aT−1,oT\)\\tau=\(o\_\{0\},a\_\{0\},o\_\{1\},a\_\{1\},\\ldots,a\_\{T\-1\},o\_\{T\}\), whereoto\_\{t\}denotes the observation received by the agent at stepttandat∈𝒜a\_\{t\}\\in\\mathcal\{A\}is the action executed by the agent\.

The trace is induced by an underlying state trajectory\(s0,a0,s1,a1,…,aT−1,sT\),\(s\_\{0\},a\_\{0\},s\_\{1\},a\_\{1\},\\ldots,a\_\{T\-1\},s\_\{T\}\),such thatst\+1=δ​\(st,at\),s\_\{t\+1\}=\\delta\(s\_\{t\},a\_\{t\}\),and each observationoto\_\{t\}is generated from the underlying statests\_\{t\}\. We callτ\\taua successful agent trace if the underlying execution starts from a valid initial state and reaches a goal state, i\.e\.s0∈𝒮0s\_\{0\}\\in\\mathcal\{S\}\_\{0\}andsT∈𝒮goal\.s\_\{T\}\\in\\mathcal\{S\}\_\{\\mathrm\{goal\}\}\.

Note that every actiona∈𝒜a\\in\\mathcal\{A\}in an FSM\-defined scenario is treated as aPrimitive Operator, i\.e\. actions in aSuccessful Traceare all primitive operators\. For clarity, we will simply refer to such primitive operators as actions throughout the paper\.

### 2\.2PFSM\-Based Procedural Skill Discovery

A standard FSM represents task completion as a concrete path from an initial state to a goal state\. Such a path precisely records one execution, but is often too instance\-specific because each transition is grounded in concrete states and actions\. As a result, executions with the same control logic may appear as different paths when they involve different objects, locations, or intermediate states\.

To capture reusable execution patterns, we introduce the notion of aParameterized Finite State Machine\(PFSM\)\. A PFSM abstracts concrete states and actions with parameters, allowing multiple concrete FSM paths to be represented by the same parameterized control\-flow structure\.

###### Definition 4\(Parameterized FSM \(PFSM\)\)

A Parameterized Finite State Machine is defined as

ℳ~=\(𝒮~,𝒜~,Θ,δ~,𝒮~0,𝒮~goal\),\\widetilde\{\\mathcal\{M\}\}=\(\\widetilde\{\\mathcal\{S\}\},\\widetilde\{\\mathcal\{A\}\},\\Theta,\\widetilde\{\\delta\},\\widetilde\{\\mathcal\{S\}\}\_\{0\},\\widetilde\{\\mathcal\{S\}\}\_\{\\mathrm\{goal\}\}\),where𝒮~\\widetilde\{\\mathcal\{S\}\}is a finite set of parameterized states,𝒜~\\widetilde\{\\mathcal\{A\}\}is a finite set of parameterized actions,Θ\\Thetais the parameter space, andδ~:𝒮~×𝒜~×Θ→𝒮~\\widetilde\{\\delta\}:\\widetilde\{\\mathcal\{S\}\}\\times\\widetilde\{\\mathcal\{A\}\}\\times\\Theta\\rightarrow\\widetilde\{\\mathcal\{S\}\}is a deterministic parameterized transition function\. Each parameter assignmentθ∈Θ\\theta\\in\\Thetainstantiates a parameterized transition into a concrete FSM transition\. Here, a parameterized states~∈𝒮~\\tilde\{s\}\\in\\widetilde\{\\mathcal\{S\}\}represents an abstract execution state rather than a fully grounded environment state\. A parameterized actiona~∈𝒜~\\tilde\{a\}\\in\\widetilde\{\\mathcal\{A\}\}represents an action schema whose arguments are instantiated by parameters\.

#### Example 1\.

Consider two successful traces for finding and taking a target object:

τ1\\tau\_\{1\}:go\_to\(drawer1\)→\\rightarrowopen\(drawer1\)→\\rightarrowgo\_to\(drawer2\)→\\rightarrowopen\(drawer2\)→\\rightarrowgo\_to\(desk1\)→\\rightarrowgo\_to\(bed\)→\\rightarrowtake\(book\)→\\rightarrowend\.

τ2\\tau\_\{2\}:go\_to\(shelf1\)→\\rightarrowgo\_to\(shelf2\)→\\rightarrowgo\_to\(drawer1\)→\\rightarrowopen\(drawer1\)→\\rightarrowgo\_to\(drawer2\)→\\rightarrowopen\(drawer2\)→\\rightarrowtake\(mug\)→\\rightarrowend\.

In a standard FSM, these two traces correspond to different concrete paths, because they visit different numbers of locations\. However, they share the same parameterized control\-flow pattern:

This pattern can be represented as a PFSM with parameterized actions such asgo\_to​\(l\)\\texttt\{go\\\_to\}\(l\)andtake​\(o\)\\texttt\{take\}\(o\), wherellis a location parameter andoois an object parameter\. The loop over candidate locations abstracts away the number and identity of concrete locations, while preserving the reusable control logic needed to complete the task\.

Given a set of successful traces, each trace can be lifted from a concrete FSM path to a subgraph of the PFSM transition graph\. Such a subgraph captures the parameterized execution structure of a successful trace, including its abstract states, parameterized actions, and control\-flow relations\. We refer to this lifted subgraph as aparameterized trace graph\. Since the underlying PFSM is unavailable, the lifting functionϕ:τi↦G~i\\phi:\\tau\_\{i\}\\mapsto\\widetilde\{G\}\_\{i\}does not admit a closed\-form definition\. We approximate it via a multi\-stage pipeline described in Section[3](https://arxiv.org/html/2606.26669#S3)\.

Our goal is to discover procedural skills from successful traces\. Intuitively, a procedural skill corresponds to a PFSM subgraph that is shared by many successful traces\. Such a subgraph captures a recurring control\-flow structure that helps the agent reach a goal across different concrete instantiations\.

###### Problem 1\(Procedural Skill Discovery\)

Given a set of successful traces𝒯\+=\{τ1,τ2,…,τN\}\\mathcal\{T\}^\{\+\}=\\\{\\tau\_\{1\},\\tau\_\{2\},\\ldots,\\tau\_\{N\}\\\}and a lifting functionϕ:τi↦G~i\\phi:\\tau\_\{i\}\\mapsto\\widetilde\{G\}\_\{i\}that maps each trace to a parameterized trace graph, the goal is to discover a set of procedural skills𝒦=\{K1,K2,…,Km\}\\mathcal\{K\}=\\\{K\_\{1\},K\_\{2\},\\ldots,K\_\{m\}\\\}, where each skillKjK\_\{j\}is a parameterized control\-flow subgraph that matches a subset of\{G~i\}i=1N\\\{\\widetilde\{G\}\_\{i\}\\\}\_\{i=1\}^\{N\}under parameter binding, i\.e\.Kj⪯G~iK\_\{j\}\\preceq\\widetilde\{G\}\_\{i\}foriiin some index set\.

Intuitively, a desirable skill set𝒦\\mathcal\{K\}should satisfy three properties:\(i\) Coverage, where each skill is supported by multiple successful traces rather than a single execution,\(ii\) Utility, where skills capture control\-flow structures that help reach goal states, and\(iii\) Compactness, where skills are neither overly specific nor trivially generic\. In realistic agent settings, neither the full PFSMℳ~\\widetilde\{\\mathcal\{M\}\}nor the lifting functionϕ\\phiis analytically available\.Skill\-DisCoapproximates both from successful traces through the pipeline in Section[3](https://arxiv.org/html/2606.26669#S3)\.

## 3TheSkill\-DisCoFramework

Section[2](https://arxiv.org/html/2606.26669#S2)formulates procedural skill discovery as identifying reusable PFSM subgraphs from successful agent traces\. Solving this problem directly is challenging because the complete PFSMℳ~\\widetilde\{\\mathcal\{M\}\}is unavailable, the lifting functionϕ\\phifrom raw traces to parameterized trace graphs must be inferred, and exact subgraph matching under parameter binding is costly and noise\-sensitive\. To address these challenges,Skill\-DisCodiscovers procedural skills through distillation and compilation\.

### 3\.1Framework Overview

Figure[2](https://arxiv.org/html/2606.26669#S3.F2)shows an overview of theSkill\-DisCoframework\. The input toSkill\-DisCois a set of successful traces𝒯\+=\{τ1,τ2,…,τN\}\\mathcal\{T\}^\{\+\}=\\\{\\tau\_\{1\},\\tau\_\{2\},\\ldots,\\tau\_\{N\}\\\}, whereNNdenotes the number of successful traces\. The output is a skill library𝒦=\{K1,K2,…,Km\}\\mathcal\{K\}=\\\{K\_\{1\},K\_\{2\},\\ldots,K\_\{m\}\\\}, which contains themmprocedural skills\.

Skill\-DisCocontains two phases\. The distillation phase approximates the latent lifting function from traces to reusable PFSM subgraphs\. It first normalizes each raw trace into an executable intermediate program, then segments the program into subgoal\-level operations, and finally clusters fragments that share parameterized control\-flow structure\. Each cluster is treated as an approximate PFSM subgraph and becomes a skill candidate\.

The compilation phase turns each candidate structure into an executable artifact\. It first constructs a skill specification with a signature, description, behavioral requirements, and metadata\. It then synthesizes Python code and verifies it on held\-out tasks; only skills that pass verification are included in the final callable library\.

SuccessfulTracesTrace NormalizationSSS1S\_\{1\}S2S\_\{2\}S3S\_\{3\}S4S\_\{4\}S5S\_\{5\}S6S\_\{6\}S7S\_\{7\}S8S\_\{8\}EE1Operation ExtractionOp1SSS1S\_\{1\}S2S\_\{2\}S3S\_\{3\}EEOp2SSS5S\_\{5\}S6S\_\{6\}S7S\_\{7\}S8S\_\{8\}EE2Procedural Skill ConsolidationSSS1S\_\{1\}S2S\_\{2\}S3S\_\{3\}EESSS1S\_\{1\}S2S\_\{2\}SnS\_\{n\}S3S\_\{3\}EESSS1S\_\{1\}S2S\_\{2\}SnS\_\{n\}S3S\_\{3\}EE3DistillationSkill SpecificationNameDescPreParamskill\_spec\.json4Synthesis & Verification5![Refer to caption](https://arxiv.org/html/2606.26669v1/figs/synthesis.png)![Refer to caption](https://arxiv.org/html/2606.26669v1/figs/check.png)![Refer to caption](https://arxiv.org/html/2606.26669v1/figs/prune.png)VerifyCompilation![Refer to caption](https://arxiv.org/html/2606.26669v1/figs/toolbox.png)SkillLibrary

Figure 2:Overview ofSkill\-DisCo\.*Distillation*phase turns successful traces into reusable PFSM subgraphs;*Compilation*phase converts them into executable and verified skills\.
### 3\.2The Distillation Phase

The distillation phase consists of three stages that jointly approximate the latent lifting functionϕ:τi↦G~i\\phi:\\tau\_\{i\}\\mapsto\\widetilde\{G\}\_\{i\}and discover reusable PFSM subgraphs from successful traces\. As described in Section[2](https://arxiv.org/html/2606.26669#S2), each raw execution trace is first abstracted into a concrete trace graph over the FSM\. This concrete trace graph is then lifted into a PFSM graph, where repeated action patterns are represented as parameterized, code\-like control\-flow structures with branches\. Finally, reusable subgraphs are identified from the resulting PFSM graphs and extracted as procedural skills\. Therefore, the lifting functionϕ\\phiis not implemented as a single monolithic step\. Instead, it is decomposed into three successive transformations, each corresponding to one stage of the distillation phase\.

Stage 1: Trace Normalization\.Trace normalization converts each successful raw trace into a structured, executable intermediate representation\. Raw agent logs interleave reasoning text, tool calls, observations, and action histories, but do not expose the control\-flow structure needed for PFSM\-based skill discovery\.Skill\-DisCotherefore normalizes each trace into a programpip\_\{i\}that preserves primitive operators and observations while making loops, branches, and parameterized entities explicit\.

Each normalized program has three components: primitive environment calls paired with observations, symbolic variables for task\-specific entities such as objects or web elements, and code\-level control flow for repeated action patterns and observation\-conditioned decisions\. For example, a trace that visits candidate locations until an object is found can become a loop whose guard depends on the current observation\.

In our implementation, an LLM extracts all executed actions and observations, preserves their order, replaces concrete entities with typed variables when possible, and emits a Python\-like program\. This program is not the final skill; it is an intermediate representation from which reusable subgoal\-level operations are extracted\.

Stage 2: Subgoal\-level Operation Extraction\.The goal of Stage 2 is to decompose each normalized program into subgoal\-level operations that can serve as candidate procedural skills\. A complete trace often contains multiple reusable parts\. For example, a single household task may include searching for an object, retrieving it, navigating to an appliance, and applying the appliance\. Treating the whole trace as one skill would make the induced routine too specific, while treating each primitive operator as a skill would lose the benefit of procedural reuse\.Skill\-DisCotherefore extracts intermediate\-granularity operators that correspond to coherent subgoals\.

Given a normalized programpip\_\{i\}, the operator extractor emits𝒪i=\{o1\(i\),…,omi\(i\)\},\\mathcal\{O\}\_\{i\}=\\\{o^\{\(i\)\}\_\{1\},\\ldots,o^\{\(i\)\}\_\{m\_\{i\}\}\\\},where each operator is represented aso=\(ν,σ,𝐮,c\)\.o=\(\\nu,\\sigma,\\mathbf\{u\},c\)\.Here,ν\\nuis an action\-oriented identifier,σ\\sigmais a natural\-language summary,𝐮=\(u1,…,u\|o\|\)\\mathbf\{u\}=\(u\_\{1\},\\ldots,u\_\{\|o\|\}\)is the primitive operator sequence, andccis the corresponding code fragment\. We discard unit\-length fragments with\|o\|=1\|o\|=1, since they correspond to primitive operators rather than reusable procedural structure\. The remaining multi\-step operators are collected as𝒪multi=⋃i\{o∈𝒪i:\|o\|≥2\}\.\\mathcal\{O\}\_\{\\mathrm\{multi\}\}=\\bigcup\_\{i\}\\\{o\\in\\mathcal\{O\}\_\{i\}:\|o\|\\geq 2\\\}\.

Stage 3: Procedural Skill Consolidation\.Stage 3 consolidates procedural skills by clustering subgoal\-level operations that approximate the same reusable PFSM subgraph\. Intuitively, a useful procedural skill should be supported by multiple successful traces, rather than being an incidental pattern that appears in only one execution\.

InSkill\-DisCo, subgoal\-level operations are grouped together when they share the same underlying parameterized execution structure, even if their concrete objects, locations, or action lengths differ\. For example, the two traces in Example 1 differ in their concrete locations, objects, and path lengths, but share the same parameterized search\-and\-take control flow\.

Each cluster approximates a reusable PFSM subgraph and receives a reusability score:

rk≈1N​∑i=1N𝕀​\[Kk⪯G~i\],r\_\{k\}\\approx\\frac\{1\}\{N\}\\sum\_\{i=1\}^\{N\}\\mathbb\{I\}\[K\_\{k\}\\preceq\\widetilde\{G\}\_\{i\}\],whereKk⪯G~iK\_\{k\}\\preceq\\widetilde\{G\}\_\{i\}indicates that the PFSM subgraph approximated by clusterckc\_\{k\}can be matched to the lifted trace graphG~i\\widetilde\{G\}\_\{i\}under some parameter binding\. The score is estimated from trace coverage and operation statistics\. For each high\-coverage cluster,Skill\-DisCoabstracts the shared subgoal\-level operation as a procedural skill\.

### 3\.3The Compilation Phase

The distillation phase abstracts high\-coverage clusters into procedural skills representing reusable PFSM subgraphs\. However, a PFSM subgraph is only a structural artifact, i\.e\. it does not define a callable interface, runtime grounding rules, return protocol, or failure handling\. The compilation phase turns each procedural skill into a callable, executable, and verifiable version\. InSkill\-DisCo, the compilation phase consists of two stages:skill specificationandskill synthesis and verification\.

Stage 4: Skill Specification\.Stage 4 augments discovered procedural skills with explicit specifications\. For each skill abstracted from a high\-coverage cluster,Skill\-DisCocreates a skill definition that captures how the skill should be invoked and what behavior it should satisfy before any concrete implementation is generated\. Each skill definition contains: \(i\) a*signature*, including an action\-oriented skill name, typed parameters with default values, and a structured return type \(ii\) a*description*, serving as both a machine\-readable docstring and LLM\-facing guidance \(iii\)*behavioral requirements*, including preconditions, postconditions, and declared side effects and \(iv\)*metadata*, including the skill abstraction level, expected primitive actions amortized per invocation, and a confidence score inherited fromrkr\_\{k\}\.

The explicit specification guides implementation synthesis and provides concrete criteria for verification, while giving the deployed agent a domain\-agnostic vocabulary for selecting skills during task execution\.

Stage 5: Synthesis and Verification\.Stage 5 turns each skill specification into a verified executable skill through a synthesis and verification loop\. Given a skill definition,Skill\-DisCofirst synthesizes a Python program that realizes the specified behavior using the primitive actions\. During execution,fkf\_\{k\}interacts with the workload environment and returns a structured output that provides execution information to the caller\.

On a held\-out set, verification checks runtime correctness, postcondition satisfaction, and action savings\. Skills that fail are re\-synthesized with feedback for up toRRretries; any remaining failures are discarded\.

The result is a verified executable skill library: each skill exposes a documented signature that agents can inspect, select, and call during task execution\.

## 4Experiments

We evaluate whetherSkill\-DisCocan distill reusable procedural skills from successful traces and deploy them as reliable skills for interactive agents\. Our experiments are organized around four questions:RQ1\.DoesSkill\-DisCoimprove end\-to\-end task success rate and turn efficiency compared with base agents and prior skill\-induction methods? \(§[4\.2](https://arxiv.org/html/2606.26669#S4.SS2)\)RQ2\.Do the procedural skills transfer across model families, scales, and reasoning modes? \(§[4\.3](https://arxiv.org/html/2606.26669#S4.SS3)\)RQ3\.How are the learned skills invoked and executed at inference time? \(§[4\.4](https://arxiv.org/html/2606.26669#S4.SS4)\)RQ4\.Do all components ofSkill\-DisCocontribute to the observed gains? \(§[4\.5](https://arxiv.org/html/2606.26669#S4.SS5)\)

### 4\.1Experimental Setup

Datasets\.We evaluate on two interactive agent datasets with different execution structures:\(1\) ALFWorld\(Shridhar et al\.,[2021](https://arxiv.org/html/2606.26669#bib.bib11)\)consists of text\-based household tasks that require navigation, search, and object manipulation\.\(2\) WebArena\(Zhou et al\.,[2024](https://arxiv.org/html/2606.26669#bib.bib23)\)consists of realistic web\-navigation tasks over self\-hosted websites\.

Splits\.For each dataset, we use a strict*induction/evaluation*split: skills are derived only from the induction split and evaluated only on held\-out tasks\. ForALFWorld, the induction split consists of 200 tasks sampled from the officialtrainset, and the evaluation split is the official unseen split with 134 tasks\. For WebArena, which has no canonical induction split, we split the 812 tasks in half: the first 406 tasks for induction and the remaining 406 for evaluation\. All baselines use the same splits asSkill\-DisCo\.

Baselines\.We compare against two categories of baselines\. The first category contains base agents without skill augmentation: ReAct\(Yao et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib19)\)using the AgentBench implementation\(Liu et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib5)\), and CodeAct\(Wang et al\.,[2024b](https://arxiv.org/html/2606.26669#bib.bib14)\)\. The second group consists of offline workflow\- and skill\-induction methods: AWMoffline\(Wang et al\.,[2024c](https://arxiv.org/html/2606.26669#bib.bib16)\)and the offline variant of ASI, ASIoffline\(Wang et al\.,[2025](https://arxiv.org/html/2606.26669#bib.bib15)\)\. For all skill\-augmented variants, each skill’s signature and description are appended in agents’ prompts to instruct LLMs to decide whether and how to invoke a skill or emit a primitive action\.

Metrics\.We report*success rate*\(SR\) and*average agent turns*\(Avg\. Turns\) per episode\. Full per\-episode token usage and inference cost are reported in Appendix[A\.3](https://arxiv.org/html/2606.26669#A1.SS3)\.

### 4\.2End\-to\-End Performance

We first evaluate whetherSkill\-DisCoimproves complete task execution when added to existing interactive agents\. Table[1](https://arxiv.org/html/2606.26669#S4.T1)comparesSkill\-DisCowith base agents and prior offline skill\-induction methods using GPT\-4o\.Skill\-DisCoalso uses GPT\-4o to induce the skill library\.

Table 1:End\-to\-end results on ALFWorld and WebArena\. Parentheses show relative changes over the base agent;boldmarks the best result andunderliningmarks the second\-best\.Higher task success rate\.Skill\-DisCoachieves the highest SR on all benchmarks under our evaluation setting\. OnALFWorld,Skill\-DisCo\+\+CodeAct improves over the strong CodeAct from 96\.3% to 99\.3%\. On WebArena,Skill\-DisCo\+\+ReAct improves ReAct from 23\.9% to 29\.1%, outperforming ASIofflineby 4\.5 absolute points\. Since all offline skill\-induction methods use the same induction and evaluation splits, these gains reflect the quality of the induced skills bySkill\-DisCo\.

Consistent reduction in agent turns\.Skill\-DisCoalso reduces average turns across all settings:−54\.5%\-54\.5\\%/−11\.3%\-11\.3\\%\(ReAct/CodeAct\) onALFWorldand−13\.1%\-13\.1\\%/−22\.0%\-22\.0\\%on WebArena\. By delegating repeated low\-level action sequences to the reliable procedural skills, agents solve each task with fewer decisions\.

Complementary to different agents\.Table[1](https://arxiv.org/html/2606.26669#S4.T1)shows that the same library improves both ReAct \(natural\-language reasoning\) and CodeAct \(code\-emitting\) across all benchmarks, indicating thatSkill\-DisCoacts as an agent\-agnostic augmentation layer by providing reusable procedural skills, rather than being tied to a specific agent\.

Table 2:Skill transfer across target models on ALFWorld and WebArena\.Δ\\Deltadenotes relative change over the vanilla setting;boldmarks the best result\.SR \(%\)↑\\uparrowAvg\. Turns↓\\downarrowModelVan\.\+Sk\. \(Δ\\Delta\)Van\.\+Sk\. \(Δ\\Delta\)\(a\) ALFWorldQwen3\.5\-4B61\.291\.0 \(\+48\.8%\+48\.8\\%\)9\.05\.0 \(−44\.4%\-44\.4\\%\)Qwen3\.5\-9B54\.598\.5 \(\+80\.8%\+80\.8\\%\)10\.83\.4 \(−68\.2%\-68\.2\\%\)GPT\-4o96\.399\.3\(\+3\.1%\+3\.1\\%\)3\.63\.2 \(−11\.3%\-11\.3\\%\)GPT\-4o\-mini71\.694\.8 \(\+32\.3%\+32\.3\\%\)7\.14\.4 \(−38\.0%\-38\.0\\%\)GPT\-5\-chat91\.098\.5 \(\+8\.2%\+8\.2\\%\)4\.73\.0\(−34\.6%\-34\.6\\%\)GPT\-5\-mini91\.898\.5 \(\+7\.3%\+7\.3\\%\)4\.93\.3 \(−33\.3%\-33\.3\\%\)\(b\) WebArenaQwen3\.5\-4B10\.118\.7 \(\+85\.3%\+85\.3\\%\)8\.66\.8 \(−20\.4%\-20\.4\\%\)Qwen3\.5\-9B21\.223\.9 \(\+12\.8%\+12\.8\\%\)6\.86\.0 \(−12\.0%\-12\.0\\%\)GPT\-4o23\.929\.1 \(\+21\.6%\+21\.6\\%\)5\.95\.1 \(−13\.1%\-13\.1\\%\)GPT\-4o\-mini18\.018\.0 \(±0\.0%\\pm 0\.0\\%\)7\.77\.1 \(−7\.7%\-7\.7\\%\)GPT\-5\-chat32\.537\.0\(\+13\.7%\+13\.7\\%\)5\.34\.8\(−8\.6%\-8\.6\\%\)GPT\-5\-mini32\.533\.7 \(\+3\.8%\+3\.8\\%\)5\.44\.8 \(−10\.1%\-10\.1\\%\)Table 3:Skill\-usage statistics\. \#Sk is the number of induced skills; Turns and Sk\. turns are average total and skill\-invoking turns; Avg\./Max prim\. steps are primitive steps collapsed per skill call; Err\. is execution\-error rate\.
### 4\.3Cross\-Model Skill Transferability

We next test whether the skill library induced bySkill\-DisCowith GPT\-4o can transfer to other models\. We deploy the same skill library*without modification*across multiple target models: Qwen3\.5\-4B, Qwen3\.5\-9B, GPT\-4o, GPT\-4o\-mini, GPT\-5\-chat, and GPT\-5\-mini\. Based on Table[1](https://arxiv.org/html/2606.26669#S4.T1), we use the skill library induced from the strongerSkill\-DisCoconfiguration on each benchmark: CodeAct forALFWorldand ReAct forWebArena\.

Skills transfer across target models\.With the same skill library, every target model benefits: average turns drop in every cell \(−7\.7%\-7\.7\\%to−68\.2%\-68\.2\\%\), while SR improves by\+3\.1%\+3\.1\\%to\+80\.8%\+80\.8\\%onALFWorldand by up to\+85\.3%\+85\.3\\%on WebArena with no decreases\. These results show that the induced skills are robust across model families and scales\.

Weaker models can benefit substantially from skill transfer\.Although gains are not strictly monotone in capacity, the largest jumps occur on the smaller open\-source backbones: Qwen3\.5\-9B gains\+80\.8%\+80\.8\\%onALFWorldand Qwen3\.5\-4B gains\+85\.3%\+85\.3\\%on WebArena, versus only\+3\.1%\+3\.1\\%–\+7\.3%\+7\.3\\%for GPT\-4o/GPT\-5\-mini\. Strikingly, Qwen3\.5\-9B with the GPT\-4o\-induced library reaches 98\.5% onALFWorld, surpassing its inducer \(96\.3%\) at a fraction of the cost\. This shows thatSkill\-DisCoserves as a form of*procedural\-knowledge distillation and transfer*, allowing smaller models to benefit from skills compiled by a stronger inducer\.

### 4\.4Skill Usage and Execution Reliability

We analyze how much of an episode the agent delegates to its skill library and how reliably those skill calls execute\. Following the settings in Table[1](https://arxiv.org/html/2606.26669#S4.T1)\(CodeAct onALFWorldand ReAct on WebArena\), we report aggregate skill\-usage statistics in Table[3](https://arxiv.org/html/2606.26669#S4.T3)and compareSkill\-DisCowith ASIoffline\.

Skill\-DisColearns compact, high\-coverage skills\.Skill\-DisCouses far fewer skills than ASI \(5 vs\. 110 onALFWorld; 20 vs\. 146 onWebArena\) while each call covers more prim\. steps \(5\.6 vs\. 0\.2 onALFWorld; 2\.8 vs\. 2\.5 onWebArena\) and larger maximum step compression \(33/36 vs\. 10/8\)\. Thus,Skill\-DisCodistills compact skills that encode reusable procedures rather than shallow fragments\.

Verified skills execute more reliably\.Skill\-DisComakes skill calls less error\-prone, reducing execution errors from 75\.3% to 0\.0% onALFWorldand from 33\.9% to 21\.5% onWebArena\. Thus, its gains come not only from invoking skills, but from invoking skills that execute reliably; together with higher step compression, this explains the SR and turn improvements in Table[1](https://arxiv.org/html/2606.26669#S4.T1)\.

### 4\.5Ablation Study

We evaluate the contribution of the two main phases ofSkill\-DisCo, distillation and compilation, through ablations on ALFWorld using CodeAct with GPT\-4o \(Table[4](https://arxiv.org/html/2606.26669#S4.T4)\)\.

Table 4:Pipeline ablations\. \#Sk = skill library size; Relative SRΔ\\Deltavs\. the full pipeline in parentheses\.Distillation is the main driver of success\.Removing distillation and inducing skills per successful trace yields a larger 43\-skill library but reduces SR from 99\.3% to 53\.0% and increases turns from 3\.2 to 11\.5\. Without cross\-trace consolidation the library is dominated by overlapping, trace\-specific variants, making skill selection harder and causing wrong\-variant invocations or fallback to long open\-loop executions\.

Compilation mainly improves execution compactness\.Removing compilation and shipping the output of Stage 3 as natural\-language procedure descriptions only modestly reduces SR \(99\.3→97\.0%99\.3\\\!\\to\\\!97\.0\\%\), but each episode must keep the full procedure text in context, inflating tokens \(Appendix[A\.3](https://arxiv.org/html/2606.26669#A1.SS3)\)\. Compiling skills into callable code externalizes procedural execution from the prompt, yielding both efficiency and a small additional reliability gain\.

## 5Related Work

LLM\-Based Agents\.ReAct\(Yao et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib19)\)interleaves reasoning with actions; CodeAct\(Wang et al\.,[2024b](https://arxiv.org/html/2606.26669#bib.bib14)\), PAL\(Gao et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib2)\), and Code as Policies\(Liang et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib4)\)show executable code improves compositional reasoning\(Wei et al\.,[2022](https://arxiv.org/html/2606.26669#bib.bib17)\)\. Yet procedural knowledge in successful traces remains ephemeral and rarely reused\.

Reusing Agent Experience as Behavioral Imitation\.A common line keeps the model fixed and reuses experience as*token\-level context*: Reflexion\(Shinn et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib10)\)prompts self\-reflection; AWM\(Wang et al\.,[2024c](https://arxiv.org/html/2606.26669#bib.bib16)\)induces textual workflows; Trace2Skill\(Ni et al\.,[2026](https://arxiv.org/html/2606.26669#bib.bib6)\)writes structured skill documents\. All store knowledge in*natural language*—unverifiable before deployment and re\-interpreted at inference\.Skill\-DisCoinstead compiles procedural knowledge into external executable code, verifiable offline and reusable across models\.

Synthesizing Executable Tools, Workflows, and Skills\.\(1\) Tool and workflow generation\.LATM\(Cai et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib1)\), CREATOR\(Qian et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib7)\), and ToolGen\(Wang et al\.,[2024a](https://arxiv.org/html/2606.26669#bib.bib13)\)synthesize or unify tools per task; AgentDistill\(Qiu et al\.,[2025](https://arxiv.org/html/2606.26669#bib.bib8)\)produces MCP modules for training\-free transfer\. At the system level, ADAS\(Hu et al\.,[2024](https://arxiv.org/html/2606.26669#bib.bib3)\), AgentSquare\(Shang et al\.,[2024](https://arxiv.org/html/2606.26669#bib.bib9)\), AFlow\(Zhang et al\.,[2024](https://arxiv.org/html/2606.26669#bib.bib21)\), and MaAS\(Zhang et al\.,[2025](https://arxiv.org/html/2606.26669#bib.bib20)\)automate agentic\-system or workflow design\. All start from*explicit task specifications*;Skill\-DisComines a*corpus of execution traces*, grounding skills in recurring behavior\.\(2\) Skill induction from agent experience\.Voyager\(Wang et al\.,[2023](https://arxiv.org/html/2606.26669#bib.bib12)\)commits one JavaScript function per successful task, leaving near\-duplicate variants unconsolidated\. SkillWeaver\(Zheng et al\.,[2025](https://arxiv.org/html/2606.26669#bib.bib22)\)derives APIs from website affordances, not workload traces\. ASI\(Wang et al\.,[2025](https://arxiv.org/html/2606.26669#bib.bib15)\)shows programs beat free\-form text as skill representations but still operates per\-trajectory\.Skill\-DisCois an offline*corpus\-level compiler*: semantic clustering merges equivalent operations into verified executable skills, so library size scales with distinct behaviors, not episode count\.

## 6Conclusion

This paper studies procedural skill discovery by making shared execution structure across successful traces explicit\. We formulate skills as reusable PFSM subgraphs under parameter binding, and introduceSkill\-DisCowhich distills compact, high\-coverage structures from traces and compiles them into executable, and verifiable skills\. Experiments onALFWorldandWebArenashow that these structurally grounded skills improve success rate and turn efficiency, supporting more reliable and transferable agent experience reuse\.

## Limitations

Procedural tasks only\.SkillDisCo compiles programmatic skills from interaction traces and is effective for tasks with reusable procedural structure \(navigation, web automation, tool use\)\. It offers no benefit for pure NLP tasks such as text generation or reading comprehension, where success depends on linguistic understanding rather than executable procedures\.

Pipeline quality depends on model capability\.SkillDisCo’s pipeline relies on the compiler LLM’s reasoning and code\-generation ability\. Insufficient model capability yields incorrect or overly specific skills, and output quality degrades as model capability decreases\.\.

Requires successful traces\.Only successful episodes contribute distillation signal\. In domains where even frontier models succeed rarely, the corpus may be too sparse for reliable corpus\-level skill extraction\.

## References

- Cai et al\. \(2023\)Tianle Cai, Xuezhi Wang, Tengyu Ma, Xinyun Chen, and Denny Zhou\. 2023\.[Large language models as tool makers](https://arxiv.org/abs/2305.17126)\.*arXiv preprint arXiv:2305\.17126*\.
- Gao et al\. \(2023\)Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig\. 2023\.[PAL: Program\-aided language models](https://arxiv.org/abs/2211.10435)\.*arXiv preprint arXiv:2211\.10435*\.
- Hu et al\. \(2024\)Shengran Hu, Cong Lu, and Jeff Clune\. 2024\.[Automated design of agentic systems \(ADAS\)](https://arxiv.org/abs/2408.08435)\.*arXiv preprint arXiv:2408\.08435*\.
- Liang et al\. \(2023\)Jacky Liang, Wenlong Huang, Fei Xia, Peng Xu, Karol Hausman, Brian Ichter, Pete Florence, and Andy Zeng\. 2023\.Code as policies: Language model programs for embodied control\.In*IEEE International Conference on Robotics and Automation \(ICRA\)*, pages 9493–9500\.
- Liu et al\. \(2023\)Xiao Liu, Hao Yu, Hanchen Zhang, Yifan Xu, Xuanyu Lei, Hanyu Lai, Yu Gu, Hangliang Ding, Kaiwen Men, Kejuan Yang, Shudan Zhang, Xiang Deng, Aohan Zeng, Zhengxiao Du, Chenhui Zhang, Sheng Shen, Tianjun Zhang, Yu Su, Huan Sun, and 3 others\. 2023\.[AgentBench: Evaluating LLMs as agents](https://arxiv.org/abs/2308.03688)\.*arXiv preprint arXiv:2308\.03688*\.
- Ni et al\. \(2026\)Jingwei Ni, Yihao Liu, Xinpeng Liu, Yutao Sun, Mengyu Zhou, Pengyu Cheng, Dexin Wang, Erchao Zhao, Xiaoxi Jiang, and Guanjun Jiang\. 2026\.[Trace2Skill: Distill trajectory\-local lessons into transferable agent skills](https://arxiv.org/abs/2603.25158)\.*arXiv preprint arXiv:2603\.25158*\.Work in progress\.
- Qian et al\. \(2023\)Cheng Qian, Chi Han, Yi R\. Fung, Yujia Qin, Zhiyuan Liu, and Heng Ji\. 2023\.[CREATOR: Tool creation for disentangling abstract and concrete reasoning of large language models](https://arxiv.org/abs/2305.14318)\.*arXiv preprint arXiv:2305\.14318*\.
- Qiu et al\. \(2025\)Jieyi Qiu, Xiang Juan, Yan Wang, Lei Yang, Xin Qi, Tao Zhang, Jun Guo, Yun Lu, Zheng Yao, Mei Wang, and 1 others\. 2025\.[AgentDistill: Training\-free agent distillation with generalizable MCP boxes](https://arxiv.org/abs/2506.14728)\.*arXiv preprint arXiv:2506\.14728*\.
- Shang et al\. \(2024\)Yu Shang, Yu Li, Keyu Zhao, Likai Ma, Jiahe Liu, Fengli Xu, and Yong Li\. 2024\.[AgentSquare: Automatic LLM agent search in modular design space](https://arxiv.org/abs/2410.06153)\.*arXiv preprint arXiv:2410\.06153*\.
- Shinn et al\. \(2023\)Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao\. 2023\.Reflexion: Language agents with verbal reinforcement learning\.*Advances in Neural Information Processing Systems*, 36\.
- Shridhar et al\. \(2021\)Mohit Shridhar, Xingdi Yuan, Marc\-Alexandre Côté, Yonatan Bisk, Adam Trischler, and Matthew Hausknecht\. 2021\.[ALFWorld: Aligning text and embodied environments for interactive learning](https://arxiv.org/abs/2010.03768)\.In*International Conference on Learning Representations*\.
- Wang et al\. \(2023\)Guanzhi Wang, Yuqi Xie, Yunfan Jiang, Ajay Mandlekar, Chaowei Xiao, Yuke Zhu, Linxi Fan, and Anima Anandkumar\. 2023\.[Voyager: An open\-ended embodied agent with large language models](https://arxiv.org/abs/2305.16291)\.*arXiv preprint arXiv:2305\.16291*\.
- Wang et al\. \(2024a\)Renxi Wang, Xudong Han, Lei Ji, Shu Wang, Timothy Baldwin, and Haonan Li\. 2024a\.[ToolGen: Unified tool retrieval and calling via generation](https://arxiv.org/abs/2410.03439)\.*arXiv preprint arXiv:2410\.03439*\.
- Wang et al\. \(2024b\)Xingyao Wang, Yangyi Chen, Lifan Yuan, Yizhe Zhang, Yunzhu Li, Hao Peng, and Heng Ji\. 2024b\.[Executable code actions elicit better llm agents](https://arxiv.org/abs/2402.01030)\.In*ICML*\.
- Wang et al\. \(2025\)Zora Zhiruo Wang, Apurva Gandhi, Graham Neubig, and Daniel Fried\. 2025\.[Inducing programmatic skills for agentic tasks](https://arxiv.org/abs/2504.06821)\.*arXiv preprint arXiv:2504\.06821*\.
- Wang et al\. \(2024c\)Zora Zhiruo Wang, Jiayuan Mao, Daniel Fried, and Graham Neubig\. 2024c\.[Agent workflow memory](https://arxiv.org/abs/2409.07429)\.*arXiv preprint arXiv:2409\.07429*\.
- Wei et al\. \(2022\)Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Brian Ichter, Fei Xia, Ed Chi, Quoc Le, and Denny Zhou\. 2022\.Chain\-of\-thought prompting elicits reasoning in large language models\.*Advances in Neural Information Processing Systems*, 35\.
- Yang et al\. \(2024\)John Yang, Carlos E Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik R Narasimhan, and Ofir Press\. 2024\.[SWE\-agent: Agent\-computer interfaces enable automated software engineering](https://arxiv.org/abs/2405.15793)\.In*The Thirty\-eighth Annual Conference on Neural Information Processing Systems*\.
- Yao et al\. \(2023\)Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao\. 2023\.[ReAct: Synergizing reasoning and acting in language models](https://arxiv.org/abs/2210.03629)\.In*International Conference on Learning Representations*\.
- Zhang et al\. \(2025\)Guibin Zhang, Luyang Niu, Junfeng Fang, Kun Wang, Lei Bai, and Xiang Wang\. 2025\.[Multi\-agent architecture search via agentic supernet](https://arxiv.org/abs/2502.04180)\.*arXiv preprint arXiv:2502\.04180*\.
- Zhang et al\. \(2024\)Jiayi Zhang, Jinyu Xiang, Zhaoyang Yu, Fengwei Teng, Xionghui Chen, Jiaqi Chen, Mingchen Zhuge, Xin Cheng, Sirui Hong, and 1 others\. 2024\.[AFlow: Automating agentic workflow generation](https://arxiv.org/abs/2410.10762)\.*arXiv preprint arXiv:2410\.10762*\.
- Zheng et al\. \(2025\)Boyuan Zheng, Michael Y\. Fatemi, Xiaolong Jin, Zora Zhiruo Wang, Apurva Gandhi, Yueqi Song, Yu Gu, Jayanth Srinivasa, and 1 others\. 2025\.[SkillWeaver: Web agents can self\-improve by discovering and honing skills](https://arxiv.org/abs/2504.07079)\.*arXiv preprint arXiv:2504\.07079*\.
- Zhou et al\. \(2024\)Shuyan Zhou, Frank F\. Xu, Hao Zhu, Xuhui Zhou, Robert Lo, Abishek Sridhar, Xianyi Cheng, Tianyue Ou, Yonatan Bisk, Daniel Fried, Uri Alon, and Graham Neubig\. 2024\.[WebArena: A realistic web environment for building autonomous agents](https://arxiv.org/abs/2307.13854)\.In*International Conference on Learning Representations*\.

## Appendix AFull Results: Token Usage and Inference Cost

### A\.1API Pricing Assumptions

All per\-episode inference costs reported in the paper are computed from provider\-published token prices, retrieved from Artificial Analysis111[https://artificialanalysis\.ai/models\#pricing](https://artificialanalysis.ai/models#pricing)on 23 May 2026 \(on\-demand rates\)\. Cached input tokens \(returned inside a context\-caching session\) are billed at1/10\\nicefrac\{\{1\}\}\{\{10\}\}of the regular input rate; output tokens are billed at the full output rate\. No batch\-API discounts are applied\.

### A\.2Full Baseline Comparison with Token and Cost Statistics

Table[5](https://arxiv.org/html/2606.26669#A1.T5)reproduces Table[1](https://arxiv.org/html/2606.26669#S4.T1)from the main paper with the three token/cost columns restored\.

Table 5:Full comparison against prior baselines with a GPT\-4o backbone, including per\-episode token usage and inference cost\. “In\-Tok\. \(Cached\)” = avg\. input tokens per episode with the prompt\-cached portion in parentheses \(cached tokens are billed at1/10\\nicefrac\{\{1\}\}\{\{10\}\}of the regular input rate\)\. Same convention used in all subsequent tables\.MethodSR \(%\)↑\\uparrowAvg\. Turns↓\\downarrowIn\-Tok\. \(Cached\)Out\-Tok\.Cost \($\)\(a\) ALFWorldReAct82\.0019\.2935,600 \(22,200\)6260\.0450CodeAct96\.273\.637,721 \(6,232\)5620\.0109AWMoffline54\.4811\.3438,908 \(22,923\)2750\.0484ASIoffline47\.0111\.4368,945 \(54,175\)2860\.0533Skill\-DisCo\+\+ReAct92\.40 \(\+12\.7%\+12\.7\\%\)8\.78 \(−54\.5%\-54\.5\\%\)22,100 \(11,300\) \(−37\.9%\-37\.9\\%\)607 \(−3\.0%\-3\.0\\%\)0\.0360 \(−20\.0%\-20\.0\\%\)Skill\-DisCo\+\+CodeAct99\.25\(\+3\.1%\+3\.1\\%\)3\.22\(−11\.3%\-11\.3\\%\)8,468 \(6,303\) \(\+9\.7%\+9\.7\\%\)368\(−34\.5%\-34\.5\\%\)0\.0107\(−1\.8%\-1\.8\\%\)\(b\) WebArenaReAct23\.895\.8850,914 \(8,605\)7280\.1152CodeAct19\.9510\.8675,962 \(24,202\)8060\.1435AWMoffline21\.185\.9249,025 \(11,748\)5640\.1018ASIoffline24\.635\.7156,662 \(9,247\)6030\.1269Skill\-DisCo\+\+ReAct29\.06\(\+21\.6%\+21\.6\\%\)5\.11\(−13\.1%\-13\.1\\%\)51,068 \(8,582\) \(\+0\.3%\+0\.3\\%\)561\(−22\.9%\-22\.9\\%\)0\.1215 \(\+5\.5%\+5\.5\\%\)Skill\-DisCo\+\+CodeAct22\.91 \(\+14\.8%\+14\.8\\%\)8\.47 \(−22\.0%\-22\.0\\%\)85,649 \(27,078\) \(\+12\.8%\+12\.8\\%\)736 \(−8\.7%\-8\.7\\%\)0\.1606 \(\+11\.9%\+11\.9\\%\)
Parenthesized values give relativeΔ\\Deltavs\. the matching base agent \(ReAct or CodeAct\)\.Bestandsecond\-bestper column highlighted; our rows inbold\.

### A\.3Per\-Episode Token and Cost Breakdown

Tables[6](https://arxiv.org/html/2606.26669#A1.T6)expand the aggregate “Avg\. In\-Tok\. \(Cached\) / Avg\. Out\-Tok\. / Avg\. Cost” figures from Table[2](https://arxiv.org/html/2606.26669#S4.T2)with the full numerical detail for every model\-setting pair\.

Table 6:Per\-episode token usage and inference cost on ALFWorld \(CodeAct backbone, 134 unseen tasks\)\. “Δ\\Delta” is the relative change vs\. the same model’s Vanilla setting \(applied to In\-Tok\.\)\.
### A\.4Full Ablation Breakdown

Table[7](https://arxiv.org/html/2606.26669#A1.T7)expands the two\-row ablation summary in Table[4](https://arxiv.org/html/2606.26669#S4.T4)\(§[4\.5](https://arxiv.org/html/2606.26669#S4.SS5)\) with the no\-skill baseline and per\-episode token and cost statistics\.

Table 7:Full ablation breakdown on ALFWorld \(CodeAct \+ GPT\-4o\)\.

## Appendix BPipeline Stage Prompts

We summarize the LLM prompts that drive each pipeline stage \(latest\_pipeline/skill\_mining/\)\. For brevity each listing keeps the system message’s role, key directives, and the JSON output schema; long motivating examples, repeated rationale, and formatting boilerplate from the source files are elided with “…”\. Placeholders in\{braces\}are Python f\-string slots filled at runtime\. A few slots in Stages 4 and 5 are specialized per benchmark \(benchmark\_prompts\.py\) – we leave them as placeholders here and omit the benchmark\-specific fills for brevity\.

### B\.1Stage 1 — Trace→\\toProgram Transpilation

Listing 1:Stage 1 prompt \(trace normalization, fromprompt/trace\_converter\.md\)\.1\[System\]

2YouareaSeniorAISystemsArchitect\.ConvertarawReActtrace

3\(alternatingTHOUGHT/ACTIONmessagesandenvironmentobservations\)

4intoastructuredPythonprogramthatpreservesthereasoningwhile

5makingcontrolflowexplicitandlogicallystable\.

6

7EachreasoningblockmustfollowtheUnifiedReasoningTemplate:

8\#A\.Deterministic\(logic\-controlled\)

9if"<condition\>"inobservation:

10action="<derivedaction\>"

11context\.append\(\(observation,None,action\)\)

12observation,available\_actions=env\.step\(action\)

13\#B\.Cognitive\(LLM\-driven,foradaptive/uncertainsteps\)

14thinking,action=llm\(task,context,observation,available\_actions\)

15context\.append\(\(observation,thinking,action\)\)

16observation,available\_actions=env\.step\(action\)

17

18Rules:\(i\)usedeterministiccontrolflow\(if/for/while\)forrepetitive

19orstabilizedreasoning;\(ii\)reservellm\(\)foradaptivedecisions;

20\(iii\)update‘context‘andcall‘env\.step\(\)‘aftereveryaction;

21\(iv\)preserveeveryACTIONfromthetrace\-\-neverdropmistakesor

22recoverysteps;\(v\)copyrealobservation/thinking/actionstringsas

23inline‘\#\.\.\.‘comments\.

24

25\[User\]

26PleaseconvertthefollowingagenttracehistorytoPythoncode:

27\{raw\_history\}

### B\.2Stage 2 — Semantic Operation Extraction

Listing 2:Stage 2 prompt\.1\[System\]

2YouareanexpertatanalyzingagenttracesrepresentedasPythoncode\.

3Extractsemanticoperations:groupsofconsecutivestepsthattogether

4accomplishonecoherentsub\-goalandwhoseinternalrelationshipcan

5beexpressedascontrolflow\(if/for/whileorfixedsequence\)\.

6Agoodoperationhasclearboundaries,locality,andreusability\.

7

8Foreachoperationemit:

9name:snake\_caseverb\_noun

10description:thesub\-goal

11env\_steps:every\(action,observation\)pair\-\-preferthe

12authoritativeenv\-steplogoverthecode,whichmay

13havedroppedactionsduringconversion

14code\_snippet:thecompletecodeblock\(notruncation\)

15succeeded:trueiffthefinalobservationconfirmsthesub\-goal

16\(e\.g\.,"Nothinghappens\."=\>false\)

17

18OutputJSON:\{"task\_summary":"\.\.\.","operations":\[\.\.\.\]\}

19

20\[User\]

21\#\#CodetoAnalyze

22‘‘‘python

23\{trace\.code\}

24‘‘‘

25\{env\_log\_section\}

26Pleaseextractallsemanticoperations\.Theenv\-steplogis

27authoritative\-\-groupitsentriesbythecode’sstructurebut

28includeALLactionsfromthelog\.

### B\.3Stage 3 — Operation Clustering \(Two Passes\)

Stage 3 first runs a*grouping pass*over mini\-batches that proposes candidate reusable patterns, then a*consolidation pass*that merges overlapping proposals into a minimal cluster set\.

Listing 3:Stage 3a prompt – grouping\.1\[System\]

2Youareidentifyingreusableoperationpatterns\.Partitiontheinput

3operationsintonon\-overlappinggroupswhosememberssharethelargest

4reusableaction/observationpatternandsemanticgoal\-\-transferring

5acrossdifferentobjects,locations,pages,ortaskinstances\.

6

7Rules:use‘env\_steps‘todecidemembership\(notnames\);ignore

8incidentaldifferences;splitonlywhentheactionpatternorgoal

9differs;ignoreoperationsthatdidnotchangestate;preferfewer,

10larger,uniformgroups\-\-whenindoubt,MERGE\.

11

12OutputJSON:\{"groups":\[\{"group\_name","description",

13"representative\_operations":\[\{"operation\_id","name"\}\]\}\]\}

14

15\[User\]

16\#\#OperationstoAnalyze\(\{len\(batch\)\}operations\)

17‘‘‘json

18\{json\.dumps\(batch,indent=2\)\}

19‘‘‘

Listing 4:Stage 3b prompt – consolidation\.1\[System\]

2Mergethecandidateoperationgroupsintoaminimal,non\-redundant

3skillset\.Assigneveryinputgroup‘index‘toexactlyonefinal

4cluster\(nooverlap,nomissingindex\)\.

5

6Mergegroupswhosereusableskill,goal,orinducedstatechangeis

7similar,evenifthewording,objects,locations,orappliances

8differ\.Proceedinthreesteps:\(1\)draftcandidateclusters,

9\(2\)mergeduplicates/overlaps,\(3\)emitthefinalJSONastheLAST

10fenced‘json‘blockinyourresponse\.

11

12OutputJSON:\{"clusters":\[\{"name","description",

13"indices":\[0,3,7\]\},\.\.\.\]\}

14

15\[User\]

16\#\#GroupstoConsolidate\(\{len\(groups\)\}groups\)

17‘‘‘json

18\{json\.dumps\(group\_summaries,indent=2\)\}

19‘‘‘

### B\.4Stage 4 — Skill Contract Definition

Stage 4 turns each cluster into a typed skill contract\. The base prompt is built bybuild\_stage4\_prompt\(bench\_cfg\)and contains two benchmark slots,\{action\_construction\_note\}and\{action\_seq\_example\}, that are filled per benchmark\.

Listing 5:Stage 4 prompt \(benchmark slots left as placeholders\)\.1\[System\]

2YoudesignreusableskillAPIsforLLMagents\.SkillsarePython

3functionsoftheform

4defskill\_name\(param1,param2,\.\.\.\):

5‘env‘isaglobal\-\-neveraparameter\-\-andisusedas

6observation,available\_actions=env\.step\(action:str\)

7Afteraskillreturns,thecallerLLMseesONLYthereturnedDict;

8itmustalwaysincludeatleast‘success‘,thelatest‘observation‘

9and‘available\_actions‘,andaprocesstraceof\(action,observation\)\.

10

11Designprinciples:\(1\)generalize\-\-parameterizeobjectnames,

12locationlists,andactiontemplates;\(2\)singleresponsibility\-\-

13onegoalperskill;\(3\)actionSELECTIONnotconstruction\-\-

14\{action\_construction\_note\}

15\(4\)declareeverystatechangein‘side\_effects‘andreflectitin

16‘canonical\_action\_sequence‘;\(5\)composefreely\-\-assumeno

17prerequisitefromthecaller\.

18

19OutputJSONcontract:

20\{"skill\_name","description","docstring",

21"parameters":\[\{"name","type","description","required","default"\}\],

22"return\_type":"Dict",

23"preconditions","postconditions","side\_effects",

24"canonical\_action\_sequence":\[

25"Orderedactiontemplateswith\{param\}placeholders\.",

26\{action\_seq\_example\}

27"DeriveONLYfromSUCCEEDEDtraces;prefertheshortest

28successfulsequence;copytheexactactionsyntax\."

29\],

30"abstraction\_level":"primitive\|composite\|workflow",

31"estimated\_actions\_saved":<int\>,"confidence\_score":<float\>\}

32

33\[User\]

34\#\#OperationGroup

35\-Name/Description/\#operations/\#traces/avg\_actions/

36reusability\_score:\{clusterfields\}

37

38\#\#RepresentativeOperations\(realenv\.step\(\)patterns\)

39‘‘‘json

40\{json\.dumps\(examples,indent=2\)\}

41‘‘‘

42Defineageneral,reusableskillthatabstractsthispattern\.

### B\.5Stage 5 — Skill Synthesis

Stage 5 synthesises a self\-contained Python implementation from the Stage 4 contract\. The base prompt is built bybuild\_stage5\_prompt\(bench\_cfg\)and contains two benchmark slots,\{first\_action\_rule\}\(how to obtain the first vs\. later actions\) and\{identifier\_note\}\(an env\-specific gotcha\)\.

Listing 6:Stage 5 prompt \(benchmark slots left as placeholders\)\.1\[System\]

2YousynthesisethePythonbodyofaskilldefinedbytheStage4

3contract\.‘env‘isglobal;signaturecontainsonlydomainparameters\.

4

5Criticalrules:

61\.UseONLY‘env\.step\(\)‘andthePythonstdlib\-\-nohelper

7functions,nosimulation,nofabricatedobservations\.

82\.\{first\_action\_rule\}

93\.Matchthetrace’sactionsyntaxexactly;whenconstructing,

10reproducetheverb/preposition/argumentpatternfromthe

11referencetraces\.

124\.BranchontheLATEST‘observation‘,notonaself\-computedflag\.

135\.Honoureveryparameter;implementeverystepin

14‘canonical\_action\_sequence‘andonlythoseplusdeclared

15sideeffects\.

166\.Appendevery\(action,observation\)pairto‘process\_trace‘\.

177\.ReturnaDictincludingatleast‘success‘,latest‘observation‘,

18latest‘available\_actions‘,and‘process\_trace‘\(plusanyextra

19keysthecallerneeds\)\.

20

21Environmentnote:\{identifier\_note\}

22

23OutputJSON:\{"implementation":"defskill\_name\(\.\.\.\):\\\\n\.\.\.",

24"example\_usage":"result=skill\_name\(\.\.\.\)\.\.\."\}

25

26\[User\]

27\#\#SkillDefinition

28\{skill\.skill\_name/description/parameters/pre&postconditions\}

29

30\#\#RepresentativeCodeExamples\(groundtruthenv\.step\(\)patterns\)

31‘‘‘json

32\{json\.dumps\(examples,indent=2\)\}

33‘‘‘

34Synthesisetheimplementation\.Selectactionsfrom

35‘available\_actions‘,followthecode\_snippetpatternsexactly,and

36returntheDictsothecallercancontinuewithoutblindspots\.

## Appendix CSkill Library Examples

We show one representative skill for each benchmark, reproduced verbatim from the final compiled skill catalogs\. Listing[7](https://arxiv.org/html/2606.26669#LST7)is the highest\-coverage skill in the ALFWorld library: it iterates over a list of candidate locations, opens any closed containers, and returns as soon as the target item is observed\. Listing[8](https://arxiv.org/html/2606.26669#LST8)is a representative WebArena skill that drives the multi\-step submission workflow on a Reddit clone \(open form→\\tofill URL / title / body→\\toselect forum→\\tosubmit\), with every action selected by content\-based matching against the live admissible\-action set viafind\_bid\(\.\.\.\)\.

Listing 7:ALFWorld skill:systematic\_search\_locations\.1defsystematic\_search\_locations\(locations,target\):

2"""Systematicallysearchthroughalistoflocationstofinda

3specifictargetitem\.Theskillnavigatestoeachlocation,opens

4itifnecessary,andexaminesitscontentstolocatethetarget\.

5

6Args:

7locations:Alistoflocationnamestosearchthrough\.

8target:Thenameoftheitemtosearchfor\.

9"""

10process\_trace=\[\]

11found\_in=None

12

13forlocationinlocations:

14

15action=f"goto\{location\}"

16observation,available\_actions=env\.step\(action\)

17process\_trace\.append\(\(action,observation\)\)

18

19

20if"closed"inobservation:

21action=next\(

22\(aforainavailable\_actions

23if"open"ina\.lower\(\)andlocationina\.lower\(\)\),

24f"open\{location\}",

25\)

26observation,available\_actions=env\.step\(action\)

27process\_trace\.append\(\(action,observation\)\)

28

29

30iftargetinobservation:

31found\_in=location

32return\{

33"success":True,

34"found\_in":found\_in,

35"observation":observation,

36"available\_actions":available\_actions,

37"process\_trace":process\_trace,

38\}

39

40

41return\{

42"success":False,

43"found\_in":None,

44"observation":observation,

45"available\_actions":available\_actions,

46"process\_trace":process\_trace,

47\}

Listing 8:WebArena skill:create\_submission\_workflow\(Reddit site\)\.1defcreate\_submission\_workflow\(

2title:str,

3body:str,

4forum\_name:str,

5url:Optional\[str\]=None\):

6

7"""Completeworkflowforcreatinganewsubmission/post\.Navigates

8tothesubmissionform,fillsinrequiredfields\(URLifpresent,

9title,body\),selectsthetargetforum,andsubmitstheform\.

10Flow:clickSubmit\-\>fillfields\-\>selectforum\-\>clickCreate\.

11

12Args:

13title:Titleofthesubmissiontopost\.

14body:Maincontent/bodyofthesubmission\.

15forum\_name:Targetforum/subredditlabeltoselect\.

16url:OptionalURLtoincludeiftheformhasaURLfield\.

17"""

18process\_trace=\[\]

19matched\_elements=\[\]

20failure\_reason=None

21

22observation=env\.step\(’noop\(0\)’\)

23

24

25submit\_bid=find\_bid\(’Submit’,observation\)

26ifnotsubmit\_bid:

27return\{’success’:False,’observation’:observation,

28’process\_trace’:process\_trace,

29’matched\_elements’:matched\_elements,

30’failure\_reason’:"Submitbuttonnotfound\."\}

31observation=env\.step\(f"click\(’\{submit\_bid\}’\)"\)

32process\_trace\.append\(\(f"click\(’\{submit\_bid\}’\)",observation\)\)

33matched\_elements\.append\(’Submit’\)

34

35

36ifurl:

37url\_bid=find\_bid\(’URL’,observation\)

38ifurl\_bid:

39act=f"fill\(\{url\_bid\!r\},\{str\(url\)\!r\}\)"

40observation=env\.step\(act\)

41process\_trace\.append\(\(act,observation\)\)

42matched\_elements\.append\(’URL’\)

43

44

45title\_bid=find\_bid\(’Title’,observation\)

46ifnottitle\_bid:

47return\{’success’:False,’observation’:observation,

48’process\_trace’:process\_trace,

49’matched\_elements’:matched\_elements,

50’failure\_reason’:"Titlefieldnotfound\."\}

51act=f"fill\(\{title\_bid\!r\},\{str\(title\)\!r\}\)"

52observation=env\.step\(act\)

53process\_trace\.append\(\(act,observation\)\)

54matched\_elements\.append\(’Title’\)

55

56

57combobox\_bid=find\_bid\(’Chooseone’,observation\)\\

58orfind\_bid\(’Forum’,observation\)

59ifnotcombobox\_bid:

60return\{’success’:False,’observation’:observation,

61’process\_trace’:process\_trace,

62’matched\_elements’:matched\_elements,

63’failure\_reason’:"Forumselectioncomboboxnotfound\."\}

64observation=env\.step\(f"click\(’\{combobox\_bid\}’\)"\)

65process\_trace\.append\(\(f"click\(’\{combobox\_bid\}’\)",observation\)\)

66forum\_bid=find\_bid\(forum\_name,observation\)

67ifnotforum\_bid:

68return\{’success’:False,’observation’:observation,

69’process\_trace’:process\_trace,

70’matched\_elements’:matched\_elements,

71’failure\_reason’:f"Forum’\{forum\_name\}’notfound\."\}

72observation=env\.step\(f"click\(’\{forum\_bid\}’\)"\)

73process\_trace\.append\(\(f"click\(’\{forum\_bid\}’\)",observation\)\)

74matched\_elements\.append\(forum\_name\)

75

76

77body\_bid=find\_bid\(’Body’,observation\)

78ifnotbody\_bid:

79return\{’success’:False,’observation’:observation,

80’process\_trace’:process\_trace,

81’matched\_elements’:matched\_elements,

82’failure\_reason’:"Bodyfieldnotfound\."\}

83act=f"fill\(\{body\_bid\!r\},\{str\(body\)\!r\}\)"

84observation=env\.step\(act\)

85process\_trace\.append\(\(act,observation\)\)

86matched\_elements\.append\(’Body’\)

87

88

89create\_bid=find\_bid\(’Createsubmission’,observation\)\\

90orfind\_bid\(’Submit’,observation\)

91ifnotcreate\_bid:

92return\{’success’:False,’observation’:observation,

93’process\_trace’:process\_trace,

94’matched\_elements’:matched\_elements,

95’failure\_reason’:"Create\-submissionbuttonnotfound\."\}

96observation=env\.step\(f"click\(’\{create\_bid\}’\)"\)

97process\_trace\.append\(\(f"click\(’\{create\_bid\}’\)",observation\)\)

98matched\_elements\.append\(’Createsubmission’\)

99

100success=’submitted’inobservation\.lower\(\)\\

101or’created’inobservation\.lower\(\)

102return\{

103’success’:success,

104’observation’:observation,

105’process\_trace’:process\_trace,

106’matched\_elements’:matched\_elements,

107’failure\_reason’:None

108ifsuccess

109else’Nosuccessconfirmationdetected\.’,

110\}

Similar Articles

SKILL-KD: Contrastive Skill Distillation for LLM Agents

Hugging Face Daily Papers

SKILL-KD is a contrastive skill distillation framework that improves LLM agents by distilling actionable discrepancies between teacher and student trajectories into textual skill patches, with drift-aware consolidation to iteratively refine skills.

SkillSmith: Compiling Agent Skills into Boundary-Guided Runtime Interfaces

arXiv cs.AI

SkillSmith is a boundary-first compiler-runtime framework that extracts fine-grained operational boundaries from LLM agent skills, enabling agents to dynamically access only relevant components, reducing solve-stage token usage by 57.44% and thinking iterations by 42.99% on the SkillsBench benchmark.