arXiv:2610.31461cs.AIOct 2026

Manuscript Offprint

arXiv:2610.31461

Adaptive Skill Granularity for Coding Agents: Runtime Routing and Macro-to-Micro Recovery

Dingxuan Zhang, Yanhui Jiang, Jun Wang, Hefeng Zhou

Dingxuan Zhang 1∗^{1*}, Yanhui Jiang 2∗^{2*}, Jun Wang 3^{3}, and Hefeng Zhou 1^{1}

1^{1} Shanghai Jiao Tong University, China

2^{2} Kuaishou Technology Co., Ltd., China

3^{3} University of Warwick, UK

h.rezin.zhou@gmail.com

Abstract. Reusable skills allow large language model agents to package task-specific procedures, tool affordances, and execution guidance into modular units. Prior work has largely studied how agents retrieve, compose, or synthesize skills before execution. In coding agents, however, execution poses an additional runtime control problem: the same task may be solved through primitive tool calls, macro skills, or hybrid execution that starts with a macro and falls back to micro-level recovery. We introduce Adaptive Skill Granularity, a framework that treats skill granularity as an action-abstraction policy conditioned on task structure, execution state, and macro-skill failures. The system combines a feature-based granularity controller and a finite-state recovery executor. We evaluate the framework with a deterministic coding-agent protocol using verifier-defined success, total cost, and process metrics such as macro adoption, failure recovery, route match, and transition correctness. Results show that fixed macro execution is efficient when applicable but brittle under mismatch, while runtime routing and explicit macro-to-micro recovery improve robustness and recover controlled macro failures that fixed-granularity execution leaves unresolved. Our findings suggest that skill libraries for coding agents should be treated not only as retrievable resources, but also as controllable, verifiable, and recoverable execution abstractions.

Keywords: LLM agents, agent skill, adaptive skill granularity

1 Introduction

Large language model (LLM) agents increasingly solve software-engineering tasks by inspecting files, invoking tools, editing code, and validating changes. To avoid solving each task from scratch, recent systems package reusable procedures as skills: named artifacts that specify when to act, which tools to use, what state to inspect, and how to verify completion. Existing skill ecosystems include Markdown skills, structured runtime skills, skill routers, dependency-aware skill graphs, and mined trajectory fragments [8, 25–27].

∗^{*} These authors contributed equally to this work. Code is available at: https://github.com/Jayceon-3/Adaptive-Skill-Agent

Most prior work treats skill use as a selection or retrieval problem: given a task and a skill library, expose the most relevant skill text or bundle before planning [6, 13, 26]. This is necessary but insufficient for tool-using agents. During execution, the agent must also decide the granularity of its next actions. A simple bug fix may be safer with micro tools such as search, editing, syntax checks, and tests, while a module move may benefit from a macro skill that combines file movement, import rewriting, and validation. When such a macro fails or only partially applies, the agent needs controlled macro-to-micro recovery rather than another retrieval step.

This motivates treating skill granularity as a runtime control variable. Recent evidence shows that injected skills often provide uneven gains, increase cost, or even degrade software-engineering performance when their abstraction level does not match the task context [7]. Hierarchical agent methods also adapt abstraction levels, but usually at the planning level through learned policies or repeated refinement [10, 19]. In contrast, we control the admissible action set at runtime: the agent may execute with micro tools, macro skills, or a hybrid mode that downgrades to micro tools after an observable macro failure. This keeps the controller inspectable and makes recovery an explicit execution transition rather than an informal retry or re-planning heuristic.

This paper studies adaptive skill granularity as a runtime control problem. An LLM agent with a skill library must decide not only which skill description to retrieve, but also the abstraction level of its next actions. Our central hypothesis is that no fixed granularity is universally optimal; the best choice depends on task structure, skill quality, execution state, and verifier feedback. We instantiate this problem in coding agents because repositories provide persistent state, tools expose concrete side effects, and tests offer deterministic validation. This makes coding a high-observability testbed while keeping the method defined over general agent trajectories, action abstractions, and recovery transitions. We further ground macro-skill admission in a real-world skill-library template, requiring each candidate macro to document its scope, interface, side effects, failure behavior, verification procedure, and fallback path before it can enter the executable library. We make three contributions.

  1. We formulate runtime skill granularity control as distinct from ordinary skill retrieval. The decision is not only which skill to expose, but whether to execute in micro, macro, or hybrid recovery mode.

  2. We present an agent-control architecture, instantiated in coding agents, that combines a feature-based granularity controller with a finite-state recovery executor to manage runtime execution abstraction.

  3. We define a verifier-driven GranBench-Code evaluation protocol that treats validated success and total cost as primary metrics, and reports macro adoption, failure recovery, route match, transition correctness, and confidence intervals. We apply it in a pilot study of fixed-granularity, routed, and recovery-enabled agents, while specifying the unconstrained and LLM-router baselines required for the full study.

References (27)