# Dr. Groundbot: why a job failed

When a GitHub Actions job fails on Groundbox, Dr. Groundbot, our CI agent, works out why. It reads the job's log and test results and reruns the failing command in copies of the failed job's VM, booted from its disk as the job left it, and the failing test in many copies at once to tell a flaky test from a real failure. Nothing is held after the job. The answer says whether the change broke it, a test is flaky, or CI itself is the problem, how sure it is, the evidence and what to do next.

The diagnosis is on the job's page in the dashboard, under **Diagnosis**. Say whether it was right with **Right** or **Wrong**; when it was wrong, add the real cause. To ask for one again, or for a job that has none:

```
groundbox ci diagnose <job id>          # waits for the answer; --no-wait returns at once
groundbox ci diagnosis <job id>         # the job's diagnosis
groundbox ci diagnoses --repo owner/name --category flaky_test
groundbox ci diagnosis-feedback <dgn id> wrong --note "The cache was stale"
```

**Price:** Dr. Groundbot's first 10 finished diagnoses each month are free, on every team. After that they stop for the month, and nothing is charged, unless you turn on **Keep going after the free ones**: then $0.25 each, from your usage balance like CI minutes. A diagnosis that fails is never charged. All of it is in **Settings → Dr. Groundbot** or the CLI: turn diagnoses off, turn paid ones on, or set the most a month. On the free plan, paid ones need credit left.

```
groundbox ci diagnosis-settings                    # on or off, this month's use and spend
groundbox ci diagnosis-settings --paid on          # keep going after the free ones
groundbox ci diagnosis-settings --monthly-max 100  # at most 100 a month (none: no number)
groundbox ci diagnosis-settings --agent codex      # your coding agent, first on the Fix in buttons
groundbox ci diagnosis-settings --handoff claude   # tag @claude on the pull request when he is sure
groundbox ci diagnosis-settings off
```

