Reinforcement learning environment
An environment is the world a model acts in during reinforcement learning, which responds to each action with a new state.
A reinforcement learning environment receives each action of the model, changes in response, and reports what the model can now observe. For an agent, the environment might be a code repository with a shell, a web browser, or a desktop. A task inside it sets the goal, such as fixing a failing test or filling in a form. The environment also decides when the task has ended.
The common interface has two operations. Reset puts the environment in its starting state and returns the first observation. Step applies one action and returns the next observation, a reward, and whether the task has ended. This shape was popularized by the Gym library for classic control and game tasks, which is why such environments are often called gym environments.
Environments for agents that run code usually run in a sandbox, one for each attempt, isolated from the trainer and from other attempts. The model runs code that no one has reviewed, and during training it explores actions that are wrong on purpose or by accident. The sandbox limits those actions to a machine that can be thrown away. It also keeps one attempt from changing what another attempt sees.