arXiv:2610.17083cs.ROOct 2026

Manuscript Offprint

arXiv:2610.17083

Declarative Reactive Robot Behaviors from Imperative Language Models

Vincent Berenz, Tasha Kim, Bernhard Schölkopf

Vincent Berenz 1^{1}, Tasha Kim 2^{2}, Bernhard Schölkopf 1,3,4^{1,3,4}

1^{1}Max Planck Institute for Intelligent Systems, Tübingen, Germany

2^{2}University of Oxford, Oxford, United Kingdom

3^{3}ELLIS Institute Tübingen, Germany 4^{4}ETH Zürich, Zürich, Switzerland

{vincent.berenz, bernhard.schoelkopf}@tuebingen.mpg.de, tasha.kim@eng.ox.ac.uk

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.

I. INTRODUCTION

The vision of users programming robots through natural conversation is a longstanding goal of human-robot interaction research [1]–[3]. Recent advances in speech recognition and LLMs have made this increasingly feasible. A common pipeline transcribes speech, interprets it using an LLM, then converts it into executable code [4], [5]. Existing work has largely focused on task-oriented programming, which entails generating programs that achieve a specific goal with explicit success criteria and termination conditions (e.g., “bring me a coffee”). Such tasks naturally align with imperative programming, since the structure of plan execution can be modeled by sequential control flow, explicit state transitions, and conditional branching. This is precisely what LLMs excel at, as they are trained predominantly on imperative programming languages.

In this paper, we address the distinct challenge of programming robotic behaviors, a term we use to denote open-ended, continuous patterns of sensorimotor engagement that persist and adapt over time (e.g., “greet visitors in a friendly manner”), which are not reduced to a single success criterion or termination condition. This kind of persistent reactivity has long been studied in rule-based agent architectures and robot control systems [6], [7]. In contemporary robotics, behavior trees (BTs) are often used to organize reactive behavior logic [8], [9]. Programming behaviors requires specifying what a robot should do under what conditions, with continuous evaluation and adaptation, which are requirements that are naturally captured by declarative and reactive programming [10], [11]. Yet, LLMs trained predominantly on mainstream imperative languages have very limited exposure to declarative or reactive paradigms, particularly in the context of domain-specific languages (DSLs) [12].

This raises the question of whether LLMs can generate correct declarative and reactive programs despite this training gap. We investigate whether this gap can be bridged using PLAYFUL [11], a behavior programming platform with two components. The first is an imperative component: Python modules implementing sensing, acting, and evaluation primitives that interface with the robot's operating system. The second is a declarative and reactive component: a scripting language composing these modules into hierarchical condition-action mappings that are continuously evaluated at runtime to form BTs [8]. The declarative script encodes the logic of the behavior, and the Python modules provide the interface to the robot.

A further challenge is that natural language behavior descriptions are inherently under-specified: users rely on common-sense assumptions, rarely detail low-level aspects of the desired behavior (e.g., at what distance to stop, where to direct gaze, how to arbitrate competing actions), and may leave parts intentionally open. BTs are well suited to this problem: the top levels of the tree correspond to what the user does specify, while the lower levels encode details the user leaves implicit. We ask if an LLM can fill in these lower levels appropriately, and whether the development process allows the user to observe and correct mismatches incrementally. We investigate whether, given

© 2026 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. Accepted to the 2026 IEEE International Conference on Robot and Human Interactive Communication (RO-MAN).

suitable context (language documentation, a developer tutorial, and a set of reusable programming guidelines) an LLM-based coding agent can generate correct PLAYFUL programs from under-specified descriptions, despite having no prior training on the language or the reactive paradigm. A key empirical finding motivates this study: without explicit paradigm-level guidelines, the agent produces syntactically valid but poorly structured programs, in which behavioral logic leaks into Python procedural code rather than being expressed through the DSL's declarative mechanisms. This is a direct consequence of the agent's imperative defaults. But when provided with guidelines authored once by an expert, the same agent reliably produces well-structured reactive programs. This demonstrates that LLMs can work with declarative paradigms when given sufficient context that illustrates how the language works and what correct design looks like. The declarative nature of PLAYFUL also supports incremental conversational refinement [9]: since statements are independent and order-irrelevant, the coding agent can add or modify rules based on conversational turns without restructuring existing code.

The agent starts from only the generic robot operating system (OS) API. Then it leverages its native strength in imperative code where it applies, to jointly design both the imperative Python modules and the declarative script that composes them into behavior logic. The guidelines steer it through the declarative component. This co-design produces a reusable primitive library that transfers across qualitatively different behaviors, with the agent inventing domain-appropriate primitives as needed. We evaluate this approach on the Pepper humanoid robot [13] with two qualitatively different behaviors across three experiments: step-by-step conversational development, one-shot generation of the same behavior, and one-shot generation of a novel behavior.

References (42)