Docs · how to

Use denv as an Inspect sandbox

Give every Inspect sample a forked denv environment with sandbox="denv".

1. Install the package

pip install "denv[inspect]"
export DENV_SERVER=https://api.denv.ai DENV_API_KEY=dak_…

The sandbox registers itself through Inspect's entry point; no import is needed in your task file.

2. Describe the sandbox in `denv.yaml`

Inspect treats a string sandbox config as a file path, so put the configuration in a file next to the task.

From an image:

image: python:3.12-slim
egress: deny
volumes: [/work]

From a version of a whole environment, data included:

from_version: ver_01…
service: opsbox

3. Select it in the task

from inspect_ai import Task, task
from inspect_ai.dataset import json_dataset
from inspect_ai.scorer import includes
from inspect_ai.solver import generate, use_tools
from inspect_ai.tool import bash

@task
def ops_triage():
    return Task(
        dataset=json_dataset("tasks.jsonl"),
        solver=[use_tools(bash()), generate()],
        scorer=includes(),
        sandbox=("denv", "denv.yaml"),
    )
inspect eval ops_triage.py --model openai/gpt-5

Each sample gets its own environment at sample_init and it is destroyed at sample_cleanup. Only the volumes paths persist across snapshot and fork; the image's writable layer does not.

Grade with a separate verifier

From a scorer, call the verifier declared in the environment's compose file:

from denv import Client

v = Client().verify(env_id)
score = v.reward          # None if the verify failed

The agent's processes are frozen, the declared paths are collected with special files refused, and the grader runs on a fork. The environment id for the sample is available on the sandbox object as _env_id.