---
title: "codes.task.failed@1 · OpenVibe.Services"
canonical: "https://openvibe.services/docs/contracts/codes.task.failed"
updated: null
---

# codes.task.failed@1 · OpenVibe.Services

HTML: [codes.task.failed@1 · OpenVibe.Services](https://openvibe.services/docs/contracts/codes.task.failed)

# CodesTaskFailedPayload `codes.task.failed@1`

Generated at 2026-11-13 06:25:48 UTC from [`openvibe-contracts v0.419.0`](https://github.com/OpenVibers/OpenVibe.Contracts/tree/v0.419.0) and [`openvibe-sdk v0.161.0`](https://github.com/OpenVibers/OpenVibe.SDK/tree/v0.161.0).

- Version: 1.0.0
- Owner: codes
- Visibility: first-party
- Status: active
- Compatibility: backward
- Schema: [`https://openvibe.network/contracts/events/payloads/codes.task.failed.v1.json`](/docs/contracts/codes.task.failed.json)

codes.task.failed v1 (OpenVibe.Codes): the task ended failed, or expired because no machine took it in time (Run's expired state is announced on the failed topic). Envelope: source codes, subject { type: user, id: <owner usr\_> }, visibility internal.

## Fields

| Field | Type | Required | Description | Constraints |
| --- | --- | --- | --- | --- |
| `task_id` | string | yes |  | - `pattern ^tsk_[0-9A-HJKMNP-TV-Z]{26}$` |
| `state` | enum | yes |  | - `one of "failed", "expired"` |
| `agent` | string \| null | yes |  | - `maxLength 80` |
| `repo` | one of | yes | owner/name from the task's repository URL, or null when it is not a repository path. |  |
| `cost_usd` | number \| null | yes |  | - `minimum 0` |
| `files_changed` | integer \| null | yes |  | - `minimum 0` |
| `started_at` | string \| null | yes |  | - `format date-time` |
| `finished_at` | string \| null | yes |  | - `format date-time` |
| `error` | string \| null | yes |  | - `maxLength 500` |

## Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

 Valid: no-repo

~~~~
{
  "task_id": "tsk_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3",
  "agent": null,
  "repo": null,
  "cost_usd": null,
  "files_changed": null,
  "started_at": "2026-10-28T16:00:00.000Z",
  "finished_at": "2026-10-28T16:04:12.000Z",
  "error": "the machine stopped answering",
  "state": "failed"
}
~~~~

Valid: task

~~~~
{
  "task_id": "tsk_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3",
  "agent": "claude",
  "repo": "OpenVibers/OpenVibe.Codes",
  "cost_usd": null,
  "files_changed": null,
  "started_at": "2026-10-28T16:00:00.000Z",
  "finished_at": "2026-10-28T16:04:12.000Z",
  "error": "the machine stopped answering",
  "state": "failed"
}
~~~~

Rejected: prompt-in-payload

~~~~
{
  "task_id": "tsk_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3",
  "agent": "claude",
  "repo": "OpenVibers/OpenVibe.Codes",
  "cost_usd": null,
  "files_changed": null,
  "started_at": "2026-10-28T16:00:00.000Z",
  "finished_at": "2026-10-28T16:04:12.000Z",
  "error": "the machine stopped answering",
  "state": "failed",
  "prompt": "fix the login bug"
}
~~~~

Rejected: task-id

~~~~
{
  "task_id": "job_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3",
  "agent": "claude",
  "repo": "OpenVibers/OpenVibe.Codes",
  "cost_usd": null,
  "files_changed": null,
  "started_at": "2026-10-28T16:00:00.000Z",
  "finished_at": "2026-10-28T16:04:12.000Z",
  "error": "the machine stopped answering",
  "state": "failed"
}
~~~~

## Validate

~~~~
const contracts = require('openvibe-contracts');
contracts.validate('codes.task.failed@1', value);   // { valid, errors: [{ path, message }] }
~~~~
