Declarative Reactive Robot Behaviors from Imperative Language Models
Organizations: Max Planck Institute for Intelligent Systems, Tübingen, Germany · University of Oxford, Oxford, United Kingdom · ELLIS Institute Tübingen, Germany · ETH Zürich, Zürich, Switzerland
Abstract
Large Language Models (LLMs) are predominantly trained on imperative programming languages, and existing work on LLM-based robot programming reflects this: it focuses on goal-directed tasks expressed as plans. However, many robotic applications require not tasks but behaviors--open-ended, continuous patterns of sensory-motor engagement with no termination condition (e.g., greeting visitors, patrolling an area). Such behaviors are better served by declarative and reactive programming, on which LLMs have virtually no training. We investigate whether this gap can be bridged. Using Playful, a reactive scripting language, we show that an LLM-based coding agent can generate correct declarative and reactive programs for robotic behaviors. These programs are produced from under-specified natural language descriptions, given suitable context and a set of reusable programming guidelines. The guidelines encode design principles that redirect the agent from imperative defaults toward proper reactive patterns. Developed once by an expert, they generalize across robots and behaviors. Starting from only the generic robot operating system API, the agent jointly designs both the imperative component (Python modules for sensing, acting, and evaluating) and the declarative component (the reactive script that composes them into behavior logic). The declarative nature of reactive programming supports both incremental refinement through conversational turns and one-shot generation of complete behaviors.
Figures & tables
| Category | Overview |
|---|---|
| Script as source of truth | The playful script must fully describe the behavior; reading Python should not be necessary. |
| Targeting and generality | Nodes and evaluations are generic; scheme-type binding is expressed only in the script via targeting . |
| Scheme types | Distinct behavioral roles require distinct scheme types. |
| Naming | Names must be generic and action-oriented. |
| Resource granularity | Resources map one-to-one to independently controllable API channels and to nodes. |
| Safety | Safety constraints must be visible in the script, not hidden in Python. |
| Element type | Guidelines | No guidelines |
|---|---|---|
| Script logical elements | ||
| Activation conditions ( targeting ) | 10 | 0 |
| Activation conditions ( while ) | 10 | 16 |
| Priority assignments | 56 | 20 |
| Mode transitions | 0 | 4 |
| Subtotal | 76 | 40 |
| Code source | Guidelines | No guidelines |
|---|---|---|
| New lines (from guardian) | 144 | 263 |
| Reused lines (from greeter) | 225 | 47 |
| Total lines | 369 | 310 |
| Reuse ratio | 61% | 15% |
LLM-Based Program Synthesis
Large language model (LLM)-based program synthesis turns natural-language goals and examples into executable programs, often using tests or formal constraints.
See all 307 papers