arXiv:2611.01701cs.AINov 2026

Manuscript Offprint

arXiv:2611.01701

Just-in-Time Skill Retrieval via Long-Horizon State Tracking

Xin Lin, Ziheng Wang, Zerui Chen, Jiayao Ma, Zhimin Wei, Bingshuai Liu, Buchao Zhan, Qinggang Zhang, Jinsong Su

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language model (LLM) agents increasingly rely on external skill libraries to support complex task execution. However, determining which skills are needed remains challenging in long-horizon tasks. Existing methods typically select a fixed skill set before execution, implicitly assuming that a task's procedural requirements can be determined from its initial description. This assumption is restrictive for long-horizon interaction, where new requirements emerge from intermediate observations, execution outcomes, and newly revealed constraints. This motivates just-in-time skill retrieval, which dynamically selects skills as execution unfolds. Just-in-time skill retrieval is promising but challenging: the utility of a skill depends not only on the current context, but also on the evolving task state shaped by prior steps. To this end, we propose JitSkill, a state-grounded framework that addresses this challenge through continuous task-state tracking. By connecting emerging requirements with accumulated task progress, JitSkill provides procedural support throughout execution without treating each retrieval decision independently. Experiments across three agent benchmarks demonstrate its effectiveness in improving long-horizon task completion. Our code is available at https://github.com/XMUDeepLIT/JitSkill.git/.

1 Introduction

Large Language Model (LLM)-based agents increasingly rely on external knowledge to support complex reasoning, tool use, and interaction with their environments (Feng et al., 2026; Zhou et al., 2026b; Huang et al., 2026; Wu et al., 2026b; Yuan et al., 2026; Jang et al., 2026). Among different forms of external knowledge, skills provide a natural representation of procedural experience: they

capture how an agent accomplishes recurring goals or operations by encoding successful task executions as reusable procedures that agents can invoke again when similar demands arise (Xia et al., 2026; Wu et al., 2026b; Yu et al., 2026). As these skills accumulate across tasks, external skill libraries provide agents with a growing repository of procedural knowledge that can complement their underlying reasoning and action capabilities (Wang et al., 2023; Li et al., 2026d; Zhang et al., 2026).

As skill libraries continue to grow, exposing all available skills to an agent becomes increasingly impractical: it increases the context burden and introduces irrelevant or only partially relevant procedures that may interfere with subsequent reasoning (Su et al., 2026; Li et al., 2025; Kang et al., 2026). Existing approaches therefore largely formulate skill selection as a retrieval problem, aiming to identify a compact subset of useful skills from an expanding skill library. Early retrieval-based approaches primarily identify individual skills according to their relevance to the task, as exemplified by SkillFlow (Li et al., 2025) and SkillRouter (Zheng et al., 2026). More recent methods move beyond independent skill matching by explicitly modeling relationships among skills: GoS (Liu et al., 2026), GoSkills (Zeng et al., 2026), and CaSKG (Li et al., 2026f) exploit dependency, grouping, or causal relations to retrieve and organize structurally related skills. SkillAligner (Li et al., 2026c) further considers compatibility after retrieval, identifying mismatches among retrieved skills, task requirements, and execution interfaces and adapting skill fragments accordingly. Together, these advances have progressively extended skill retrieval from individual relevance matching to structured retrieval and alignment, enabling agents to access increasingly large and heterogeneous skill libraries.

Despite these advances, existing retrieval methods largely assume that the skills required for a task can be sufficiently determined from the information

*Equal contribution. †Corresponding authors.

Figure

Figure 1: Comparison of pre-execution and just-in-time skill retrieval. (a) Pre-execution skill retrieval can miss needs revealed during execution. (b) Just-in-time retrieval acquires skills on demand as needs become observable.

