Adding a new environment
Drop a four-file package into agrimanager/env/ — there is no registry.
Both dataset build and training resolve your environment by folder name —
importlib.import_module("agrimanager.env.<env_name>") — and discover your classes
automatically. Drop a new folder in, and it works.
The four-file contract#
Create a package at agrimanager/env/<your_env>/ with four files:
| File | What it provides |
|---|---|
env.py | subclass of BaseEnv — reset(), step(action), system_prompt() |
env_config.py | subclass of BaseEnvConfig |
prompt.py | parse_action_response(text) → Optional[int] |
create_dataset.py | subclass of BaseDatasetGenerator plus a module-level generate(config, output_dir) |
The core interface#
class YourEnv(BaseEnv): def reset(self) -> Tuple[Any, Dict]: # return (obs, info) — obs is the first textual observation ... def step(self, action) -> Tuple[Any, float, bool, Dict]: # action arrives as the raw LLM string; parse it, step the simulator, # return (obs, reward, done, info) — a scalar reward on every turn ... def system_prompt(self) -> str: # the task plus the schema: observations, action menu, objective ...
How an environment plugs in#
env_name; build time routes to your create_dataset.py, training time routes to your env.py — with no central registry in between.Steps#
- Maintain the simulator externally under
../AgriManagerExternal/<env>; AgriManager only integrates it. - Create the four-file package in
agrimanager/env/<your_env>/, mirroringwofost_gym/. - Export your classes in the package
__init__.py's__all__— this is how discovery finds them. - Stamp
env_nameinto every parquet row'senv_config. That is the registration. - Write a dataset config with
env_name+dataset_id, then runentrypoints/dataset/build.sh. - (Optional) add
nn_adapter.pywith aBaseNNEnvAdapterfor the neural-network PPO baseline. - Smoke-test it — copy
smoke_tests/wofost_gym/, swap the env name, and run the build/train/eval scripts.
Return a scalar reward every turn. If your env is trajectory-rewarded, emit 0 on early
turns and the trajectory reward on the final turn. The action menu rendered in your prompt and
parse_action_response() must stay mutually consistent.
No if env_name == … branches anywhere — dispatch always goes through
create_environment(). Never modify verl/ for an env integration. Hand-run tooling
(asset generation, baselines, analyses) belongs in integrations/<env>/.