Functional Cache Grafting: Robust and Rapid Code-Policy Synthesis for Embodied Agents
Abstract
Lay Summary
We study how robots can use large language models to write control code more quickly and reliably. Recent robots can translate natural language instructions into executable programs, but they often need to process long prompts again and again for every new task. When the generated code fails, the robot may also need to regenerate the full program, which slows down execution and can make the robot less responsive in dynamic environments. We propose FCGRAFT, a framework that lets the robot reuse previously successful code at the function level. Instead of generating every policy from scratch, FCGRAFT stores validated robot-control functions together with their internal model caches. It then stitches relevant functions together for a new task and patches only the small code region that needs correction when an error occurs. This makes robot policy generation faster while also improving reliability. By reusing validated control structures, FCGRAFT reduces inconsistent code, API mistakes, and missing safety checks, helping embodied agents act more robustly in open-domain and real-world tasks.