Summary of SkillZip: Contract-Preserving Graph Compression for Scalable Agent Skill Libraries

Summary (Overview)

  • SkillZip is a novel framework for compressing large-scale LLM agent skill libraries by operating at the section-level granularity rather than whole-skill packages, enabling more precise retrieval and context hydration within limited context budgets.
  • The framework introduces contract-preserving compression through four key components: Sec2Graph (section-level graph construction), MotifZip (contract-preserving macro compression), PathHydrate (budgeted executable context hydration), and ReZip (incremental library maintenance).
  • SkillZip achieves 3.46× compression ratio with 99.2% dependency preservation and 98.7% verifier reachability, while outperforming the strongest baseline (SkillDAG) by up to 12.2 points on ALFWorld.
  • The system demonstrates scalability from 200 to 100K skills with robust retrieval performance, maintaining 65.1 Ret@1 at the largest scale with 248.3 ms online latency.
  • SkillZip works as a plug-and-play procedural-memory layer across six LLM backbones without backbone-specific fine-tuning, showing consistent improvements on both technical (SkillsBench) and embodied (ALFWorld) benchmarks.

Introduction and Theoretical Foundation

Background and Motivation

LLMs increasingly act as agents whose procedural knowledge is stored in reusable skill packages loaded at inference time. As skill libraries grow, a central challenge emerges: how to expose the smallest sufficient executable context under a limited context budget. The paper identifies four critical challenges in existing systems:

  1. Reuse-granularity mismatch: Existing systems use whole skills as retrieval units, but skills contain multiple functional sections (intents, operations, verifiers, outputs) that may be shared across skills.

  2. Contract preservation under compression: Current compression methods optimize token budgets but preserve textual rather than procedural contracts—a compressed skill can obscure preconditions, guard branches, or verifier hooks.

  3. Persistent executable compression: Execution graphs are built after retrieval over already-selected skills, so the library itself is not stored as a persistent compressed structure.

  4. Execution-aware maintenance: Skill libraries evolve, and one-shot compression cannot recognize newly reusable routines or revise risky macros.

Core Insight

The paper identifies a unit mismatch: skills are retrieved as packages, compressed as text, and converted into execution graphs only after retrieval. The solution requires a contract-bearing procedural unit that survives retrieval, compression, and execution alike. A compression is contract-preserving if it shortens a routine while retaining its interface, execution, and verification aspects.

Key Definitions

Section node: A typed procedural unit:

υ=τv,cv,Xv,Yv,Rv,Gv,srcv\upsilon = \langle \tau_v, c_v, X_v, Y_v, R_v, G_v, \mathrm{src}_v \rangle

where τv\tau_v is the execution role, cvc_v is section content, XvX_v and YvY_v are input/output signatures, RvR_v records resources/tools, GvG_v records guard/verifier conditions, and srcv\mathrm{src}_v points to source.

The framework uses nine operational roles: Intent, Trigger, Input, Precondition, Operation, Resource, Failure, Verifier, and Output.

Procedural skill graph: G=(V,Edep,Eskill,Eres,Eeq)G = (\mathcal{V}, \mathcal{E}_{dep}, \mathcal{E}_{skill}, \mathcal{E}_{res}, \mathcal{E}_{eq}) with typed dependency edges (Edep\mathcal{E}_{dep}), skill membership edges, resource links, and equivalence edges linking compatible occurrences to canonical prototypes.

Macro node: Mg:IgOgM_g: I_g \Rightarrow O_g compresses a connected section subgraph with boundary inputs IgI_g, outputs OgO_g, and expansion rule Mg    (Vg,Eg,χg)M_g \implies (V_g, E_g, \chi_g) where χg\chi_g is the procedural contract.

Methodology

1. Sec2Graph: Building Procedural Subgraphs

Converts whole skill packages into source-grounded procedural subgraphs:

  • Section grounding: Segments packages using headings, lists, code blocks, warnings, and tool references as boundary cues
  • Contract extraction: Extracts typed I/O (Xv,Yv)(X_v, Y_v) and resources RvR_v for interface; guards and verifier conditions in GvG_v
  • Procedural subgraph construction: Connects sections with typed edges (weak-order, dependency, verifier, repair edges)
  • Cross-skill reuse: Links compatible sections to shared canonical prototypes while preserving occurrence identity

2. MotifZip: Contract-Preserving Compression

Mines recurring section-level motifs and promotes them to macro nodes only when contracts are preserved:

Typed candidate generation:

