Manuscript Offprint

arXiv:2609.31076

Up and Down the Abstraction Ladder: Code-Based Skills for Language Agents

Bartłomiej Cupiał, Jens Tuyls, Maciej Wołczyk, Davide Paglieri, Martin Klissarov, Benjamin Eysenbach, Piotr Miłoś, Karthik R. Narasimhan

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

Abstract

Language agents struggle to act and learn in environments that require long sequences of low-level actions. Code-based abstractions can make these agents more productive by letting them invoke reusable skills instead of repeatedly selecting individual actions. The code handles recurring local decisions, while the language model decides which skills to use and how to combine them. Yet abstractions are leaky, and situations beyond a skill's capabilities may require a return to primitive actions. Motivated by this tradeoff between productivity and flexibility, we systematically study how code-based action abstraction affects the performance, inference cost, and learning of language agents. We study this in NetHack, a challenging, long-horizon game environment, using CodeHack, our library of code-based skills with natural-language descriptions. We use this library to compare agents restricted to primitives with those using semantic skills alone or in combination with primitives. We evaluate these agents in three settings: zero-shot prompting, supervised fine-tuning, and reinforcement learning. Across a broad zero-shot evaluation on NetHack, we find that compared with primitives, skills nearly triple game progression, while reducing inference cost per episode by 86%. Combining skills with primitives retains much of this benefit while preserving a path back down to low-level actions. Finally, in RL, we find that skill-based agents learn significantly faster than agents acting on primitives, achieving a 7.2x larger average gain in dungeon level over the same training budget. These results show that a supplied skill library can improve performance, efficiency, and learning, while retaining primitives provides flexibility when the library is insufficient. We release CodeHack together with training and evaluation code.

Project page: bartekcupial.github.io/abstraction-ladder/

1 Introduction

As language models (LMs) transition into autonomous agents, they are increasingly tasked with complex, long-horizon problems, ranging from software engineering [Yang et al., 2024] and computer use [Xie et al., 2024, Yuan et al., 2026] to embodied control [Liang et al., 2023]. Many of these environments require chaining together long sequences of low-level, primitive actions, such as precise mouse clicks and keystrokes for computer use agents, or chains of cd and ls commands for software engineering agents. While operating on this primitive action space allows for the finest level of control, it can also be costly, and elevating the action interface to a higher level of temporal abstraction can help facilitate learning and exploration [Sutton et al., 1999, Nachum et al., 2019].

1^{1} University of Warsaw; 2^{2} Princeton University; 3^{3} IDEAS NCBR; 4^{4} University College London; 5^{5} McGill University;

6^{6} AKCES NCBR; 7^{7} Mila; 8^{8} Mistral AI; 9^{9} Institute of Mathematics, Polish Academy of Sciences.

†^{\dagger} Our title is inspired by the following blog: https://worrydream.com/LadderOfAbstraction/.

Preprint.

Past approaches have addressed these challenges through agent-computer interfaces [Yang et al., 2024, Wang et al., 2024] and temporal abstractions [Sutton et al., 1999]. However, to the best of our knowledge, no study has examined the empirical benefits and tradeoffs of using primitive actions, higher-level skills, or a mixture of both for language agents in long-horizon settings. This paper aims to fill that gap by studying the use of temporally extended code-based actions, or “skills.” Skills, closely related to options in hierarchical reinforcement learning [Sutton et al., 1999, Bacon et al., 2017, Klissarov et al., 2025a], execute sequences of primitive actions behind a semantically meaningful interface. Rather than learning the skills themselves, we ask how useful a fixed library of such skills is for language-model agents and learned controllers. To make this comparison possible, we build CodeHack, a code-based skill library for

Figure

Figure 1: The value of skills vs. primitives for language agents in NetHack. Higher-level, semantically meaningful skills provided by CodeHack improve performance both in zero-shot use and during RL. Learning curves are for Qwen-3.5-4B.

NetHack and MiniHack that exposes the same environment through primitive-only, skill-only, and mixed action interfaces. Code-based skills are natural for language agents because they can be described in language and inspected as source code. They also open a path toward agents that construct and refine these skills themselves [Liang et al., 2023, Wang et al., 2024].

We first compare skills with primitives in MiniHack, where controlled tasks let us isolate navigation, exploration, combat, and item-use. We then use NetHack as our main domain because completing it remains a longstanding challenge, despite extensive work on RL, imitation learning, and language-based control [Piterbarg et al., 2023, Tuyls et al., 2024, Wolczyk et al., 2024, Paglieri et al., 2025]. Successful games span tens to hundreds of thousands of turns, while a single mistake can end a run [Kuttler et al., 2020]. The variety of situations agents can encounter in NetHack also makes pure skill abstraction incomplete in practice as no practical fixed library can anticipate every contingency, so agents may still need to move back down to primitive control when abstractions are poorly matched to the current state. We therefore also evaluate mixed control on NetHack, which allows the agent to move up and down the abstraction ladder.

