Reactive Environments for Active Inference Agents with RxEnvironments.jl

Wouter W. L. Nuijten, Bert de Vries

Abstract

Active Inference is a framework that emphasizes the interaction between agents and their environment. While the framework has seen significant advancements in the development of agents, the environmental models are often borrowed from reinforcement learning problems, which may not fully capture the complexity of multi-agent interactions or allow complex, conditional communication. This paper introduces Reactive Environments, a comprehensive paradigm that facilitates complex multi-agent communication. In this paradigm, both agents and environments are defined as entities encapsulated by boundaries with interfaces. This setup facilitates a robust framework for communication in nonequilibrium-Steady-State systems, allowing for complex interactions and information exchange. We present a Julia package RxEnvironments.jl, which is a specific implementation of Reactive Environments, where we utilize a Reactive Programming style for efficient implementation. The flexibility of this paradigm is demonstrated through its application to several complex, multi-agent environments. These case studies highlight the potential of Reactive Environments in modeling sophisticated systems of interacting agents.

Introduction

In the current landscape of AI simulation, researchers heavily rely on frameworks like OpenAI’s Gymnasium. These tools are primarily designed for Reinforcement Learning (RL), where interactions follow a strict, imperative loop: an agent takes an action, the environment updates, and the agent receives a single observation.

However, Active Inference (AIF)—a framework based on the Free Energy Principle—requires a more nuanced approach. Biological agents do not wait for a global "clock tick" to perceive their surroundings. Instead, they utilize multiple sensory channels (such as vision and proprioception) operating at varying frequencies. Furthermore, they interact with environments that continue to evolve even when the agent is idle. Traditional imperative tools often fail to capture this complexity, particularly in multi-agent communication and nonequilibrium systems. To address this, we introduce RxEnvironments.jl, a Julia package designed to move beyond the rigid step-function paradigm by leveraging reactive programming.

The Reactive Environment Paradigm

The core of RxEnvironments.jl is the Reactive Programming (RP) paradigm. Rather than a sequence of commands, the system is defined by how entities react to "impulses" or events. This approach allows for the creation of complex, asynchronous, and multi-agent environments specifically tailored for AIF agents.

Entities and Boundaries

In this framework, both agents and environments are treated as "Entities." They communicate through "Boundaries" consisting of sensors and actuators, effectively implementing the concept of a Markov Blanket. This symmetry simplifies the design of multi-agent systems; an "action" from an agent is simply an "observation" for the environment, and vice versa.

Subscription and Emission

Entities operate on a subscription model. When an agent acts, it sends an impulse to the environment. The environment then determines which subscribers (other agents or entities) should receive an observation in response. Functions such as emits and what_to_send allow for fine-grained control over data distribution and frequency.

Decoupled Logic

The framework splits the traditional transition function into two distinct parts:

  1. receive!: Updates internal state based on a specific external stimulus.
  2. update!: Updates state based on elapsed time. This allows the environment to "age" or maintain dynamics (like a bouncing ball) independently of agent input, simulating real-time dynamics.

Validation through Case Studies

As RxEnvironments.jl is a software framework, its utility is demonstrated through three distinct case studies rather than traditional training datasets:

  • Modified Mountain Car: A classic RL problem updated to include instantaneous proprioceptive feedback. The agent "feels" its engine force in real-time while receiving periodic sensory observations, replicating AIF theories regarding proprioceptive feedback loops.
  • Football (Soccer): A complex multi-agent environment involving 22 players. The framework handles asynchronous commands and allows for agent-to-agent communication (e.g., "shouting" to teammates), scaling seamlessly from a single player to a full team.
  • Hearing Aid Simulation: A multi-entity simulation involving a user, an intelligent agent, and the external world. This demonstrates the agent's ability to handle asynchronous appraisals from a human while simultaneously processing high-frequency audio streams.

Insights and Results

The implementation of RxEnvironments.jl demonstrates that reactive environments can successfully model scenarios that are difficult or impossible to replicate in standard RL toolkits. By breaking the "lock-step" of traditional simulations, the framework provides a more biologically plausible environment for AIF agents. Furthermore, the authors demonstrate that setting up these reactive environments requires minimal boilerplate code compared to imperative versions, despite the significant increase in flexibility.

Limitations and Future Work

While the environment framework is highly flexible, a current limitation is that most existing AIF agent implementations are still designed for discrete, lock-step interactions. Future work involves developing new classes of agents that can take full advantage of asynchronous, reactive environments. Additionally, the authors aim to establish standardized benchmarks for Active Inference to encourage community adoption. A promising direction is the integration of this framework with "Reactive Message Passing" on factor graphs, potentially creating a fully reactive pipeline from an agent's internal cognitive architecture to the external world.

Summary updated

Abstract

Active Inference is a framework that emphasizes the interaction between agents and their environment. While the framework has seen significant advancements in the development of agents, the environmental models are often borrowed from reinforcement learning problems, which may not fully capture the complexity of multi-agent interactions or allow complex, conditional communication. This paper introduces Reactive Environments, a comprehensive paradigm that facilitates complex multi-agent communication. In this paradigm, both agents and environments are defined as entities encapsulated by boundaries with interfaces. This setup facilitates a robust framework for communication in nonequilibrium-Steady-State systems, allowing for complex interactions and information exchange. We present a Julia package RxEnvironments.jl, which is a specific implementation of Reactive Environments, where we utilize a Reactive Programming style for efficient implementation. The flexibility of this paradigm is demonstrated through its application to several complex, multi-agent environments. These case studies highlight the potential of Reactive Environments in modeling sophisticated systems of interacting agents.
BibTeX
@inproceedings{nuijten2024reactive,
  author = {Wouter W. L. Nuijten and Bert de Vries},
  title = {{Reactive Environments for Active Inference Agents with RxEnvironments.jl}},
  booktitle = {IWAI},
  year = {2024},
  url = {https://openreview.net/forum?id=tiZUJLVOe2},
}
Figure