Efficient Skill Grounding via Code Refactoring with Small Language Models
Abstract
Effective skill grounding is essential for deploying reusable skills in embodied agents, as even minor embodiment or environmental differences can render an entire skill incompatible. This challenge is particularly pronounced in embodied settings, where agents must operate in dynamic, partially observable environments without access to large language models (LLMs). In this setting, reliance on LLMs is impractical, while small language models (sLMs) remain insufficient for the effective skill grounding required for reliable long-horizon control. We present RECENT, a refactoring-centric agent framework that enables efficient skill grounding with sLMs by decoupling skill semantics from embodiment- and environment-specific execution binding. By representing skills as executable code, RECENT preserves the semantic intent encoded in a skill’s control structure while grounding it by modifying only execution bindings through localized refactoring, rather than regenerating code from scratch. We evaluate RECENT across diverse skill grounding scenarios spanning multiple robot embodiments in dynamic environments, demonstrating robust long-horizon performance when deployed with an sLM. Across all scenarios, RECENT achieves the best performance among sLM-based Code-as-Policies (CaP) methods and matches the task performance of LLM-based CaP.
Lay Summary
We present RECENT, a refactoring-centric agent framework that enables small language models to adapt reusable robot skills to new embodiments and environments. The key challenge is that robot skills are tied to embodiment- and environment-specific execution details, so reusing them requires grounding these details in each new setting. This is difficult under limited computational resources, where agents cannot rely on large language models. In RECENT, each reusable skill is represented as executable code whose task intent is validated on a reference robot, with robot-specific execution details isolated for later editing. At deployment time, a skill ontology, a structured map of robot skills and capabilities, identifies which code parts need to change, and a small language model edits only those local parts instead of rewriting the whole skill. During execution, lightweight checks detect likely environment-dependent failures early and patch only the affected code. Across simulated and real-world manipulation tasks, RECENT improves long-horizon task success while reducing adaptation cost, execution interruptions, and idle time. These results suggest that targeted code editing can make reusable robot skills more scalable and reliable under limited computational resources.