Growing with Your Embodied Agent: A Human-in-the-Loop Lifelong Code Generation Framework for Long-Horizon Manipulation Skills

Yuan Meng, Zhenguo Sun, Max Fest, Xukun Li, Zhenshan Bing, Alois Knoll · DOI

Abstract

Large Language Models (LLMs) have demonstrated significant potential in generating robotic control code. However, current "Code-as-Policies" approaches often struggle with long-horizon tasks due to context window limitations, reasoning failures, and catastrophic forgetting. We introduce LYRA, a human-in-the-loop framework that enables robots to learn, store, and retrieve reusable manipulation skills through lifelong code generation. By combining human feedback with Retrieval-Augmented Generation (RAG), LYRA achieves a 0.93 success rate on complex tasks and executes sequences requiring over 20 primitive actions.

Introduction

While LLMs can translate natural language into executable Python code for robots, they face three primary challenges in complex environments: the context window limit, which prevents the inclusion of numerous examples; reasoning failures in long-horizon tasks where physical nuances are missed; and catastrophic forgetting, where correcting the agent on new tasks degrades performance on previous ones. LYRA addresses these by enabling a robot to "grow" its capabilities through a permanent, modular skill library.

The LYRA Framework

LYRA operates through a three-phase lifecycle designed for continuous skill acquisition and refinement.

The three phases of the LYRA framework: Skill Acquisition, Capability Extension, and Task-specific Planning.
  1. Preference-aligned Skill Acquisition: A human interacts with the agent in a multi-turn loop. The human provides a task description, the LLM generates code, and the human offers corrective feedback (e.g., "stack ALL blocks, not just two") until the skill is perfected in simulation.
  2. Lifelong Capability Extension: To prevent forgetting, LYRA utilizes a "meta-prompt" instructing the LLM to preserve existing functionality while incorporating new features, such as handling different object colors or rotations.
  3. Task-specific Retrieval and Planning: For complex objectives, LYRA employs an external memory (ChromaDB) and RAG to retrieve only relevant skill headers and examples. A "hint" mechanism allows users to guide the RAG system toward specific skills (e.g., "use the jenga_layer skill") within a large library.

Experimental Evaluation

LYRA was evaluated across diverse benchmarks, including Ravens (tabletop manipulation), Franka Kitchen (household tasks), and MetaWorld (diverse manipulation). Real-world validation was conducted on a Franka FR3 robot arm using vision foundation models like SAM 2 for perception.

Performance comparison of LYRA against baselines. The radar chart shows LYRA's superior success rates across various tasks.

Key Results

  • Superior Performance: LYRA achieved a 0.93 average success rate, outperforming baselines like DAHLIA and Code-as-Policies by up to 27%.
  • Efficiency: The framework required 42% fewer feedback rounds than LLM-only closed-loop systems, demonstrating the value of human-guided skill refinement.
  • Extreme Long-Horizon Capability: LYRA successfully completed tasks like "build a house," involving 12 sub-skills and over 20 primitive steps—a complexity level previously unreachable for similar agents.
  • Cross-Embodiment Transfer: Learned skills transferred from simulation to real-world hardware with minimal adjustment, as the system generates high-level code calling core primitives.

Discussion and Future Work

LYRA highlights that encapsulating behaviors as modular "skill functions" is superior to generating flat code, as functions are easier to debug and reuse. Furthermore, human verification proved more robust than LLM self-correction, which often produces false positives.

While highly effective, current limitations include a dependency on high-fidelity perception models and a manual curriculum design. Future work will explore automated curriculum generation and extending the framework to dual-arm or mobile manipulation.

Summary updated

BibTeX
@misc{meng2025growing,
  author = {Yuan Meng and Zhenguo Sun and Max Fest and Xukun Li and Zhenshan Bing and Alois Knoll},
  title = {{Growing with Your Embodied Agent: A Human-in-the-Loop Lifelong Code Generation Framework for Long-Horizon Manipulation Skills}},
  year = {2025},
  eprint = {2509.18597},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.18597},
}
Figure