Title: Ca$^2$P: Cache-Augmented Code-as-Policies for Open-Domain Embodied Tasks
Primary area: applications to robotics, autonomy, planning
Keywords: LLM, KV Cache, Embodied AI

Abstract: Embodied agents deployed in open-domain environments must continuously handle unpredictable tasks beyond predefined action policies. Such tasks are often given as natural language instructions, and recent progress in code-writing large language models (CodeLLMs) has inspired the Code-as-Policies (CaP) paradigm, where instructions are translated into executable control code when issued. However, generating full code from scratch for each instruction incurs high latency and inconsistency, limiting CaP's practicality in real-world, time-sensitive scenarios. To address these limitations, we present Ca$^2$P, a Cache-Augmented Code-as-Policies framework that improves CodeLLM-based robotic programming by introducing function-level key-value (KV) caching, a repurposed and extended form of the native KV caching mechanism tailored for function reuse, together with cache-augmented code policy synthesis. Ca$^2$P decomposes previously generated and validated code policies and stores them as function-level KV caches, supporting efficient compositional programming, where new policies are synthesized by invoking cached functions directly through their KV states. Furthermore, by revisiting and editing cached functions within their KV states, Ca$^2$P provides cache-refactoring, thereby enabling efficient synthesis of task-specific code policies without the need for full regeneration. Evaluated on ALFRED, TEACh, and RLBench benchmarks together with real-world robot manipulation, Ca$^2$P achieves the best trade-off between robustness and latency, with $19.80\%$ higher task success rate and $2.91\times$ faster policy synthesis than the CaP baseline.

TL;DR: Ca$^2$P: Cache-Augmented Code-as-Policies for Open-Domain Embodied Tasks