Skip to navigation

nemo_gym.web.task_images

View as MarkdownOpen in Claude

Resolve benchmark reference images at the agent-side trust boundary.

Module Contents

Functions

NameDescription
resolve_local_task_image_pathResolve and validate one local reference below a read-only image root.
resolve_task_image_urlReturn a model-safe URL for one task reference image.

Data

_MIME_OVERRIDES

_PASSTHROUGH_SCHEMES

API

nemo_gym.web.task_images.resolve_local_task_image_path(
image_reference: str,
image_root: str | pathlib.Path | None,
max_bytes: int
) -> tuple[pathlib.Path, str]

Resolve and validate one local reference below a read-only image root.

nemo_gym.web.task_images.resolve_task_image_url(
image_reference: str,
image_root: str | pathlib.Path | None,
max_bytes: int
) -> str

Return a model-safe URL for one task reference image.

Public WebArena-family JSONL records store relative image paths. The model endpoint cannot consume those controller paths directly, so the web agent reads them from an explicitly mounted, read-only root and emits a data URL. Existing data and HTTP(S) URLs pass through unchanged.

Local references are accepted only when they resolve inside image_root. This prevents benchmark metadata from becoming an arbitrary file-read API.

nemo_gym.web.task_images._MIME_OVERRIDES = {'.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.png': 'image/png', '.webp': 'ima...
nemo_gym.web.task_images._PASSTHROUGH_SCHEMES = frozenset({'data', 'http', 'https'})