TL;DR
SpeedRunner introduces a purely online "wake-sleep" framework that allows LLM agents to learn cost-effective programmatic skills by using a coding agent to analyze their own trajectory history. By offloading repetitive reasoning into deterministic, executable code, it drastically reduces inference costs (up to 8x) while matching or exceeding state-of-the-art performance across complex embodied environments.
What Problem Does This Paper Address?
As Large Language Model (LLM) agents are increasingly deployed in real-world scenarios, they must adapt to changing environments on the job. While augmenting agents with a library of "skills" helps them adapt, most existing frameworks represent these skills using natural language descriptions. This forces the agent to re-read and re-reason through the same routines over and over again, driving up token consumption and financial costs.
Programmatic skill learning—where skills are stored as executable code—offers a solution by offloading reasoning to a cheap, deterministic execution environment. However, current programmatic methods rely on unrealistic assumptions, such as the ability to "rewind" or "replay" environment states to validate new code. The authors tackle a major challenge: How can an LLM agent learn structured, programmatic skills in a purely online setting where actions are irreversible and trial-and-error is costly?
Methods
The authors propose SpeedRunner, a framework structured around an alternating Wake-Sleep cycle:
- Wake Phase: The actor agent ($\pi_L$) receives tasks and executes them in the environment using its current library of callable Python functions ($L$), generating a history of raw trajectories ($H$).
- Sleep Phase: An "inducer" agent (a coding agent equipped with a code execution environment) surgically analyzes these trajectories. Instead of stuffing massive, raw text traces into an LLM context window, the inducer writes Python code to query failures, aggregate cross-episode statistics, and diagnose regressions.
Based on this programmatic analysis, the inducer refactors the skill library. Crucially, SpeedRunner introduces public and private access modifiers to the skill library. Helper functions are marked private and hidden from the main actor agent, keeping its context window clean and preventing performance degradation from "tool bloat."
Datasets
SpeedRunner was evaluated across three diverse text-based embodied benchmarks:
- ScienceWorld: A simulator grounded in elementary school science curricula. The authors tested on the Electricity (Task 3) and Classification (Task 4) subtasks.
- BabyAI (via the BALROG wrapper): A 2D grid-world requiring instruction-following under partial observability. Evaluation focused on the complex pick_up_seq_go_to task.
- Crafter: An open-ended survival benchmark inspired by Minecraft, where agents must gather resources, craft tools, and survive hazards.
Key Insights and Ideas
- Code as a Cheap Turing Machine: Translating an agent's repetitive behavioral routines into code effectively offloads the computational burden from an expensive LLM to a deterministic execution environment, maximizing token efficiency.
- Surgical Trace Analysis: Rather than relying on lossy text summaries or massive context windows to review past actions, an agent can use a code interpreter to query its own history. For example, it can programmatically count how many times a specific function returned a "not found" error to identify systemic visibility bugs.
- Composition Over Accumulation: Unlike baseline methods that continuously append new, scenario-specific functions, SpeedRunner refactors its library into deeper, denser call graphs. It creates high-level abstractions that reuse existing helper functions, leading to highly compact codebooks.
Key Results
SpeedRunner consistently dominated baselines (including ReAct, Online Prompt Optimization, and Voyager) in both performance and cost-effectiveness.
- Dramatic Cost Reduction: On the BabyAI benchmark, SpeedRunner reduced final token costs to roughly an eighth (1/8x) of the ReAct baseline while achieving near-perfect task performance.
- Robustness to Randomness: In Crafter, the authors varied environmental stochasticity by doubling the zombie spawn rate. While prose-based memory and append-only code baselines collapsed under high randomness, SpeedRunner adapted by refactoring its existing skills to be combat-aware, maintaining its performance edge.
- Distribution Shift Resilience: When switched midway from the ScienceWorld Electricity task to the Classification task, SpeedRunner successfully adapted its procedural knowledge, maintaining a compact library of ~40 functions compared to the Agent Skill Induction (ASI) baseline, which bloated to ~160 functions.
Limitations and Future Work
- Model Scope: Due to API cost constraints, the authors evaluated their framework using smaller models (GPT-5.4-mini, Gemini-3-Flash, and Qwen-3.5-27B) rather than flagship models, and omitted expensive benchmarks like SWE-bench.
- Instability in Online Learning: Like many online skill-induction frameworks, SpeedRunner suffers from high run-to-run variability and instability, as indicated by large error bars across different random seeds.
- Static Inducer Strategies: The inducer agent operates on fixed prompting strategies. The authors suggest that future work could explore meta-learning, allowing the inducer to improve its own trajectory analysis code over time.
Summary updated