C=GrowMotifs(BucketBySignature(G),G)\mathcal{C} = \text{GrowMotifs}(\text{BucketBySignature}(\mathcal{G}), \mathcal{G})

Graph grammar rule:

Mg[Ig,Og](Vg,Eg,πg,χg)M_g[I_g, O_g] \Rightarrow (V_g, E_g, \pi_g, \chi_g)

Compression gain scoring:

Δ(g)=freq(g)L(g)L(Mg)L(ruleg)+αReuse(g)λCut(g)μRisk(g)\Delta(g) = \text{freq}(g)L(g) - L(M_g) - L(\text{rule}_g) + \alpha\text{Reuse}(g) - \lambda\text{Cut}(g) - \mu\text{Risk}(g)

A motif is accepted only if: (1) interface is stable across occurrences, (2) execution is dependency-closed, (3) verification remains reachable.

Key theoretical guarantee (Proposition 1): Compositional structural lifting—if a raw procedural subgraph PP contains all or none of the internal nodes for each occurrence, then ξΩ(κΩ(P))P\xi_\Omega(\kappa_\Omega(P)) \cong P up to auxiliary prototype links, preserving typed external dependencies and operation-to-verifier reachability.

3. PathHydrate: Budgeted Executable Context

Builds compact, dependency-closed procedural subgraphs for queries:

Task anchoring: Converts queries into structured objects:

zq=(gq,Oq,Γq,Iq,Dq,{di})z_q = (g_q, O_q, \Gamma_q, I_q, D_q, \{d_i\})

Dual-level seed fusion: Combines section-level and skill-level retrieval:

s(v,di,q)=max{cos(e(di),e(v)),cos(e(q),e(v))}s(v, d_i, q) = \max\{\cos(\mathbf{e}(d_i), \mathbf{e}(v)), \cos(\mathbf{e}(q), \mathbf{e}(v))\}

Skills are fused via reciprocal-rank fusion:

RRF(σ)=rRrank1k+rankr(σ)\text{RRF}(\sigma) = \sum_{r \in \mathcal{R}_{rank}} \frac{1}{k + \text{rank}_r(\sigma)}

Constrained subgraph search:

Pq=argminPGzipηT(P)+βP+γE(P)δMatch(P,q)P_q^* = \arg\min_{P \subseteq \mathcal{G}_{zip}} \eta T(P) + \beta|P| + \gamma E(P) - \delta\text{Match}(P, q)

subject to anchor coverage, dependency closure, verifier reachability, and budget T(P)BT(P) \leq B.

Progressive hydration: Macros rendered at lowest sufficient level: name, contract, outline, or full source.

4. ReZip: Incremental Library Maintenance

Updates the compressed library as new skills and execution traces arrive:

Zt+1=ReZip(Zt,ut)\mathcal{Z}_{t+1} = \text{ReZip}(\mathcal{Z}_t, u_t)

Macro promotion condition:

suppt(r)m,Δ(r)>0,Validχ(r)=1\text{supp}_t(r) \geq m, \quad \Delta(r) > 0, \quad \text{Valid}_\chi(r) = 1

Execution risk scoring:

ρt(M)=λenexp(M)nuse(M)+λvnfail(M)nuse(M)+λdcrepair(M)nuse(M)\rho_t(M) = \lambda_e \frac{n_{\text{exp}}(M)}{n_{\text{use}}(M)} + \lambda_v \frac{n_{\text{fail}}(M)}{n_{\text{use}}(M)} + \lambda_d \frac{c_{\text{repair}}(M)}{n_{\text{use}}(M)}

Empirical Validation / Results

Main Results (RQ1)

BackboneMethodSkillsBench R↑ALFWorld R↑
MiniMax-M2.7Vanilla Skills17.247.1
MiniMax-M2.7Vector Skills10.450.7
MiniMax-M2.7GoS18.754.3
MiniMax-M2.7SkillDAG27.367.1
MiniMax-M2.7SkillZip33.379.3
gpt-5.2-codexVanilla Skills27.489.3
gpt-5.2-codexVector Skills21.592.9
gpt-5.2-codexGoS34.493.6
gpt-5.2-codexSkillDAG36.893.6
gpt-5.2-codexSkillZip43.096.4

SkillZip improves over SkillDAG by 6.0–12.2 points on SkillsBench and 2.8–12.2 points on ALFWorld, with the largest gains on the weaker backbone where there is more room for improvement.

Compression and Structural Fidelity (RQ3)