available before execution begins. This assumption becomes increasingly restrictive in long-horizon interactive tasks, where capability demands are not fully specified by the initial instruction but emerge progressively through intermediate observations, execution outcomes, and newly discovered constraints (Yao et al., 2023; Zhou et al., 2024). A skill set selected at the outset may therefore provide adequate support for the initial task description while failing to cover procedural needs that arise later in the trajectory. This limitation has motivated a shift toward just-in-time skill retrieval, where skills are retrieved on demand as task execution unfolds. Recent web and computer-use agents instantiate this paradigm by dynamically identifying skill requirements from the current observation, subgoal, or local execution context and retrieving corresponding skills when those requirements emerge (Li et al., 2026a; Chen et al., 2026). Rather than predicting all necessary skills from the initial task description, just-in-time retrieval allows the retrieved skill set to evolve with execution, retrieving skills when their corresponding needs actually become observable.

Just-in-time retrieval is promising but challenging. (i) Whether a skill is needed depends not only on the current context but also on prior execution. The same observation or subgoal can call for different procedural support depending on what has already been accomplished, which resources have been acquired, which attempts have failed, and which requirements remain unresolved (Bai et al., 2026; Zhou et al., 2026a; Xu et al., 2026). A skill that is useful early in a trajectory may become redundant once the requirement it addresses has been satisfied, or even conflict with decisions established later in execution. Consequently, retrieving

skills only from the current observation or local sub-goal can produce individually reasonable decisions that are inconsistent with the task's accumulated progress. (ii) Maintaining a task state that reliably guides skill retrieval and execution is challenging. Simply retaining the full history can obscure the task-relevant consequences of prior interactions, causing the agent to repeat completed work, revisit invalidated paths, or overlook commitments that should constrain subsequent skill decisions. Together, these challenges create a fundamental risk in just-in-time retrieval: locally relevant skills can be repeatedly selected and successfully executed without forming a coherent trajectory toward the remaining task goals. We refer to this failure as execution drift, which manifests as redundant exploration or execution-consistency deviation.

To address these challenges, we propose JIT-SKILL, a state-grounded skill retrieval framework that couples just-in-time skill retrieval with long-horizon task-state tracking. Rather than treating each retrieval decision as an independent response to the current context, JITSKILL continuously maintains a compact representation of the task state and uses it to guide both skill retrieval and subsequent execution. Specifically, it maintains complementary explicit and latent representations that together constitute the task state. The explicit record organizes prior operations, their outcomes, and failure feedback into accessible textual evidence, while the latent representation recurrently summarizes historical interactions that cannot be fully retained in bounded explicit fields. At each decision point, the skill navigator grounds just-in-time skill retrieval in the tracked task state while responding to the current execution context.

Figure

(a)

Figure

(b)

(c)

Figure 2: Preliminary analysis of skill retrieval. (a) A travel-task example illustrating errors caused by over-looking prior execution progress. (b) Comparison of initial and online retrieval on AppWorld in terms of stage-specific skill coverage (Hit@3) and task goal completion (TGC) by difficulty. (c) Redundant exploration and execution-consistency deviation under local-context, full-history, and structured-history retrieval.

The executor receives the selected skills together with the explicit record and latent state tokens to execute the next action. The resulting action and environment feedback subsequently update the task state, allowing their consequences to inform later retrieval decisions. In this way, task state serves as a persistent bridge between past execution and future skill decisions, allowing skill retrieval and execution to evolve with the trajectory without losing sight of what has already been established and what remains to be accomplished.

Our contributions are as follows:

  • We identify two limitations of existing skill retrieval paradigms: fixed pre-execution skill retrieval cannot cover demands that emerge as a task progresses, while local online matching cannot determine whether selected skills remain consistent with accumulated task progress. We show why treating each retrieval decision as an independent response to the current context leaves both unresolved.

  • We introduce JITSKILL, a task-state-grounded

framework for just-in-time skill retrieval. It tracks task progress through complementary explicit and latent states, which guide on-demand retrieval and are provided to the executor for state-aware skill execution.

  • Across SkillsBench, ALFWorld, and τ2\tau^{2}-Bench, JITSKILL achieves the highest overall task success rates, with a 20.6% relative improvement over the strongest baseline on SkillsBench. Ablation results further support the benefit of jointly grounding skill retrieval and execution in the tracked task progress.

References (1)