> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# POST /v1/compute/plans/{plan_id}/stages/{stage_id}/fail

```text
POST https://weights.fyi/run/v1/compute/plans/{plan_id}/stages/{stage_id}/fail
Authorization: Bearer <token>                    scope: submit
Content-Type: application/json
```

**Available since:** 2026-10-28: included in this build; see [What is live](/run/docs/what-is-live.md) for deployment status.

**Answer time:** synchronous failure commit, cancellation of dependent stages and scheduling refresh.

Reports that an active `awow_harness_lease` stage ended unsuccessfully, with a reason. The plan must be `executing` and the stage must hold an active harness lease. The reason's first word decides what happens: a transient platform fault is retried, a credit hold waits, anything else is terminal (table below).

A terminal failure is scoped to dependencies, not to the plan. The stage becomes `failed` and every stage that needs it, directly or through other stages, becomes `cancelled`. Independent sibling tracks keep their leases and run on, and completed stages stay completed. The plan stays `executing` until its last stage ends; it then settles `failed`.

## Request

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | Bearer token with `submit`; use the account token. |
| `plan_id`, `stage_id` | path | yes | Your plan and its active harness stage. |
| `reason` | JSON body | yes | String with non-whitespace content, at most 4,096 UTF-8 bytes. Stored as sent. |

The body must be a JSON object of at most 1 MiB. Other fields are ignored. The reason is validated even when the stage or plan has already ended.

| Reason starts with | What happens |
|---|---|
| `INPUT_STAGING_FAILED`, `PLATFORM_OOM` | A transient platform fault, retried automatically. While the stage has attempts left under `workload.max_attempts` (default 3) it returns to `ready_to_wake` for another lease, its siblings untouched. The scoped token is revoked and a `stage_lease_released` event carries `reason`, `error`, `failure_count`, `max_attempts` and `transient_platform_failure: true`. The failure that uses the last attempt is terminal. |
| `no_credit`, `credit_exhausted`, `token_daily_cap`, also after `HTTP 402:` | A credit hold, not a failure. The stage returns to `ready_to_wake` without spending an attempt and wakes again once credit or the daily cap allows. The event carries `credit_hold: true`, `waiting_for` and `readiness`. |
| Anything else | Terminal. The stage is `failed`, its unfinished packs are cancelled, its scoped token is revoked and a `stage.failed` event records the error. Its transitive dependents are cancelled, each with a `stage.cancelled` event. |

The code must open the reason (`PLATFORM_OOM`, `PLATFORM_OOM: detail`); a code named later in the text is read as ordinary text.

## Return value

**200 OK** with the current [plan receipt](/run/docs/reference/compute-plans-get.md). Its `stages[].failure` carries the stored detail:

| Stage | `failure` |
|---|---|
| The failed stage | `{"status": "failed", "reason": "<your reason>", "error": "<your reason>"}` |
| A cancelled dependent | `{"status": "cancelled", "reason": "dependency_failed", "source_stage_id": "<the failed stage>"}` |
| A requeued or held stage, and every untouched stage | `null` |

If either the stage or plan is already `completed`, `failed` or `cancelled`, a valid request returns the current receipt without changing the outcome or overwriting the first reason. This includes retries with a different valid reason.

## Errors

| Status | Code | Meaning |
|---|---|---|
| `400` | `invalid_json`, `invalid_compute_plan` | Invalid JSON, body, identifier or reason. |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | Supply a valid account token. |
| `403` | `scope_required`, `account_suspended` | Token lacks `submit`, or the account is suspended. |
| `404` | `compute_plan_not_found`, `compute_stage_not_found` | Plan or stage is absent or inaccessible to this account. |
| `409` | `compute_plan_conflict` | No active harness lease, or this stage is service-managed. |
| `413` | `body_too_large` | Body exceeds 1 MiB. |
| `429` | `rate_limited` | Wait for `Retry-After` before retrying. |

## Examples

```sh
curl -s https://weights.fyi/run/v1/compute/plans/PLAN_ID/stages/STAGE_ID/fail \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/json" \
  -d '{"reason":"The coding suite exceeded its deadline."}'
```

Selected response fields. `review` needs `sessions` and is cancelled; the independent `audit` stage runs on, so the plan is still `executing`:

```json
{"plan_id":"example-plan","state":"executing","stages":[{"stage_id":"sessions","state":"failed","needs":[],"failure":{"status":"failed","reason":"The coding suite exceeded its deadline.","error":"The coding suite exceeded its deadline."}},{"stage_id":"review","state":"cancelled","needs":["sessions"],"failure":{"status":"cancelled","reason":"dependency_failed","source_stage_id":"sessions"}},{"stage_id":"audit","state":"lease_ready","needs":[],"failure":null}],"last_event_seq":44}
```

## History

- 2026-10-28: documented harness failure, branch cancellation and terminal retries.
- 2026-11-16: corrected to dependency-scoped failure; documented automatic retry of transient platform faults, credit holds and `stages[].failure`.

## See also

- [GET /v1/compute/plans/{plan_id}](/run/docs/reference/compute-plans-get.md)
- [POST /v1/compute/plans/{plan_id}/stages/{stage_id}/complete](/run/docs/reference/compute-stages-complete.md)
- [GET /v1/compute/events](/run/docs/reference/compute-events.md)
