> Documentation index: [/llms.txt](/llms.txt). Every page as one file: [/llms-full.txt](/llms-full.txt).

# Lab

Lab [#lab]

Lab tests a platform agent by playing simulated people against it, judging the answers and reporting the result, billed to the workspace.

* [Build an environment](./environments)
* [Run the gym](./gym)
* [Diagnose conversations](./diagnose)
* [Certify an agent](./certify)

Building blocks [#building-blocks]

| Part          | What it is                                                                                                      |
| ------------- | --------------------------------------------------------------------------------------------------------------- |
| Environment   | Test cases (simulated people who write to the agent), the files they hold, and the checks the answers must pass |
| Gym           | Plays an environment against an agent to measure it, or to improve its configuration round by round             |
| Diagnosis     | Reads conversations the agent already had and says what fails, why, and where to fix it                         |
| Certification | Measures an agent on test cases against a pass bar; a person approves or rejects the result in the web app      |

The agent must be a platform agent; publish one from files with [Create and configure an agent](../configurable-agents/create-and-configure).

Authentication [#authentication]

Every request sends `X-Space-Slug` and one credential; see [Authentication and API keys](../api-basics/authentication). An API key needs the **Lab** scope.

| Task                                                                     | Auth          |
| ------------------------------------------------------------------------ | ------------- |
| Environments, gym sessions and diagnoses                                 | Key or bearer |
| Launch, read and share a certification; change its reviewer              | Key or bearer |
| An agent's chats, through `/api/v1/diagnostics/agents/{agent_id}/chats/` | Key or bearer |
| Approve or reject a certification                                        | Bearer only   |

A key without **Lab** gets `403 {"detail": {"code": "API_KEY_SCOPE_MISSING", "scope": "lab"}}`.

Numbers and names [#numbers-and-names]

| Field       | On                                           | Meaning                                                                                         |
| ----------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `space_seq` | Diagnosis runs, gym sessions, certifications | The number the web app shows (**#3**), counted per workspace. `id` stays the key in every path. |
| `kit_name`  | Diagnosis runs, gym sessions                 | The environment's name, also when the caller cannot read that environment.                      |

Read the conversations behind a report [#read-the-conversations-behind-a-report]

All paths start with `/api/v1/diagnostics`.

| Report        | Conversation IDs                                      | Read them with                                                                                     |
| ------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| Gym           | `GET /gym/{session_id}/conversations/` → `[].chat_id` | `GET /agents/{fork_agent_id}/chats/{chat_id}/`, with `fork_agent_id` from `GET /gym/{session_id}/` |
| Diagnosis     | `trace_ids`                                           | `GET /agents/{agent_id}/chats/{chat_id}/`                                                          |
| Certification | `report.cases[].executions[].chat_id`                 | `GET /certifications/{certification_id}/chats/{chat_id}/`                                          |

`GET /agents/{agent_id}/chats/` lists the agent's chats the caller can open. With a key, these are the only routes that read an agent's chats.