Contributions. In this paper, we provide a systematic study of action abstraction for long-horizon language agents. Specifically, our work makes the following contributions:

  1. CodeHack. We develop and release CodeHack, an open-source library of reusable Python skills for NetHack and MiniHack, together with training and evaluation code for studying primitive-only, skill-only, and mixed control.

  2. A systematic study of action abstraction. We compare agents that use primitives, skills, or both, in zero-shot, SFT, and RL settings, and present careful ablations relevant to skill coverage.

• Zero-shot control. Skills improve success rates on every evaluated MiniHack task, with an average gain of 55 percentage points over primitive control. These benefits extend to NetHack, where skills nearly triple average progression across 14 models while reducing inference cost per episode by 86% relative to primitives. Adding primitives alongside skills preserves most of these performance benefits, although at a higher inference cost than skill-only control.

• Learning with RL. We study how the action interface affects learning under a fixed RL budget in NetHack. Averaged across two models, skill-only and mixed controllers achieve gains in dungeon depth 7.2 and 8.6 times those of primitive-only controllers, respectively. These larger gains widen the absolute performance gap already present in zero-shot evaluation, showing that the benefits of skills extend to learning.

• Incomplete skill coverage. We investigate whether retaining access to primitive actions alongside skills helps compensate for incomplete skill coverage, and find that mixed control is generally less affected by missing skills than skill-only control. Selected trajectories illustrate how primitive fallback works in practice, with agents using primitives to resolve situations that the available skills cannot handle before returning to skills.

Figure

Figure 2: CodeHack as a shared control layer for primitive-only, skill-only, and mixed agents. 1. The controller can be either a language-model agent or a learned RL policy, since CodeHack supports both natural-language control and a discrete action-space interface. 2. Depending on the configured action interface, the controller selects code skills such as explore or fight_melee, primitive commands such as movement, kick, or search, or both. 3. All three interfaces use the same runtime for symbolic state, inventory tracking, map memory, panic handlers, and no-progress feedback. Primitive commands are registered as one-step strategies. Code skills can expand into multiple primitives. 4. This runtime supports both NetHack and MiniHack, allowing the same skill library to transfer across environments while preserving a path back to low-level control when abstractions are insufficient.

