API Reference
hud.env
API reference for the Environment and Observation classes
The hud.env
module (primarily hud.env.environment
) provides the core classes for representing and interacting with runtime environments.
See the Environment Concepts page for explanations and usage examples.
Classes
Environment
Represents a running instance (browser, OS) where an Agent interacts. Environments are typically created using hud.gym.make()
rather than direct construction.
Attributes:
metadata
(dict[str, Any]): Metadata associated with this environment instance.client
(Client
): Internal client instance responsible for communicating with the environment runtime (local or remote).url
(str | None): Primary access URL for the environment (if applicable).live_url
(str | None): URL for live viewing/streaming (if applicable, obtained viaget_urls
).task
(Task
| None): The Task currently associated with this environment.build_data
(dict[str, Any]): Data related to the environment build process.
Key Methods:
step(self, actions: list[CLA] | None = None)
: Executes agent actions or gets the initial state.- Parameters:
actions
: List of CLA actions, orNone
to get initial observation.
- Returns:
(Observation, reward, terminated, info)
tuple.reward
is typically 0 unless overridden by custom logic.terminated
is typicallyFalse
.
- Parameters:
evaluate(self, config: HudStyleConfigs | None = None)
: Runs the evaluation logic defined in the Task (or the providedconfig
).- Parameters:
config
: Optional override for evaluation logic using Configuration Styles.
- Returns: The result from the evaluation function(s).
- Parameters:
reset(self, configs: HudStyleConfigs | None = None)
: Resets the environment state, usually running setup logic.- Parameters:
configs
: Optional override for setup logic.
- Returns:
(Observation, info)
tuple after resetting. (Note:gym.make(task)
handles initial setup; directreset
is less common).
- Parameters:
get_urls(self)
: Fetches access URLs (url
,live_url
) for the environment.- Returns:
dict
containing URLs.
- Returns:
close(self)
: Terminates the environment instance and cleans up resources. Saves Trajectory if linked to a Job.
Observation
Represents the state observed by the agent at a given step.
Attributes:
screenshot
(str | None): Base64-encoded PNG string of the screen.text
(str | None): Textual observation from the environment (e.g., accessibility info, terminal output).
TaskResult
The TaskResult
class represents the result of a task step.
Attributes
observation
(Observation): The current observationreward
(float): Reward value from the stepterminated
(bool): Whether the task is completeinfo
(dict[str, Any]): Additional information from the environment