- **Categories:** `bug_in_change`, `already_broken` (fails every time, but not because of the change: the default branch fails the same way, or it broke with the date or a dependency release), `queue_conflict` (merge queue runs only), `flaky_test`, `ci_problem` (the runner, a service, the network, a registry, a secret or the workflow) and `unknown`. Confidence is `low`, `medium` or `high`.
- **Failures known on sight:** a lockfile out of date, files Prettier wants formatted, a full disk, running out of memory, a service over its quota or rate limit, an expired token or certificate, and Ubuntu's package archive not delivering a package are answered at once by a rule, with the exact fix where there is one, free and not counted toward the free ones. The diagnosis has `known_pattern` with the rule's name (`null` when the agent worked it out). A job with failed tests always gets the agent.
- **One-click fix:** when he is sure the change broke it (`bug_in_change`, high confidence) and the fix is a few lines in a file the pull request changed, he posts it on the pull request as a GitHub suggestion: **Commit suggestion** applies it. He checks the lines against the commit first, and never pushes to your repository himself. The diagnosis has `suggested_fix` (the file, the lines, the new text and the suggestion's link). When there is no pull request and he cannot post a check on the commit (the GitHub App's new permissions are not accepted yet), the team's owners get his answer by email instead, at most one per repository every 30 minutes.
- **Hand it to your coding agent:** he never writes the fix himself; he hands it to yours. Every answer that needs a code change has a **Prompt for AI agents** on the pull request and **Fix in Claude Code**, **Codex** and **Cursor** buttons on the pull request, in Slack and on the job's page: each opens that agent with the prompt filled in (the pull request, his answer, the fix and where to get the full evidence), and you press send. Pick your agent under **Settings → Dr. Groundbot** to have it first. The links carry only a signed id, never your logs, and stop working after a month; then they open the job's page. The diagnosis has `fix_prompt` (`null` when nothing needs changing: a rerun he started, or a failure already on the default branch), and `groundbox ci diagnosis <job id> --prompt` prints it for any agent.
- **Hand it over by himself:** with **Hand sure fixes to @claude** on, when he is sure the change broke it (`bug_in_change`, high confidence), he tags `@claude` on the pull request with the prompt, so your [Claude Code GitHub Action](https://github.com/anthropics/claude-code-action) starts on the fix with nobody asking. The Action ignores other bots unless told: add `allowed_bots: groundbox` to its `with:`. He does it once per failure, never for the same failure again, and at most 3 times on one pull request; the diagnosis has `handed_off_at`. Off unless turned on. Codex, Cursor, Copilot and Devin answer only people on GitHub today, so for them use the buttons.
- **The same failure again:** when a job fails the same way it did before (the same failed step, the same failed tests or the same errors) within 14 days, you get the earlier answer again at once, with no new run and no charge, and it does not count toward the free ones, even after they are used. The answer says so, and the diagnosis has `reused_from`, the id of the one that worked it out (`null` for a fresh one). An answer marked **Wrong** is never given again, and one you ask for with `groundbox ci diagnose` is always fresh. A job that only failed because a job it `needs` failed (a gate like `check`) is not diagnosed: the job that failed has its own.
- **In the merge queue:** a failed queue run is diagnosed for the pull request the queue tested, not the queue's branch. The agent sees that pull request's change apart from the ones ahead of it in line, so it can say when two pull requests are each fine but break together (`queue_conflict`). The answer is posted on the pull request, the queue's comment when it takes the pull request out says why (or that the answer is coming), and the diagnosis has `merge_queue` with the pull requests that were ahead (`{"ahead_prs": [12, 15]}`); it is `null` for any other run.
- **API:** `GET /v1/ci/jobs/{job_id}/diagnosis` (404 when the job has none), `GET /v1/ci/diagnoses` (`repo`, `category`, `limit`, `cursor`) and `GET /v1/ci/diagnoses/{id}` need `ci:read`. `POST /v1/ci/jobs/{job_id}/diagnose` and `POST /v1/ci/diagnoses/{id}/feedback` (`{"verdict": "right" | "wrong", "note": "..."}`) need `ci:write`. Asking for one answers 202 with the diagnosis `queued`, 503 `not_available` when the team turned diagnoses off, 402 `spend_cap_reached` past the free ones without paid ones on, or past the team's monthly number, 402 `insufficient_balance` with no credit, and 409 when the job did not fail. Each diagnosis has `cost_micros`: 0 for a free one, 250000 after. `GET /v1/ci/diagnoses/settings` (`ci:read`) and `PUT /v1/ci/diagnoses/settings` (`ci:write`, `{"enabled": true, "paid_after_free": true, "monthly_max": 100}`) read and change the settings.
- **Webhooks:** to hear about a diagnosis the moment it is done, add a [webhook](https://groundbox.dev/docs/webhooks) for `ci.diagnosis.completed`.
- **Slack:** to see each failed job and why it failed in a channel, with **Right** and **Wrong** under the answer, add the [Groundbox Slack app](https://groundbox.dev/docs/webhooks#slack).
- **SDKs**, in TypeScript and Python: `diagnose_ci_job`, `get_ci_job_diagnosis`, `get_ci_diagnosis`, `list_ci_diagnoses`, `send_ci_diagnosis_feedback`, `get_ci_diagnosis_settings` and `set_ci_diagnosis_settings`.
- **MCP:** `ci` with action `diagnosis` reads a job's diagnosis.

## Your code and AI models

**Nothing of yours is used to train an AI model, by us or anyone we use.** CI jobs and sandboxes involve no AI model at all. Two features do, and only for your team:

- **Dr. Groundbot**, when a job fails, sends what he needs to work out why to Claude through Anthropic's API: lines of the job's log, its failed tests, the pull request's diff, the files he reads and the output of the commands he runs in a copy of the job's disk. Secrets GitHub masks in the log stay masked, and tokens he recognizes are taken out first. Anthropic does not train on what is sent through its API.
- **A CI tune-up** reads your workflow files the same way, to propose its pull request.

What he keeps: each answer with its evidence, on the job's page, and short notes about each repository (how its tests run, its quirks) so the next diagnosis of it is better. Only your team sees them, they are never shared with another team, and they go when you delete the team. The copy of a failed job's disk is deleted 30 minutes after the job. To send nothing to a model, turn Dr. Groundbot off under **Settings → Dr. Groundbot** (or `groundbox ci diagnosis-settings off`) and don't run tune-ups.
