# Example Tasks (https://www.agentenvframework.com/docs/environments/computers/example-tasks)

> Tasks on computer envs, from a probe that needs no model to an agent that edits a spreadsheet in LibreOffice and is checked from inside the computer

These tasks run on the office desktop that [Composing a computer
environment](https://www.agentenvframework.com/docs/environments/computers/composing.md#apps) builds: `ubuntu-24.04` with
[cua-driver](https://www.agentenvframework.com/docs/environments/computers/supported-drivers.md#cua-driver), LibreOffice and Chromium.

## Run them

Start Docker, then run a task by name:

```bash title="Terminal"
agent-env run ./office --task probe
agent-env run ./office --task office-rehearsal
agent-env run ./office --task office
```

| Task                | What it does                                             | Needs                    |
| ------------------- | -------------------------------------------------------- | ------------------------ |
| `probe`             | Probes the deployed computer at `full`                   | Docker                   |
| `figures`           | Loads the seed into LibreOffice and reads it back        | Docker                   |
| [`office`](#office) | An agent adds a row in Calc while the screen is recorded | Docker, a model endpoint |
| `office-rehearsal`  | `office` with the agent's part played without a model    | Docker                   |

The first run composes the images, 329 s from an empty store on an 8-core amd64 host, and later
runs reuse them ([What happens when you write
it](https://www.agentenvframework.com/docs/environments/computers/composing.md#what-happens-when-you-write-it)).

`office` deploys Claude Code, which needs a model endpoint that serves Anthropic's Messages API
([Model Providers](https://www.agentenvframework.com/docs/model-providers.md)).

## Add a row in Calc

`office` has an agent add the Q4 figures in Calc and save them:

```json title="tasks/office.json"
[
  {"id": "env", "type": "deploy_env", "env_id": "desktop"},
  {"id": "files", "type": "load_artifact", "env_id": "desktop", "artifact_id": "figures", "depends_on": ["env"]},
  {"id": "agent", "type": "deploy_agent", "env_ids": ["desktop"]},
  {"id": "skills", "type": "add_skills", "env_ids": ["desktop"]},
  {"id": "record", "type": "start_computer_recording", "env_id": "desktop", "name": "agent", "depends_on": ["env"]},
  {"id": "task", "type": "prompt_agent", "depends_on": ["files", "skills", "record"],
   "prompt": "The quarterly figures are open in LibreOffice Calc on this computer. Add a row for Q4 under Q3, with revenue 165 and costs 97, then save the file as it is, a CSV. Reply DONE once it's saved."},
  {"id": "check", "type": "env_outcome_verifier", "env_id": "desktop", "file_artifact_id": "check_figures",
   "verifier_id": "q4", "depends_on": ["task"]},
  {"id": "end", "type": "end_computer_recording", "name": "agent", "depends_on": ["task"]}
]
```

1. `env` boots `desktop`, `ubuntu-24.04` with cua-driver, LibreOffice and Chromium, in a container on local Docker.
2. `files` writes `figures` through LibreOffice’s data plane into `~/Office`, and Calc reopens on `figures.csv`.
3. `agent` gives Claude Code the computer’s `/mcp` and its 73 tools, and `skills` installs the `desktop` and `libreoffice` skills.
4. `record` waits only for `env`, and the driver uploads the screen’s segments to the object store.
5. `task` asks the agent for the Q4 row once `files`, `skills` and `record` are done, and waits for its reply.
6. `check` reads `~/Office/figures.csv` through `computer-exec/v1` and passes when Q4 sits under Q1 to Q3.
7. `end` ends the recording, and the run registers its segments and manifest as one file artifact universe.

Parts of the scene:

- **env · deploy_env**: Deploys `desktop`. It boots a `ready` build that its sandbox provider runs natively, here the container on local Docker.
- **files · load_artifact**: Loads `figures`, an environment artifact named after `libreoffice`, through that app’s data plane. The app stops around the load and relaunches on its `open` file.
- **agent · deploy_agent**: No agent id, so it deploys the configured default, Claude Code, in a sandbox of its own. `env_ids` gives it the computer’s `/mcp`.
- **skills · add_skills**: Installs every skill the computer serves, each under its environment name. Here that is `desktop`, led by cua-driver’s own, and `libreoffice`.
- **record · start_computer_recording**: Starts a recording named `agent` of the display, with a grant to upload its segments. Best effort: a recording that can’t start leaves the run going.
- **task · prompt_agent**: Sends the prompt once `files`, `skills` and `record` are done, and waits for the reply. Nothing here limits the agent to the screen.
- **check · env_outcome_verifier**: Runs `check_figures` in the process that runs the task, after the reply. Its one row, `q4`, is the score: `check: 1` when it passes.
- **end · end_computer_recording**: Ends the recording `agent` after the reply and registers what it recorded. Best effort, as the start is.
- **agent-env run**: Runs the task’s steps in this process, each once the steps it depends on are done. A step with no `depends_on` waits for every step before it.
- **The office desktop**: A `computer` env: the `ubuntu-24.04` base, cua-driver, and two apps. It deploys with no gateway; the driver’s card is the env’s card.
- **cua-driver**: trycua’s driver, inside the computer. It serves the screen over MCP and fronts the framework-only routes: data planes, `computer-exec/v1`, recording.
- **LibreOffice and Chromium**: `libreoffice` opens `figures.csv` in Calc, as its `open` setting says. `chromium` opens this site’s docs.
- **~/Office/figures.csv**: The seed’s spreadsheet, Q1 to Q3, in LibreOffice’s data plane folder. The agent is asked to add Q4 and save it as CSV.
- **The skills**: `desktop` tells the agent the OS, the user, the screen and the shortcuts, after cua-driver’s own skill pack. `libreoffice` says where documents are and how Calc saves.
- **The recording**: The driver records the display as H.264 MP4 segments and uploads each itself. Its entry, `computer_recordings.agent`, goes from `open` to `ended`.
- **Claude Code**: The default agent, in a sandbox of its own. It reaches only the computer’s `/mcp` and card, and needs a model endpoint.
- **73 tools**: The seven `computer_*` tools act through the screen, in the foreground. cua-driver’s 66 own tools, such as `list_windows` and `set_value`, sit beside them.
- **check_figures**: The bundle’s verifier artifact. It runs `cat Office/figures.csv` through `computer-exec/v1`, parses the CSV and compares the rows.
- **computer-exec/v1 run**: Runs a command inside the computer as its session user, in the home. It takes the deploy’s control token, which steps run under and an agent never gets.
- **The object store**: Holds the `figures` artifact’s bytes and the recording. With the default local store, its grants reach a computer on local Docker.
- **agentenv-recordings/**: One folder per recording, holding its segments and `manifest.json`. Ending it registers both as `<instance id>__recording-agent`.

* `files` loads `figures`, an environment artifact named after `libreoffice`, through the app's
  [data plane](https://www.agentenvframework.com/docs/environments/computers/creating.md#the-data-plane). Its two files land in
  `~/Office`, and Calc reopens on `figures.csv`.
* `agent` deploys the default agent, Claude Code, with the computer's `/mcp`, which serves 73
  tools: the seven `computer_*` tools and cua-driver's 66.
* `skills` installs the computer's `desktop` skill, led by cua-driver's own, and LibreOffice's.
* `check` reads the saved file inside the computer through `computer-exec/v1`, which takes the
  deploy's control token. An agent can't reach it.

```python title="artifacts/check_figures/verify.py"
"""Whether ~/Office/figures.csv holds the loaded quarters and the Q4 row under them, read inside the computer
through its driver's computer-exec."""
import csv
import uuid

from agentenv_protocol import client as protocol

EXEC = "urn:agentenv:computer-exec/v1"
EXPECTED = [["quarter", "revenue", "costs"], ["Q1", "120", "80"], ["Q2", "135", "86"], ["Q3", "150", "91"],
            ["Q4", "165", "97"]]


async def verify(mcp_url, env_url):
    card = await protocol.get_card(env_url)
    out = await protocol.invoke_extension(env_url, card, EXEC, {"argv": ["cat", "Office/figures.csv"],
                                                                "request_id": uuid.uuid4().hex}, method="run")
    rows = list(csv.reader(out["stdout"].splitlines()))
    saved = out["exit_code"] == 0 and rows == EXPECTED
    return [{"id": "q4", "result": saved, "description": "figures.csv has Q4 under Q1 to Q3" if saved else
             f"figures.csv holds {rows}"}]
```

It passes when the file holds the three loaded quarters and `Q4,165,97`, parsed as CSV, since Calc
quotes text cells.

### A run on Sonnet 5.5

```bash title="Terminal"
agent-env run ./office --task office --model claude-sonnet-5-5
```

```text title="Output (excerpt)"
[tasks/office.json] step 6/8 task (prompt_agent)
[tasks/office.json] step 6/8 task done in 12.2s
[tasks/office.json] step 7/8 check (env_outcome_verifier)
[tasks/office.json] step 8/8 end (end_computer_recording)
[tasks/office.json] step 8/8 end done in 0.1s
[tasks/office.json] step 7/8 check done in 0.1s
[tasks/office.json] passed in 30.0s

Tasks:
  tasks/office.json v1: passed (check: 1), 30.0s, instance <instance id>
    models: solver claude-sonnet-5-5

Tore down 2 sandboxes.
```

Claude Code made six tool calls: LibreOffice's skill, `list_windows`, a screenshot, a click on A5,
the row with `computer_type`, and Ctrl+S. It replied `DONE`, and the run cost $0.26:

| Row  | Result | Description                         |
| ---- | ------ | ----------------------------------- |
| `q4` | `true` | `figures.csv has Q4 under Q1 to Q3` |

[![LibreOffice Calc on figures.csv: an orange ring marks the click on A5, the labels type Q4, Tab, 165, Tab, 97, Enter and key Ctrl+S appear as the row is typed and saved, and Q4 165 97 sits under Q3](https://www.agentenvframework.com/environments/computers/office-agent-poster.jpg)](https://www.agentenvframework.com/environments/computers/office-agent.mp4)

*Claude Code on Sonnet 5.5 during that run, from the computer's [annotated](#recording)
recording, at half speed.*

`office-rehearsal` plays the agent's part with `play_office`, a verifier, so the check passes
without a model.

## The shipped desktop tasks

The [`desktop`](https://github.com/scaleapi/agentenv-framework/tree/main/src/agent_env/examples/desktop)
bundle ships with the framework: `ubuntu-24.04` on the
[`reference` driver](https://www.agentenvframework.com/docs/environments/computers/supported-drivers.md#reference), which serves only
the `computer_*` tools:

```bash title="Terminal"
agent-env run desktop --task probe
agent-env run desktop --task files
agent-env run desktop --task agent
```

### Probe

`probe` deploys the computer and runs the conformance probe at `full`, with no model. The office
bundle has the same file:

```json title="tasks/probe.json"
[
  {"id": "env", "type": "deploy_env", "env_id": "desktop"},
  {"id": "probe", "type": "env_outcome_verifier", "env_id": "desktop", "file_artifact_id": "check_probe",
   "verifier_id": "probe"}
]
```

The probe checks what the driver serves, then that clicks, typing, scrolls and drags in a test
window land where they say. The score is 1 when every row passes or doesn't apply. `agent-env task get-instance --id <instance id>` lists the rows under
`metadata.verifications.probe.results`. On the office desktop:

```text title="Output (summary)"
Tasks:
  tasks/probe.json v1: passed (probe: 1), 16.2s, instance @local/~/office/probe-wdma6dhh
```

### Files

`files` loads a CSV into `~/Documents` and reads it inside the computer with a
[`run_code`](https://www.agentenvframework.com/docs/tasks/more-steps.md#code-and-grading) script and a
`run_container_unit_tests_verifier` command. It needs no model and passes with `tests: 1`.

### Agent

`agent` has Claude Code move the CSV from `~/Downloads` into a new `~/Documents/Reports` folder.
Its steps are `office`'s, with another prompt and check.

## Record the screen

`start_computer_recording` records a computer's display, and `end_computer_recording` stores the
recording as one file artifact universe. Both are best effort: a failure is logged and the run
goes on.

| Field                 | Default                  | Meaning                                                   |
| --------------------- | ------------------------ | --------------------------------------------------------- |
| `env_id`              | required                 | The computer to record                                    |
| `name`                | required                 | The recording's name in this run                          |
| `fps`                 | the driver's default, 10 | Frames a second                                           |
| `max_edge`            | the screen's size        | The longer edge in pixels, 64 to 8192                     |
| `cursor`              | `true`                   | Show the pointer                                          |
| `environment_name`    | none                     | In a multi env, the computer to record                    |
| `annotation_settings` | `{"is_enabled": true}`   | Draw each input over the frames; `false` records it plain |
| `fail_task_on_error`  | `false`                  | Fail the run when the recording fails                     |

The driver draws each input in its caller's colour: clicks as rings, keys and text as labels. A driver whose card lists no `annotate` records plain, with a warning.

The computer uploads H.264 MP4 segments itself, under a grant from the object store. The universe's
id is the instance id, `__recording-` and the name:

```bash title="Terminal"
agent-env artifact file-artifact-universe get --id '<instance id>__recording-agent' --output-dir recording
```

It holds the segments and a `manifest.json`. The run's context keeps each recording's state under
`metadata.computer_recordings.<name>`.

> [!WARNING]
> **The computer must reach the object store**
>
> The start fails when the store's grants don't reach the computer's sandbox, or when the computer
> has no network.

## Keep the agent to the screen

cua-driver's own tools act on apps through the accessibility tree or a script, and `check` passes
however the row got there. Two settings keep an agent to the screen:

* `tools = "standard"` on the computer env leaves it the seven `computer_*` tools ([The computer
  tools](https://www.agentenvframework.com/docs/environments/computers/supported-drivers.md#computer-tools)). `--set` sets it for one
  run.
* `builtin_tools` on [`deploy_agent`](https://www.agentenvframework.com/docs/tasks/important-steps.md#deploy_agent) limits the agent's
  own tools. Claude Code, Codex and OpenCode take it.

```bash title="Terminal"
agent-env run ./office --task office --set envs/desktop.tools=standard
```

```json title="The agent step, GUI-only"
{"id": "agent", "type": "deploy_agent", "env_ids": ["desktop"], "builtin_tools": {"only": ["Skill", "Read"]}}
```

To hide only some tools, a [`modify_env_tool_access`](https://www.agentenvframework.com/docs/tasks/more-steps.md#env-control) step
disables them for a role. A `reset_env` drops its rule, so run it again after one.

## Run it on another driver

`--set` swaps the driver for one run, as [Swap the
driver](https://www.agentenvframework.com/docs/environments/computers/composing.md#swap-the-driver) shows. The shipped `desktop` runs
on cua-driver like this:

```bash title="Terminal"
agent-env run desktop --task agent --set envs/desktop.driver=cua-driver
```

```text title="Output (excerpt)"
--set envs/desktop.driver=cua-driver: 1 env and 1 task written under ids ending in (desktop.driver cua-driver)
```

The task runs unchanged, and its agent sees cua-driver's 66 tools beside the `computer_*` ones. Its
prompt asks for the `computer_*` tools alone; add `--set envs/desktop.tools=standard` to enforce it.