> For the complete documentation index, see [llms.txt](https://docs.testvibe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testvibe.com/testvibe-api/api-reference/runs/diagnose_run.md).

# diagnose\_run

Everything needed to diagnose a failed run, in one call: the failing tests with fuller error messages, the feature's current Gherkin, the executed spec sources, artifact download links, and the log tail. It replaces the `get_run` → `read_file` → `get_run_artifacts` round trips an agent otherwise needs before it can fix anything.

## Request

```
GET /api/v1/ops/projects/{project}/runs/{runId}/diagnosis
```

| Parameter | In   | Type    | Required | Description              |
| --------- | ---- | ------- | -------- | ------------------------ |
| `project` | path | string  | yes      | The project's public id. |
| `runId`   | path | integer | yes      | The run id.              |

{% tabs %}
{% tab title="cURL" %}

```bash
curl -H "Authorization: Bearer $TESTVIBE_API_KEY" \
  "$TESTVIBE_SERVER/api/v1/ops/projects/$PROJECT/runs/214/diagnosis"
```

{% endtab %}

{% tab title="CLI" %}

```bash
testvibe runs diagnose 214          # readable digest
testvibe runs diagnose 214 --json   # includes the Gherkin and spec sources
```

{% endtab %}

{% tab title="MCP" %}
Tool **`diagnose_run`** — `{ "runId": 214 }`. Use this **first** when a run fails.
{% endtab %}
{% endtabs %}

## Response

```json
{
  "runId": 214,
  "status": "failed",
  "verdict": "failed",
  "featureId": 12,
  "featureName": "Login Functionality",
  "config": "Default",
  "siteUrl": "https://demo.example",
  "finishedUtc": "2026-06-11T09:15:42Z",
  "summary": { "total": 3, "passed": 2, "failed": 1 },
  "failures": [
    {
      "name": "Login > locked out user",
      "status": "failed",
      "durationMs": 12044,
      "error": "TimeoutError: locator.click: Timeout 10000ms exceeded …"
    }
  ],
  "featureStatus": "generated",
  "gherkin": "Feature: Login Functionality\n  …",
  "specs": [
    { "path": "Features/Default/Login Functionality.js", "content": "// executed spec source …" }
  ],
  "log": "…last 4000 chars of the run log…",
  "artifacts": [
    { "kind": "screenshot", "path": "…", "size": 48211, "url": "https://…(short-lived)" }
  ],
  "hint": "Selector or timing failures in the spec usually mean the Gherkin needs tightening …"
}
```

A run that passed returns `"verdict": "passed"` with the summary and no failure context; a run still executing returns `"verdict": "running"` — wait for it first ([`wait_for_run`](/testvibe-api/api-reference/runs/wait_for_run.md)).

| Field                       | Notes                                                                                                          |
| --------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `failures`                  | Non-passed tests only, errors trimmed at 6,000 chars (vs 1,500 in `get_run`).                                  |
| `gherkin` / `featureStatus` | The feature's **current** source — absent when the feature was deleted since the run.                          |
| `specs`                     | The executed spec files' stored content (first 5 files, 8,000 chars each; `specsTruncated: true` when capped). |
| `artifacts`                 | Same short-lived links as [`get_run_artifacts`](/testvibe-api/api-reference/runs/get_run_artifacts.md).        |

## Errors

| HTTP            | When                         |
| --------------- | ---------------------------- |
| `404 not_found` | No such run in this project. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.testvibe.com/testvibe-api/api-reference/runs/diagnose_run.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