RepresentationCR↑Tok↓DPR↑VR↑Recover.↓R↑
Raw section graph1.00×6,716100.0100.00.031.0
Exact-text dedup.1.43×4,69798.698.15.231.2
Text compression3.46×1,94165.060.045.025.5
Generic graph grammar2.91×2,30893.490.822.729.4
SkillZip w/o checks3.78×1,77788.984.631.527.8
SkillZip3.46×1,94199.298.714.833.3

Key findings:

  • Text compression achieves similar compression but destroys executable structure (DPR: 65.0, VR: 60.0)
  • Removing contract checks makes compression more compact (3.78×) but harms execution safety
  • SkillZip preserves near-complete structural fidelity (DPR: 99.2, VR: 98.7) while achieving 3.46× compression

Ablation Study (RQ4)

ComponentVariantR↑Ret@1↑Tok↓DPR↑VR↑
FullSkillZip33.373.61,94199.298.7
Unitw/o section-level nodes27.966.73,103--
Compressionw/o MotifZip31.071.82,967100.0100.0
Compressionw/o dependency closure28.672.11,65382.392.6
Compressionw/o verifier constraint29.172.81,66894.976.4
Hydrationw/o global section rescue30.468.21,81296.596.8
Hydrationw/o adaptive hydration31.573.22,58799.298.7

Key findings:

  • Section-level nodes are critical: removing them causes the largest drop (Ret@1: -6.9, reward: -5.4, context: +59.9%)
  • Contract checks matter: removing dependency closure drops DPR to 82.3; removing verifier constraints drops VR to 76.4
  • Adaptive hydration saves 33.3% tokens without harming structural fidelity

Additional Results

  • Scalability: Ret@1 advantage over SkillDAG widens from 6.2 (200 skills) to 23.3 (100K skills); at 100K skills, SkillZip retains 65.1 Ret@1 with 248.3 ms latency
  • Contract extraction quality: 91.6 macro-F1 and 84.6 exact match against human annotations
  • Efficiency gains: 47.0% reduction in cumulative prompt processing, 21.7% fewer tool calls, 21.1% faster end-to-end task time vs. SkillDAG

Theoretical and Practical Implications

Theoretical Contributions

  1. Contract-preserving compression: Introduces a formal notion of compression that preserves procedural contracts (interface, execution, verification) rather than just textual similarity, with a proven compositional lifting property (Proposition 1) guaranteeing reversible macro expansion.

  2. Section-level procedural memory: Establishes that skills are not atomic units but collections of typed, contract-bearing sections that can be independently reused across skills—a fundamental shift from whole-skill retrieval.

  3. Unified representation: Shows that retrieval, compression, and execution should operate on the same unit (contract-bearing section subgraphs), resolving the unit mismatch in existing pipelines.

Practical Implications

  1. Scalable skill libraries: Enables efficient skill reuse in libraries ranging from hundreds to hundreds of thousands of skills, with retrieval precision that improves relative to baselines as libraries grow.

  2. Context efficiency: Reduces rendered context by 72.1% compared to top-5 whole-skill loading while maintaining or improving task performance, critical for LLM context budget constraints.

  3. Safe compression: Provides a principled approach to compression that maintains executable structure—shorter context does not come at the cost of dropped verifiers or hidden dependencies.

  4. Maintainable systems: The ReZip component enables continuous library evolution, promoting new reusable routines and retiring risky macros based on execution evidence.

Conclusion

SkillZip presents a comprehensive solution to the challenge of scalable agent skill libraries by fundamentally changing the unit of procedural reuse from whole skill packages to contract-bearing section-level graphs. The framework's four components work together: Sec2Graph exposes internal skill structure, MotifZip compresses only contract-valid recurring motifs, PathHydrate builds minimal executable contexts, and ReZip maintains the compressed library as skills evolve.

The empirical results demonstrate that execution-aware compression outperforms both whole-skill retrieval and text-only compression across multiple LLM backbones and task domains. The 3.46× compression ratio with near-perfect dependency preservation (99.2%) and verifier reachability (98.7%) shows that significant context savings are achievable without sacrificing executable structure.

Future directions suggested by this work include extending the framework to handle more complex procedural contracts (e.g., multi-agent coordination), investigating semantic rather than structural equivalence guarantees, and exploring how execution evidence can be more richly incorporated into macro revision decisions. The framework's plug-and-play nature across LLM backbones also opens possibilities for integration with other agent architectures and skill-acquisition systems.

Related papers