References (85)

  • gpt-oss-120b & gpt-oss-20b Model Card
  • Grounding language in robotic affordances (opens arXiv in a new tab)
  • The option-critic architecture
  • Language as a Cognitive Tool to Imagine Goals in Curiosity-Driven Exploration
  • Feudal reinforcement learning
  • Metacognitive capabilities of llms: An exploration in mathematical problem solving
  • Diversity is all you need: Learning skills without a reward function
  • Meta Learning Shared Hierarchies
  • Gemma 3 Technical Report
  • A nethack learning environment language wrapper for autonomous agents (opens the publisher in a new tab)
  • The Llama 3 Herd of Models
  • DeepSeek-R1 incentivizes reasoning in LLMs through reinforcement learning
  • Swe-skills-bench: Do agent skills actually help in real-world software engineering? arXiv preprint arXiv:2603.15401, 2026 (opens arXiv in a new tab)
  • Fast task inference with variational intrinsic successor features
  • Voxposer: Composable 3d value maps for robotic manipulation with language models (opens arXiv in a new tab)
  • Playing nethack with llms: Potential & limitations as zero-shot agents
  • Options of interest: Temporal abstraction with interest functions
  • Motif: Intrinsic Motivation from Artificial Intelligence Feedback
  • Discovering temporal structure: An overview of hierarchical reinforcement learning (opens arXiv in a new tab)
  • Maestromotif: Skill design from artificial intelligence feedback
  • Skill Discovery in Continuous Reinforcement Learning Domains using Skill Chaining
  • The nethack learning environment
  • Language Models as Zero-Shot Trajectory Generators
  • Trust region masking for long-horizon llm reinforcement learning (opens arXiv in a new tab)
  • Code as policies: Language model programs for embodied control
  • When speed kills stability: Demystifying RL collapse from the training-inference mismatch, September 2025
  • Eureka: Human-Level Reward Design via Coding Large Language Models
  • A laplacian framework for option discovery in reinforcement learning
  • Automatic discovery of subgoals in reinforcement learning using diverse density
  • Data-efficient hierarchical reinforcement learning
  • Why does hierarchy (sometimes) work so well in reinforcement learning? arXiv preprint arXiv:1909.10618, 2019 (opens arXiv in a new tab)
  • Balrog: Benchmarking agentic llm and vlm reasoning on games
  • Hiql: Offline goal-conditioned rl with latent states as actions
  • Metra: Scalable unsupervised rl with metric-aware abstraction
  • Reinforcement learning with hierarchies of machines
  • Nethack is hard to hack
  • diff history for neural language agents
  • Team Qwen. Qwen3. 5-omni technical report. arXiv preprint arXiv:2604.15804, 2026. (opens arXiv in a new tab)
  • Minihack the planet: A sandbox for open-ended reinforcement learning research (opens arXiv in a new tab)
  • Toolformer: Language models can teach themselves to use tools
  • Proximal policy optimization algorithms
  • Dynamics-aware unsupervised discovery of skills
  • From llms to actions: Latent codes as bridges in hierarchical robot control
  • Mastering the game of go with deep neural networks and tree search (opens the publisher in a new tab)
  • OpenAI GPT-5 System Card
  • Learning options in reinforcement learning
  • Between mdps and semi-mdps: A framework for temporal abstraction in reinforcement learning (opens the publisher in a new tab)
  • Scaling laws for imitation learning in single-agent games
  • Voyager: An open-ended embodied agent with large language models
  • Fine-tuning reinforcement learning models is secretly a forgetting mitigation problem
  • Benchmarking multimodal agents for open-ended tasks in real computer environments
  • Swe-agent: Agent-computer interfaces enable automated software engineering
  • 0: Benchmarking computer use agents on long-horizon real-world tasks (opens arXiv in a new tab)
  • Whereas Section 3 introduces the library at a high level, the goal of this appendix is to make the artifact easier to understand, reproduce, and extend
  • Its role is to expose temporally extended, semantically named actions while preserving a path back to lower-level control when finer intervention is needed
  • We implemented these behaviors as Python procedures and tested them through end-to-end tests, human playthroughs, and GPT-5 playthroughs
  • This wrapper instantiates the internal CodeHack runtime, registers a configurable set of strategies, registers panic handlers, and can optionally expose selected primitive commands as one-step strategies
  • This is the main experimental advantage of the wrapper: it lets us vary abstraction level without rewriting the environment or the execution machinery
  • At every primitive step, this runtime updates its cache, so skills can reason over symbolic entities such as rooms, items, monsters, and reachability instead of repeatedly parsing raw tensors from scratch
  • A skill can depend not only on what is visible now, but also on previously observed map structure such as earlier rooms, corridors, stairs, doors, and hazards
  • We group them by broad behavioral role
  • explore, goto_corridor, goto_corridor_east, goto_corridor_north, goto_corridor_south, goto_corridor_west, goto_room, goto_room_east, goto_room_north, goto_room_south, goto_room_west, descend_stairs, ascend_stairs, gotoCorpse, search_corridor_for_hidden_doors, and search_room_for_hidden_doors
  • engrave_elbereth, fight_engulfed, fight_melee, fight_ranged, zap_monster, approach_monster, goto_choke_point, wait_for_monster, and escape_trap
  • open_doors, open_doors_kick, open_doors_key, goto_boulder, push_boulder_east, push_boulder_north, push_boulder_south, push_boulder_west, leave_shop, identify_items_altar, and dip_for_excalibur
  • The default observation space includes symbolic views of the visible dungeon map together with textual and structured information such as the current message, the hero's bottom-line statistics, and the inventory
  • However, interacting with NetHack through its terminal interface often requires action chaining: many semantically simple behaviors are implemented as sequences of low-level key presses
  • We use this metric as our main measure of human-like game progress in NetHack
  • The standard Corridor and Quest families come directly from MiniHack, while our Corridor-R10 evaluation level is a custom extension of the Corridor family and simulates exploration of a single NetHack level
  • The available-action lists and descriptions change to match the selected interface
  • For RL from base, the model is trained directly from the base model without SFT warm-starting
  • Each environment worker maintains a separate environment instance and sends its observation and interaction history to vLLM to generate the next action
  • This reduces idle time but introduces policy lag, as the collected data may come from an earlier version of the policy
  • We use reasoning mode for GPT-5, GPT-OSS-120B, Gemma-4, and Qwen-3.5, and act-only mode for Llama and Gemma3
  • Gray ± terms are standard errors across episodes
  • Gray ± terms are standard errors across paired model-level means
  • Here, coverage refers to whether the available skills provide the behaviors needed in the situations the agent encounters
  • We identify sequences in which primitives complete menus, recover from failed skills, or supply behaviors missing from the library, after which the agent returns to skills
  • 486–487: east follows the corridor.</td><td>488: explore resumes navigation.</td></tr></table>
  • The vault sequence illustrates that this choice can be inefficient
  • Bars show the share of parsed calls attributed to skills, primitives, and invalid outputs, aggregated across all evaluation episodes in each stage
  • We do not show primitive-only and skill-only interfaces, because the distributions collapse to 0 or 1 by construction
  • When skills and primitives are pooled together, explore remains the single most common action both before and after training
  • Skill-only RL becomes even more concentrated on a handful of reusable routines, with explore dominating and combat, door handling, staircase navigation, and hidden-door search accounting for much of the remaining mass
  • Primitive-only control remains dominated by local movement and search
  • We report average success rates