Skip to main content
CustomEnv is the bridge between the CLI and your own code. It loads a project’s env.json and exposes the standard Gym 5-tuple loop, so you can run the exact same phase-aware mission with your own policy or VLA and emit the same fine-tune records the CLI does. It lives in the CLI package:
from pathlib import Path
from cadenza_cli.customenv import CustomEnv, load_config

Drive a mission

cfg = load_config(Path("rescue-dog/env.json"))   # -> EnvConfig
env = CustomEnv(cfg, headless=True)

obs, info = env.reset()
done = False
while not done:
    # info["goal_prompt"] is the current phase's goal, feed it to your model.
    action = your_policy(obs, info["goal_prompt"])   # ActionCall, dict, or str
    obs, reward, terminated, truncated, info = env.step(action)
    done = terminated or truncated

env.write_finetune(Path("train.jsonl"))   # same records as `env run`
env.write_log(Path("run.log.jsonl"))

Constructor

CustomEnv(cfg, *, headless=True, xml_path=None, seed=0, adapter_factory=None)
ParamDescription
cfgAn EnvConfig from load_config(...).
headlessRun without the viewer.
xml_pathOverride the scene XML.
seedRNG seed.
adapter_factorySupply a custom sim adapter (advanced).

Methods

MethodReturnsDescription
reset()(obs, info)Start the mission at phase 0.
step(action)(obs, reward, terminated, truncated, info)Advance one tick. action may be an ActionCall, a dict, or a command string.
current_phase()phaseThe active phase object.
recordslistAccumulated per-step records.
mission_success()boolWhether all phases were completed.
judge_summary()dictLLM-judge verdict for the rollout.
signal_summary()dictReward/signal breakdown.
write_finetune(path)NoneWrite (prompt, action, reward) rows via the project’s template.
write_log(path)NoneWrite the full tick-by-tick log.
close()NoneShut down the sim.
The info dict from reset() / step() carries the current goal_prompt, phase index, and predicate state: everything your policy needs to act per phase.
Build and iterate on missions with the CLI, then bring the finished env.json here to evaluate a real policy against it, with no re-authoring required.
Related config types in cadenza_cli.customenv: EnvConfig, Phase, FineTuneConfig, and EnvConfigError (raised on an invalid env.json).