Source-linked AI summary
Declarative Reactive Robot Behaviors from Imperative Language Models
Vincent Berenz, Tasha Kim, Bernhard Schölkopf
TL;DR
Robotic behaviors are open-ended and continuous, but LLM robot programming has largely focused on imperative task plans, while reactive programming is underrepresented in training. The paper uses PLAYFUL with expert-authored guidelines to generate behavior scripts and their Python primitives from under-specified language descriptions; its experiments show that the agent can produce well-designed applications and handle that under-specification.
Problem
LLM-based robot programming has focused on goal-directed tasks, while open-ended robotic behaviors require continuous reactive engagement and declarative programming that LLMs have little exposure to.
Source: §I · p. 1Method
The agent uses language documentation, a tutorial, and expert-authored reusable guidelines to jointly design PLAYFUL scripts and the Python modules they compose, starting from a generic robot OS API.
Source: §I · p. 2Results
Experiments showed that an agent without PLAYFUL training could produce well-designed applications with paradigm-level guidelines, jointly develop imperative and declarative layers, and handle under-specified descriptions.
Source: §V · p. 5Takeaways & Limitations
Expert-authored design principles can redirect an LLM coding agent toward sound reactive design, yielding readable scripts users can inspect and refine through conversation.
Source: §VI · p. 6
Abstract
from arXiv · showhide
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.
I. INTRODUCTION
The paper addresses whether an LLM can generate open-ended robotic behaviors with declarative reactive programs despite limited exposure to reactive languages. It tests whether suitable context and expert-authored guidelines let an agent handle under-specified descriptions while jointly creating the robot-facing Python modules and behavior scripts.
I. INTRODUCTION
- Robotic behaviors are open-ended, continuous sensorimotor patterns without a single success criterion or termination condition, requiring continuous evaluation and adaptation.The paper contrasts these behaviors with goal-directed tasks that have explicit success criteria and termination conditions.Source: §I · p. 1
- PLAYFUL combines Python modules for sensing, acting, and evaluation with declarative scripts that compose them into hierarchically evaluated behavior logic.The script is continuously evaluated at runtime to form behavior trees.Source: §I · p. 1
- Natural-language behavior descriptions leave low-level choices implicit, and the paper asks whether an agent can fill them appropriately while users correct mismatches incrementally.Examples include stopping distance, gaze direction, and arbitration between competing actions.Source: §I · p. 1
- With reusable expert-authored guidelines and suitable context, the agent generates correct PLAYFUL programs despite no prior training on the language or reactive paradigm.The agent jointly develops Python modules and declarative scripts, with the guidelines steering the declarative component.Source: §I · p. 2
- The agent jointly designs reusable Python primitives and declarative scripts from a generic robot OS API, evaluated on Pepper across conversational development and two one-shot behavior-generation experiments.The experiments cover step-by-step development, one-shot generation of the same behavior, and one-shot generation of a novel behavior.Source: §I · p. 2
II. BACKGROUND AND RELATED WORK
The related work spans natural-language robot programming and LLM-based task execution. The paper distinguishes its editable, persistent reactive scripts from episodic task plans and opaque learned policies.
A. End-user and natural-language robot programming
- Pairing an LLM coding agent with a declarative reactive language produces human-readable scripts that users can inspect and refine through natural language.The paper presents this as a contribution to the longstanding goal of programming robots through natural interaction.Source: A. End-user and natural-language robot… · p. 2
B. LLMs for task-oriented robot execution
- Task-execution systems decompose commands into skill sequences and replan using feasibility, affordance, or execution feedback, but their outputs target objectives that terminate.Examples include SayCan, Inner Monologue, and ProgPrompt.Source: B. LLMs for task-oriented robot… · p. 2
- End-to-end visuomotor policies provide a contrasting direction, but yield opaque outputs users cannot inspect or incrementally refine.The passage contrasts these policies with transparent, editable scripts.Source: B. LLMs for task-oriented robot… · p. 2
C. LLM code generation for robotics
Prior robotic code-generation approaches predominantly produce imperative artifacts for task completion. Prior behavior-tree generation also targets task-oriented settings with predefined tree structures, whereas this work requires co-design of reactive scripts and their Python primitives.
C. LLM code generation for robotics
- Robotic LLM code-generation systems produce imperative code for task completion and generally call suitable APIs rather than implement their API-level primitives.Examples include ‘Code as Policies’, VoxPoser, and ‘Language to Rewards’.Source: C. LLM code generation for robotics · p. 2
D. LLMs and behavior trees
- Prior LLM behavior-tree systems focus on task-oriented behaviors with predefined node types and tree structures, unlike this work’s open-ended reactive setting.The passage identifies BTGenBot, BTGenBot-2 [27], BT-ACTION, and other approaches,.Source: D. LLMs and behavior trees · p. 2
- This work’s behavior-tree generation requires jointly designing the declarative tree and the Python modules implementing its primitive nodes.The passage characterizes this as a co-design problem not addressed by prior behavior-tree generation work.Source: D. LLMs and behavior trees · p. 2
E. Declarative and reactive behavior programming
PLAYFUL builds on declarative behavior trees and composes continuously evaluated condition-action rules with priority arbitration. Its applications pair reusable Python modules interfacing with the robot OS with scripts that compose them into behavior logic.
E. Declarative and reactive behavior programming
- Reactive robot-control foundations include Brooks’ subsumption architecture and Nilsson’s teleo-reactive programs, while temporal-logic approaches target task-like safety and liveness constraints.The passage contrasts those constraints with continuously evaluated, open-ended sensorimotor behaviors.Source: E. Declarative and reactive behavior… · pp. 2–3
- PLAYFUL builds on Targets-Drives-Means, whose independent declarative statements use priority-based arbitration, and targets natural-language generation without a pre-built primitive library.Prior PLAYFUL work generated scripts from human demonstrations.Source: E. Declarative and reactive behavior… · p. 3
III. REACTIVE PROGRAMMING AND PLAYFUL PLATFORM
- Figure 1 pairs a PLAYFUL script with its behavior-tree representation and marks how sensorimotor loops are enforced.The accompanying example concerns searching for a ball, looking at it when detected, and grasping it when close.Source: Figure 1 · p. 3, §III · p. 3
- PLAYFUL declares which conditions trigger actions; statement order is irrelevant because all statements are continuously evaluated at runtime.Primitives activate when their conditions hold, and competing primitives can share resources.Source: §III · p. 3
- On Pepper, the greeter transitions from idle scanning to engagement, while the guardian patrols and intercepts a visitor using priority arbitration and reused primitives.The targeting keyword binds objects to primitives, instantiating nodes per detected object; priorities are recomputed as the environment changes.Source: Figure 2 · p. 3
- A PLAYFUL application combines reusable Python modules interfacing with the robot OS and a declarative script composing them into behavior logic.The formal semantics are described in.Source: §III · p. 3
IV. EXPERIMENTS
The experiments test whether an agent without prior PLAYFUL training can build well-structured robotic applications from under-specified instructions when given paradigm-level guidelines. The setup uses Pepper, a generic ROS API, language documentation, a tutorial, and guidelines.
IV. EXPERIMENTS
- The experiments evaluate guideline-guided generation of PLAYFUL applications from under-specified natural-language instructions using Pepper and Claude Code Opus 4.6.The agent receives the PLAYFUL language description, a developer tutorial, and the Pepper ROS API reference.Source: §IV · p. 3
- The API exposes basic preemptible sensor and actuator functions, with no advanced control libraries or pre-existing PLAYFUL primitives.The agent must implement the Python artifacts and behavior trees itself.Source: §IV · p. 4
- Figure 3 provides the natural-language behavior instructions; Behavior 1 is developed both in one prompt and incrementally across conversational turns.The incremental version issues each step in a separate turn.Source: Figure 3 · p. 4
A. Developing the Guidelines
The agent initially defaulted to imperative code, placing behavior logic in Python instead of PLAYFUL’s declarative script. Expert-authored, reusable guidelines direct behavioral structure and arbitration into the script and keep Python modules as reusable building blocks.
A. Developing the Guidelines
- Without paradigm-level guidance, the agent often implemented behavioral logic in lower-level Python modules rather than with PLAYFUL script operators.The operators include targeting, while, and priority of.Source: A. Developing the Guidelines · p. 4
- The expert-authored guidelines make explicit that behavioral structure and arbitration belong in the declarative script, while Python modules should remain minimal, reusable building blocks.They address targeting, resource granularity, and code reuse.Source: A. Developing the Guidelines · p. 4
- The guidelines are platform-independent and were not derived from a systematic analysis of the agent’s generated programs.The authors state that the guidelines would also be useful to human programmers.Source: A. Developing the Guidelines · p. 4
B. Developing the Behavior
With and without paradigm-level guidelines, the agent generated complete, functional greeter and guardian implementations in a single pass. Despite under-specified instructions, it inferred reasonable defaults, while the implementations differed in readability and reusability.
B. Developing the Behavior
- In both conditions, the agent generated complete, functional greeter and guardian implementations in a single pass, including Python modules and PLAYFUL scripts.The corresponding tree representations are shown in Figure 4.Source: B. Developing the Behavior · p. 5
- Despite under-specified instructions, the agent inferred defaults such as human search, battery management prioritization, LED control policies, and a home-distance constraint.Source: B. Developing the Behavior · p. 5
- The implementations produced with and without guidelines differed significantly in script readability and code reusability.Source: B. Developing the Behavior · p. 5
C. The Impact of Guidelines
Guidelines shift behavioral logic from Python into declarative PLAYFUL scripts, where targeting makes object–action–logic relationships explicit. This increased declarativity accompanies greater reuse of Python code in the guardian behavior.
C. The Impact of Guidelines
- The targeting keyword appears only in guideline-compliant scripts and makes object–action–logic relationships explicit, shifting behavioral logic out of Python and into the scripts.Source: C. The Impact of Guidelines · p. 5
- With guidelines, the script-to-Python logic ratio is 4.0; without guidelines, it is 1.0.Guideline-compliant scripts handle activation conditions and priorities, while the no-guideline version embeds activation conditions and many behavioral conditions and memory accesses in Python.Source: C. The Impact of Guidelines · p. 5
- 61% of the greeter’s Python code is reused by the guideline-compliant guardian, versus 15% without guidelines, despite similar total code size.The authors connect explicit object–action–logic relationships with more generic and reusable Python primitives.Source: Table III · p. 5, C. The Impact of Guidelines · p. 5
D. Iterative Development
The greeter behavior was iteratively refined through six natural-language instructions, with each iteration extending a functional behavior tree without substantial restructuring.
D. Iterative Development
- Across six successive instructions, each iteration produced a functional behavior tree that incorporated new requirements without substantial restructuring.This supports progressive refinement and correction through multiple conversational interactions.Source: D. Iterative Development · p. 5
V. DISCUSSION AND FUTURE WORK
The experiments show that an agent without prior PLAYFUL training can generate functional, well-structured robotic applications when guided by paradigm-level guidelines, including from under-specified instructions. The discussion highlights reusable primitives and inspectable scripts, while identifying the work as an initial proof of concept with important scope limits.
V. DISCUSSION AND FUTURE WORK
- The agent generated complete, functional implementations of the greeter and guardian behaviors in one pass, jointly producing Python modules and PLAYFUL scripts.The experiments also report that paradigm-level guidelines support well-designed applications and handling under-specification, despite no prior training on PLAYFUL.Source: §V · p. 5
- Without paradigm-level guidelines, the agent produced syntactically valid programs but placed behavioral logic in Python instead of the declarative script.The authors characterize this as a paradigm-orientation failure rather than a language-understanding failure; guidelines redirect design without adding syntax.Source: §V · p. 5
- The agent co-developed Python primitives that transferred across qualitatively different behaviors, while lower-level implementation details were often implicit in the instructions.The resulting behavior is specified in a compact, inspectable script that an expert can audit and refine.Source: §V · p. 6
- The study is an initial proof of concept using a deliberately constrained robotic platform and simple behaviors; scalability and generality on more complex, modern systems remain to be assessed.The authors also identify guideline authoring and evaluation of the complete live, user-facing workflow as future work.Source: §V · p. 6
VI. CONCLUSION
The paper argues that expert-authored paradigm-level guidelines can redirect an LLM coding agent from imperative defaults toward reactive design. With documentation and a robot OS API, the agent jointly creates imperative Python modules and declarative scripts that users can inspect and refine.
VI. CONCLUSION
- Expert-authored paradigm-level guidelines can redirect strong imperative defaults toward sound reactive design, even when training data for the paradigm is limited.The resulting scripts are executable and readable, and users can inspect and refine them through conversation.Source: §VI · p. 6