> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rua.hud.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Control

> Reference for rua.code: CodeControl, its python and view_image tools, the robot and show names in the kernel, its settings, the episode result, and create_code_agent.

`CodeControl` serves a robot to an agent that writes Python. The interface is [Code Control](https://docs.rua.hud.ai/interfaces/code-as-policy.md) and the guide is [Code Control](https://docs.rua.hud.ai/guides/code-control.md).

```python theme={"dark"}
from rua.code import CodeControl, create_code_agent, read_code_settings
```

Values are in metres, degrees and a grip from 0 (open) to 1 (closed), as in [Direct Control](https://docs.rua.hud.ai/reference/direct-control.md).

## `CodeControl`

```python theme={"dark"}
CodeControl(
    embodiment: Embodiment,
    *,
    settings: Mapping[str, Any] | None = None,
    cameras: CameraSource | None = None,
    robot: str = "robot",
    name: str = "control",
    workspace_root: Path | None = None,
)
```

`CodeControl` is a `DirectControl` that serves `python` and `view_image` instead of `move`. It takes the same [embodiments](https://docs.rua.hud.ai/reference/direct-control.md#embodiments), and a cell's `robot.move` goes through direct control's own `move` tool, so it has the same checks, playback and recording.

| Parameter | Description |
| - | - |
| `embodiment` | What the robot is, as for `DirectControl`. |
| `settings` | The [settings](#settings), by name. Default: none, so each is read from its variable. |
| `cameras` | A function that gives the cameras' calibration. See [cameras](#cameras). Default: none, so `K`, `pose` and `depth` are `None`. |
| `robot` | The name of the `robot` capability to control. Default `robot`. |
| `name` | The name of the MCP capability it serves. Default `control`. |
| `workspace_root` | A folder that keeps each episode's workspace as `episode-001`, `episode-002` and so on. Default: a temporary folder that is deleted when the episode ends. |

| Member | Description |
| - | - |
| `attach(endpoint) -> CodeControl` | Serve beside the robot wire, as `DirectControl.attach` does. After it, `endpoint.capabilities()` has `control`. |
| `result_extra() -> dict` | What an episode result records. See [the episode result](#the-episode-result). |
| `workspace` | The running episode's workspace, or `None`. |
| `code` | Every setting in use, as `read_code_settings` resolves it. |

An episode starts with the endpoint's `reset` and ends with its `result`. Each episode gets its own kernel and an empty workspace, and the kernel starts with the first `python` call.

## Tools

| Tool | Arguments | What it does |
| - | - | - |
| `python` | `code` (string), `note` (string, when `notes` is on) | Runs one cell in the episode's kernel and returns the reply described below. |
| `view_image` | `path` (string) | Returns one image saved in the workspace, such as `images/001.png`. A path outside the workspace, a missing file, or a file that is not an image is an error. |
| `move` | `keyframes`, `note` | Direct control's own tool, with its schema, checks and reply. Served only when `hybrid` is on. |
| `done` | `reason` | Direct control's own tool. Moves are refused after it. |
| `hindsight` | | Direct control's own tool, served when `hindsight` is on. |

`move` is served only when `hybrid` is on. See [hybrid](#hybrid). Otherwise the agent moves the robot with `robot.move` in a cell.

### The `python` reply

A reply has these blocks, in order. A block that has nothing in it is left out.

1. What the cell printed, to stdout and stderr, including what a subprocess printed.
2. The error, if the cell raised, with the traceback cut to the cell's own frames. A cell is named `<cell 3>`.
3. `Out: ` and the value of the cell's last expression, if it is not `None`.
4. A line naming the images that were saved and not shown, when the cell showed more than `max_images_per_cell`.
5. Notices: the cell ran past `cell_timeout_s`, or the kernel exited. See [timeouts](#timeouts).
6. One JSON body: `elapsed_s` and `steps` the cell played, then `parts` (each part's measured value, as in a `move` reply), `state` (the embodiment's readouts, when it has any), and `"episode": "ended"` when the episode has ended. A body that could not read the robot has `state_error` instead of the parts.
7. For each image the cell showed: a caption line `image images/001.png` and the caption the cell gave, then the image.

Text past `output_chars` is cut in the middle:

```text theme={"dark"}
[1180 characters cut. The full text is in outputs/007.txt]
```

The whole text is saved to that file. A shown image is saved whole to `images/NNN.png`. When a reply's images together would not fit in one MCP message, they are shrunk by one factor, and the caption ends `(shown at 410x410; the saved file is larger)`.

## In the kernel

The kernel is a Python process that lives for one episode. Names, imports, threads and files in the working directory carry over between cells. The working directory is the workspace, and `HOME` is set to it.

| Name | What it is |
| - | - |
| `robot` | The one handle on the robot. |
| `np` | numpy. |
| `show(image, caption=None)` | Saves an image and puts it in the reply. |

The agent may import anything installed in the env's Python. The kernel starts with a cleaned environment: `PATH`, `HOME`, `TMPDIR`, `MPLCONFIGDIR`, `LANG` and `PYTHONUNBUFFERED`, and none of the env's variables, so a token in the env's environment does not reach it.

The workspace holds `MANUAL.md`, which documents every call the settings serve (the system prompt carries the same text), an `images/` folder, and an `outputs/` folder.

### `robot`

| Member | Description |
| - | - |
| `robot.spec` | A `Spec`: `str(robot.spec)` is the text of the parts, ranges, units and frames that the `move` tool states, `.control_rate` is the control rate, and `.parts` is the same as data. |
| `robot.observe() -> Observation` | The robot's state and cameras now. It plays no tick. |
| `robot.move(keyframes) -> MoveResult` | Plays keyframes exactly as the `move` tool does, and returns when the motion has ended. |
| `robot.preview(keyframes) -> Preview` | Checks keyframes as `robot.move` does and plays nothing. Only there when the `preview` setting is on, which it is by default. |
| `robot.step(targets) -> StepResult` | Plays one control tick toward `targets`. Only there when the `step` setting is on. |

`keyframes` is the `move` tool's: a list of `{"t": seconds, "<part>": ...}`, with every limit and check of the [`move` tool](https://docs.rua.hud.ai/reference/direct-control#tools). A numpy number or array in it is converted. Anything else that is not a number, a string, a list or a dict is a `TypeError`.

`robot` takes a call only while a cell is running. A thread that a cell leaves behind gets `robot.CellEnded` if it calls the robot after the cell has ended.

#### `Spec`

`spec.parts` maps each part name to `{"space", "frame", "dims"}`, and `dims` maps each dimension name to `{"low", "high", "unit"}`. The unit is `m`, `deg`, `m/s`, `deg/s` or `""` for a grip.

#### `Observation`

| Field | Description |
| - | - |
| `state` | Each part's name to its dimensions and values, in the units of `move`, with the embodiment's readouts, such as an arm's `joints`. |
| `cameras` | Each camera's name to a `Camera`. |
| `t` | Episode seconds. |
| `step` | Control ticks played. |
| `ended` | `True` when the episode has ended. |

The observation never carries a feature that the contract marks `privileged`.

#### `Camera`

| Field | Description |
| - | - |
| `rgb` | Height by width by 3 `uint8` array. |
| `K` | The 3 by 3 pinhole intrinsics in pixels, or `None`. |
| `pose` | The 4 by 4 transform from the camera to `frame`, or `None`. |
| `frame` | The name of the frame `pose` maps into, such as `base`, or `None`. |
| `depth` | Height by width `float32` z-depth in metres, `NaN` where nothing was hit, or `None`. |
| `depth_source` | `"sensor"` or `"learned"` when `depth` is there, else `None`. |

A field is `None` unless the [camera source](#cameras) gives it. `depth` and `depth_source` can also come from a [depth service](#learned-depth).

#### `MoveResult`

The JSON body of a `move` reply, as attributes: `status` (`completed`, `cut_short` or `ended`), `elapsed_s`, `steps`, `parts`, `state`, `reason` and `settle`. A part is also an attribute, so `result.arm` is `result.parts["arm"]`. A part that the move named has a `gap` to its target. A `MoveResult` has no images.

#### `Preview`

| Field | Description |
| - | - |
| `ok` | `True` when `robot.move` with the same keyframes would not raise. |
| `reason` | The text `robot.move` would raise with when `ok` is `False`, and `None` otherwise. |
| `min_duration_s` | The least time the whole motion needs, when it is vetoed as too fast. `None` otherwise. |
| `steps`, `duration_s` | The planned setpoints: ticks and seconds. A real move can run a little longer, because it holds at the end until the robot settles. `0` and `None` when not `ok`. |
| `end` | The planned end value of each part, `{part: {dimension: value}}`, in the units of `robot.spec`. `None` when not `ok`. |
| `path`, `columns` | The planned setpoint of every tick, a ticks x columns array, and the names of its columns (`"arm.x"`). Angles are in degrees. `None` and `[]` when not `ok`. |

#### `StepResult`

| Field | Description |
| - | - |
| `state` | As in an `Observation`. |
| `step` | Control ticks played in the episode. |
| `t` | Episode seconds. |
| `ended` | `True` when the episode has ended. |

A step returns no images. Use `robot.observe()` for the cameras.

#### Errors

A move that does not play raises, and the robot does not move. All of these are subclasses of `robot.MoveError`, which has the reason as `.reason`.

| Error | Raised when |
| - | - |
| `robot.Refused` | The call is malformed or outside what the spec allows. The reason is the one a `refused` reply of `move` gives. |
| `robot.Vetoed` | The robot cannot do the motion as asked. The reason is the one a `vetoed` reply of `move` gives (see [replies and vetoes](https://docs.rua.hud.ai/reference/direct-control.md#replies-and-vetoes)), and `.min_duration_s` is the least time the whole call needs, or `None` when the reason names none. |
| `robot.EpisodeOver` | The episode has ended, so the call played nothing. |
| `robot.CellEnded` | A thread called the robot after its cell ended. |
| `robot.MoveError` | Any other failure of a request, with `<ExceptionType>: <message>` as the reason. |

`robot.ServiceError` is raised by a [model service](#model-services) that gives no usable answer. It is not a `MoveError`: the robot is unaffected. It has `.reason` and `.service`, the name of the service.

A `robot.move` that is cut short by the call limit is not an error. It returns with `status` `cut_short`.

### Cameras

`CodeControl` takes calibration from a **camera source** that the env passes as `cameras=`. Nothing in the robot's contract carries calibration, so an env that serves direct control alone is unchanged. The source is a function from one observation's arrays, by feature name, to the fields it knows for each camera it can calibrate. A camera is named by its name in the contract, `front` for `observation/front`.

```python theme={"dark"}
def source(data: Mapping[str, Any]) -> Mapping[str, Mapping[str, Any]]: ...
```

Each camera's dict may hold `K`, `pose`, `frame`, `depth` and `depth_source`. `pose` needs `frame`, and `depth` needs `depth_source`. A field the source leaves out is `None`. The source runs, in a worker thread, only when a cell calls `robot.observe()`, so a depth image is rendered only when a cell asks for an observation.

| Field | Convention |
| - | - |
| `K` | Pinhole intrinsics in pixels: `u = fx * x / z + cx`, with pixel centres at integers and row 0 at the top. Positive focal lengths and a last row of `0 0 1`. |
| `pose` | A rigid transform from the camera's optical frame (x right, y down, z forward) to `frame`, for the observation it was given with. |
| `frame` | The frame of the spec's parts, so a point from `pose` is one the robot can move to. |
| `depth` | z-depth along the camera's axis, in the image's height and width. A trailing axis of size 1 is accepted. |

A source that names a camera the robot does not have, a field that is not one of these, or a value of the wrong shape or kind makes `robot.observe()` raise a `ValueError` that names the camera.

[`examples/yam/cameras.py`](https://github.com/hud-evals/rua/blob/main/examples/yam/cameras.py) is a worked source for one in-process MuJoCo sim. A sim that runs in a spawned process needs a source of its own.

### `preview`

`robot.preview(keyframes)` takes what `robot.move` takes and runs the same checks in the same order, against a fresh observation of the robot: the schema and ranges, the speed and acceleration vetoes, and the embodiment's `realize`. It stops before the first tick. No recording is opened, no frame is pushed, and no held value changes, so the episode is as it was. Nothing is raised for a refusal or a veto. `ok` is `True` exactly when the same `robot.move` would not raise, and `reason` and `min_duration_s` are what it would raise with. Once the episode has ended, a preview says `the episode has ended`.

A preview counts as a call to the robot in `robot_calls.total` and never as `rejected`. The `python` tool's description names `robot.preview` while the setting is on, and the manual, in the system prompt and in `MANUAL.md`, has a section for it.

### `step`

`robot.step(targets)` plays exactly one control tick, `1 / robot.spec.control_rate` seconds, and returns. `targets` is one keyframe without `t`: a dict of parts and dimensions in the units of `robot.spec`, with the ranges of the `move` tool's `per_tick` mode. A `t` in it is refused. Each step is checked in this order, and the first failure raises and plays nothing.

1. The schema and the ranges, which raise `robot.Refused`.
2. Speed, against the previous command and not the measured value. The first step of an episode has no previous command and starts from the measured value.
3. Acceleration, on position parts: how much the speed changes from the previous step to this one.
4. The embodiment's own checks, such as reach, joint limits and self-collision.

A failure of 2 to 4 raises `robot.Vetoed`. Its reason is worded for one tick and names the largest change one step allows. It has no keyframe, time or `min_duration_s`.

A part or dimension a step leaves out keeps its last command, and a velocity part keeps its last velocity until a step changes it. A step after `done` is refused, and a step after the episode has ended raises `robot.EpisodeOver`.

A velocity part keeps its last velocity when a cell ends, raises or is interrupted, until a later step or move changes it. To stop, step or move to velocity 0. The simulator only advances while a step or move plays, so a held velocity resumes when the next one plays.

### Model services

`segment`, `track` and learned depth call HTTP services that you run and configure with settings. The kernel opens no connection to them. A helper sends its request to the control over the kernel's socket, and the control posts to the URL with a deadline and retries and returns the decoded answer. A helper whose service is not configured is not in the kernel's namespace, not in the system prompt and not in `MANUAL.md`.

| Setting | Turns on |
| - | - |
| `segment_url` | `segment`. |
| `track` and `track_url` | `track`. `track` must be on and `track_url` set. |
| `learned_depth` and `depth_url` | Learned depth. `learned_depth` must be on and `depth_url` set. |

A URL is `http` or `https`. A setting on without its URL raises a `ValueError`. `service_timeout_s` (60 s) is the whole deadline of one call, and `service_retries` (2) is how many more tries a failed call gets inside it. A `429` or a `5xx` is retried after a pause of 0.25 s that doubles. A connection that fails is retried the same way. Any other status raises at once, with the status and the start of the body. No environment proxy is used. A call that runs out of time raises `robot.ServiceError`.

#### `segment`

```python theme={"dark"}
segment(image, text=None, points=None, box=None, point_labels=None) -> Segments
```

`image` is a `Camera`, an array or a PIL image. Give exactly one of `text` (a short noun phrase), `points` (a list of `[x, y]` pixels, with `point_labels` of 1 for on the object and 0 for off it), or `box` (`[x0, y0, x1, y1]`). Anything else is a `ValueError`.

`Segments` has `masks` (`(n, height, width)` bool at the image's size), `boxes` (`(n, 4)` pixels), `scores` (`(n,)`), `labels` (a list of strings) and `len()`. No object found gives `n = 0`.

#### `track`

```python theme={"dark"}
track(frames, points, query_frame=0) -> Tracks
```

`frames` are at least two images of one camera, in time order and all the same size. `points` is a list of `[x, y]` pixels in frame `query_frame`. `Tracks` has `tracks` (`(frames, points, 2)` pixels) and `visible` (`(frames, points)` bool). Where a point is not visible its track is the model's guess.

#### Learned depth

With a depth service on, `robot.observe()` fills `depth` for each camera that has none, and sets `depth_source` to `"learned"`. A camera with sensor depth keeps it. The service gets the image and `K` when the env gives it. An answer is kept for a camera while its image does not change, and forgotten at the start of an episode. A depth service that fails makes `robot.observe()` raise `robot.ServiceError`.

#### The wire protocol of a service

Every call is `POST <url>` with a JSON body, and the service answers `200` with a JSON body. An **Image** is `{"format": "png", "data": "<base64>"}` at the camera's size. A mask is a PNG of that size where a non-zero pixel is in the mask. Pixels are `[x, y]` from the top left.

| Service | Request | Response |
| - | - | - |
| `segment` | `image`, `text`, `points`, `point_labels`, `box`. Exactly one of `text`, `points` and `box` is set, the others are `null`. | `masks` (Images), `boxes`, `scores`, and `labels` (may be left out), one entry per object in ranked order. |
| `track` | `frames` (Images), `points`, `query_frame`. | `tracks` and `visible`, one row per frame and one entry per point. |
| `depth` | `image` and `K` (3 by 3, or `null`). | `depth`: `{"dtype": "float32", "shape": [height, width], "data": "<base64>"}`, little-endian, row-major, metres along the camera's axis. |

An answer that does not match raises `robot.ServiceError` and says what was expected.

### Hybrid

With `hybrid` on, the `move` tool is served beside `python`, and `overview` tells the agent so and the manual has a section for it. The tool is direct control's own, so a call plays the same checks and returns the same reply, with the camera frames. `robot.move` is the same motion called from a cell.

* Both set the same commands. A part a call leaves out holds the value the last call set, whichever of the two set it.
* Calls and cells take turns, in the order they asked. A `move` call starts only when no cell is running, and a cell starts only when no `move` call is playing. While it waits for a long cell, the server sends a progress message every 60 s.
* A refused or vetoed `move` call is a reply with the reason, like direct control's. `robot.move` raises.
* A tick played by either is recorded once, in call order, in one recording.
* `note` follows the `notes` setting, as it does for `python`.

### `show`

`show(image, caption=None)` saves the image as `images/NNN.png`, numbered across the episode, and returns the path. The reply shows it unless the cell has already shown `max_images_per_cell` images. The path of a later image is in the reply's note and the file is saved either way.

`image` is a height by width array (grey), a height by width by 3 or 4 array, a PIL image, or a `Camera`. An array is `uint8`, a float array that is read as 0 to 1, or a boolean mask. Anything else is a `ValueError`.

### Timeouts

A cell that runs longer than `cell_timeout_s` is interrupted with `KeyboardInterrupt`, which the control asks for over a socket so it works under a sandbox. If the kernel stops within 5 s, the namespace survives and the reply says so. If it does not, the kernel is killed, the reply says the namespace is gone, and the next cell starts a new kernel with the files of the workspace still there. A request the interrupted cell had in flight is cancelled. While a cell runs, the server sends a progress message every 60 s, so a long cell does not look like a dead connection to the client.

## Settings

```python theme={"dark"}
read_code_settings(overrides=None, environ=None) -> dict
```

Each setting is its value in `overrides`, else its variable in `environ` (the process environment unless given), else its default. Direct control's settings read `RUA_DC_<NAME>` and the rest read `RUA_CC_<NAME>`. `CODE_SETTINGS` holds the defaults of the rest. An unknown name, an unknown `RUA_CC_` or `RUA_DC_` variable, or a value that does not parse raises a `ValueError` that names it. `CodeControl` and `create_code_agent` take `settings=` and resolve it this way.

| Setting | Default | Description |
| - | - | - |
| Direct control's | `SETTINGS` | Direct control's [settings](https://docs.rua.hud.ai/reference/direct-control.md#settings), used unchanged. `notes`, `hindsight` and `settle` apply as they do for `move`, and `max_call_s` and `max_keyframes` apply to each `robot.move`. `frame_history` has no effect, because a cell's reply carries no frames of a move, and `observe` on raises a `ValueError` for the same reason. |
| `sandbox` | `auto` | How the kernel is launched: `auto`, `bwrap` or `none`. See [the sandbox](#the-sandbox). |
| `sandbox_memory_mb` | 4096 | The most memory the kernel may use under `bwrap`, in MB. At least 64. |
| `sandbox_file_mb` | 1024 | The largest file the kernel may write under `bwrap`, in MB. At least 1. |
| `cell_timeout_s` | 300 | Seconds a cell may run before it is interrupted. Must be positive. |
| `output_chars` | 20000 | Characters of text a reply keeps before the middle is cut. At least 1. |
| `max_images_per_cell` | 8 | Images a reply shows per cell. 0 shows none. |
| `preview` | `True` | Serve `robot.preview`. `RUA_CC_PREVIEW` takes the same values as `RUA_CC_STEP`. |
| `step` | `False` | Serve `robot.step`. `RUA_CC_STEP` takes `0`, `1`, `true`, `false`, `yes`, `no`, `on` or `off`. |
| `hybrid` | `False` | Also serve direct control's `move` tool. `RUA_CC_HYBRID` takes the same values. |
| `segment_url`, `track`, `track_url`, `learned_depth`, `depth_url` | `None`, `False`, `None`, `False`, `None` | The [model services](#model-services). Each is read from `RUA_CC_<NAME>`, and an empty URL is `None`. |
| `service_timeout_s` | 60 | Seconds one service call may take, retries included. Must be positive. |
| `service_retries` | 2 | Extra tries after a failed service call. At least 0. |

### The sandbox

The kernel runs in one of two modes.

| Mode | The kernel |
| - | - |
| `bwrap` | Runs under [bubblewrap](https://github.com/containers/bubblewrap). Its root is read-only and holds only the system directories and the Python prefix. It sees the four files of the kernel, a private `/tmp`, its workspace, which is writable, and the directory of the request socket. It shares no network, process list or IPC with the env, so it cannot reach the robot's ports or the internet, read the env's files or signal another process. The env's own `rua` package is hidden when it is installed inside the prefix. |
| `none` | Runs as a plain child process of the env's container, with the cleaned environment only. Code in a cell can read the env's files and reach the robot's loopback ports. The container is the only isolation. |

Under `bwrap` the kernel also caps itself with hard limits: `sandbox_memory_mb` of data, so an allocation past it raises `MemoryError` in the cell, and `sandbox_file_mb` for any one file written. Core dumps are off. A cell cannot lift the limits.

The `sandbox` setting picks the mode:

* `none` always runs as `none`.
* `bwrap` runs under bubblewrap, or raises a `RuntimeError` when `CodeControl` is built, with the reason it cannot launch.
* `auto` runs a short probe launch, with a 10 s limit, and takes `bwrap` when it works and `none` when it does not.

Bubblewrap needs unprivileged user namespaces and a mountable `/proc`. Docker's default seccomp profile refuses both, and so does gVisor, which is how containers run on Modal. There `auto` runs as `none`. The model services of the env are reached through the control, so the kernel needs no network for them. The mode that ran, and why `auto` fell back, are in [the episode result](#the-episode-result).

## The episode result

`control.result_extra()` returns what to merge into an episode's result, so that a run records how the agent used the interface. The env passes it on with `await endpoint.result(**control.result_extra())`.

| Key | Description |
| - | - |
| `sandbox` | The mode that ran: `bwrap` or `none`. |
| `sandbox_fallback` | Why `auto` ran as `none`, such as `bubblewrap (bwrap) is not installed`. Only there when it did. |
| `cells` | Cells run. |
| `kernels_started` | Kernels started. More than 1 means a kernel was killed or exited. |
| `move_tool_calls` | Calls of the `move` tool. Only there when `hybrid` is on. |
| `robot_calls` | A dict: `total` calls to the robot of any kind, `most_in_one_cell`, `rejected` (moves refused or vetoed), and `uncorrected`. |

`uncorrected` counts the rejected moves that come after the last move that played. A cancelled call counts as a call. An episode with `uncorrected` above 0 ended with the agent's last move still rejected.

## `create_code_agent`

```python theme={"dark"}
create_code_agent(
    model: str, *, spec: RobotSpec, settings: Mapping[str, Any] | None = None, max_turns: int, images_kept: int | None = 10, **kwargs
) -> GatewayAgent
```

Builds a HUD gateway agent, which needs `HUD_API_KEY`, with Code Control's system prompt. `spec` comes from `embodiment.spec()`. The prompt covers the tools, the parts and their ranges, the frames and what a reply shows. It names no budget, no turn count and no time limit, and `max_turns` caps the model's turns without telling it.

| Parameter | Description |
| - | - |
| `settings` | The [settings](#settings), resolved as for `CodeControl`. Pass the same ones. |
| `max_turns` | The model's turn cap. |
| `images_kept` | The images of the most recent turns that stay in the model's context. Older images are replaced by a text stub, and the agent gets them back with `view_image`. Default 10. The limit is capped at 100 images, the most Anthropic accepts in one request. `None` keeps every image. Must be at least 1. |
| `kwargs` | Go to `hud.agents.create_agent`. |

`images_kept` works with Claude agents only today. Any other agent type raises a `ValueError` unless `images_kept` is `None`. `rua.code.agent.overview(settings, spec)` takes the resolved settings and returns the prompt alone: the overview of the tools, the robot's parts and ranges, and the manual of every call the settings serve.

[`examples/yam/code_llm.py`](https://github.com/hud-evals/rua/blob/main/examples/yam/code_llm.py) runs language-model episodes on the YAM example sim and checks the result:

```bash theme={"dark"}
HUD_API_KEY=... uv run --with "mujoco>=3.2,<5" examples/yam/code_llm.py claude-sonnet-4-6 --episodes 5 --turns 30
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.