Dependency Isolation

How RLMesh keeps incompatible simulator and model stacks out of one Python interpreter.

RLMesh exchanges observations and actions between processes, so a simulator and model can install incompatible versions of the same dependency in separate Python environments.

When to split processes

Use separate processes when:

  • the simulator and model require incompatible package versions
  • an environment has heavy optional dependencies
  • an environment registration import should not touch model code
  • you need to compare multiple simulator stacks from one evaluator

One evaluator can connect to several served environments without importing their simulator packages.

The minimal workflow

Serve the environment in the Python environment where it works:

from rlmesh import EnvFactory


class SafetyEnv(EnvFactory):
    def make(self):
        import safety_gymnasium

        return safety_gymnasium.make("SafetyHalfCheetahVelocity-v1")


SafetyEnv().serve("127.0.0.1:5557")

Evaluate in the Python environment where the model works:

from rlmesh.numpy import RemoteEnv

env = RemoteEnv("127.0.0.1:5557")
observation, info = env.reset(seed=0)

The model process never imports safety_gymnasium. It only sees decoded observations shaped by the environment contract.

Two ways to run the split

Option Use when
Separate projects You already have a server process and client process.
SandboxEnv RLMesh should start and own the isolated environment session.

With separate projects you manage both processes yourself — start the server, point the client at its address, shut the server down when done. This is the right shape when the server is long-lived or managed by an orchestrator.

With a sandbox, RLMesh launches the isolated environment session for you and ties its lifetime to the handle: closing the SandboxEnv stops the session. See Sandboxed Environments for that workflow and Runtime Lifecycle for the ownership rules behind it.

What crosses the boundary

Only contract data and values cross between the processes: spaces, metadata, observations, actions, rewards, and info contents. Code, imports, and package versions stay on their own side. That is why the two sides can disagree about NumPy versions, simulator stacks, or even Python minor versions, as long as both run a compatible RLMesh release — see Compatibility.

For a runnable two-image setup, see Isolated Dependencies.