rlmesh.session
Bind a model to an env and return a Session to drive by hand or via run().
session(
model: object,
env: EnvTarget,
*,
instruction: str | None = None,
close_env: bool = False,
trust_entrypoints: bool | None = None,
execution_horizon: int = 1,
view: ViewArg = None,
workflow_edition: str | None = None,
)model is a local Model (instance, subclass class, or a bare predict
callable) or a served handle (RemoteModel / SandboxModel); env
is a local env, an EnvFactory, a remote-env handle, or an address
string. A spec’d model resolves its adapter from the env’s tags – a local env must
carry them (via rlmesh.adapters.tag() or an EnvFactory).
A served model rejects instruction= (the env’s own instruction is used).
The returned session is yours: Session.run() leaves it open, so drive it
(or re-run it) as often as you like, then close it via close() or the
with block. Closing it releases the connection and episode state; a model
instance you passed stays open (a model built here from a class is closed
with the session).
Pass rlmesh.RANDOM_SAMPLE as model for a random baseline: each step
samples the env’s action space, no spec or adapter involved.
workflow_edition declares the contract for this call and takes precedence
over the environment variable, class declaration, and project manifest.
model is a Model instance or subclass class, a served handle, or
rlmesh.RANDOM_SAMPLE; a bare predict callable or policy object is
refused – wrap it in the framework Model whose arrays it expects
(rlmesh.numpy.Model(fn)), the library never picks one. Typing: a
Model instance flows its observation/action types onto the returned
Session (predict/step are typed accordingly); a class source or
served handle yields Session[Any, Any].