Spaces and Values

How RLMesh describes observation and action specs and moves values between processes.

Spaces describe the shape, dtype, and bounds of observations and actions. They are part of the environment contract a client receives on connect, so both ends of a connection agree on what valid values look like before any step runs.

import rlmesh

observation_space = rlmesh.spaces.Box(-1.0, 1.0, shape=(4,), dtype="float32")
action_space = rlmesh.spaces.Discrete(2)

Core spaces

Space Status
Box Stable
Discrete Stable
Dict Stable
MultiBinary Experimental
MultiDiscrete Experimental
Text Experimental
Tuple Experimental

Experimental spaces work, but their API may change between releases. See Compatibility for what the stability labels mean.

Gymnasium conversion

RLMesh spaces convert to and from Gymnasium spaces in both directions, so existing Gymnasium environments and tooling keep working:

import gymnasium as gym
import rlmesh

space = rlmesh.spaces.from_gymnasium_space(gym.spaces.Discrete(2))
gym_space = rlmesh.spaces.to_gymnasium_space(space)

When EnvServer wraps a Gymnasium environment, this conversion happens automatically — you only call it directly when building contracts by hand. See Gymnasium for the integration overview.

Values

Values are what actually cross the wire: observations, actions, and the contents of info dictionaries. An RLMesh value is built from:

  • primitives
  • tensors
  • lists and tuples
  • dictionaries

Tensors travel as a validated transport container, not an ndarray. RLMesh moves bytes and metadata; compute, slicing, and broadcasting stay with the framework you decode into.

Backend adapters

A backend adapter decides which array type tensors decode into on the client side. Importing the client from rlmesh.numpy (Stable) gets NumPy arrays; rlmesh.torch (Experimental) gets Torch tensors; rlmesh.jax (Experimental) gets JAX arrays; the plain rlmesh module keeps native RLMesh values.

from rlmesh.numpy import RemoteEnv

env = RemoteEnv("127.0.0.1:5555")
observation, info = env.reset()
env.close()

Here observation is a NumPy array because the client came from rlmesh.numpy. The server side is unaffected by the client’s choice, so two clients with different backends can talk to the same environment. See Value backends for adapter details and decoded-view semantics, and the Python API reference for the full space and value surface.