{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/crevio-co/json-schema/crevio-co-ai-task-run-schema.json",
  "title": "AiTaskRun",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/crevio-co-openapi.json#/components/schemas/AiTaskRun",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "object": {
      "type": "string"
    },
    "task_id": {
      "type": "string"
    },
    "task_name": {
      "type": "string"
    },
    "chat_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "The run's own conversation (`aichat_...`): what it read, called and said. Read it with `search_chats`."
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "running",
        "completed",
        "failed",
        "needs_input",
        "timed_out",
        "unknown",
        "skipped",
        "cancelled"
      ]
    },
    "summary": {
      "type": [
        "string",
        "null"
      ]
    },
    "error_message": {
      "type": [
        "string",
        "null"
      ]
    },
    "test_run": {
      "type": "boolean"
    },
    "input_tokens": {
      "type": "integer"
    },
    "output_tokens": {
      "type": "integer"
    },
    "credits_consumed": {
      "type": "integer"
    },
    "cancel_requested_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When a stop was requested. The run stays `running` until it reaches its next step, then settles as `cancelled`."
    },
    "tool_calls_count": {
      "type": "integer"
    },
    "duration_ms": {
      "type": [
        "integer",
        "null"
      ]
    },
    "started_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "completed_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "skip_reason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "condition",
        "no_paid_plan_or_credits",
        "no_recent_activity",
        "no_task_activity",
        "no_personal_sources",
        "wake_gate",
        "wake_limit",
        "rate_limited",
        "misfire",
        "task_busy",
        "account_at_capacity",
        "member_credit_cap",
        "agent_archived",
        null
      ]
    },
    "skip_count": {
      "type": "integer"
    },
    "delivery_status": {
      "type": "string",
      "enum": [
        "delivered",
        "not_delivered",
        "not_requested",
        "unknown"
      ]
    },
    "completion": {
      "type": [
        "string",
        "null"
      ],
      "description": "How the agent closed a completed run: `verified` (it re-checked the result), `recorded` (it reported without re-checking), or `recovered` (it never reported; `summary` is its last message). Null unless an agent turn completed the run.",
      "enum": [
        "verified",
        "recorded",
        "recovered",
        null
      ]
    },
    "trigger_source": {
      "type": "string",
      "enum": [
        "scheduled",
        "event",
        "manual"
      ]
    },
    "trigger_event": {
      "type": [
        "object",
        "null"
      ],
      "description": "The event that started this run, `{type, data}`, exactly as the run received it; `data` matches the event's webhook payload. Null for a run no event started. POST /task_runs/{id}/replay runs the task again on it."
    },
    "replay_of": {
      "type": [
        "string",
        "null"
      ],
      "description": "The run (`trun_...`) whose event this run replays. Null unless started by POST /task_runs/{id}/replay."
    },
    "captured_deliveries": {
      "type": "array"
    },
    "result": {
      "type": [
        "string",
        "null"
      ],
      "description": "The agent's final reply, once the run settled. Present on single-run responses, not in lists."
    },
    "json": {
      "description": "The reply parsed and validated against the `response_format` the run was started with. Null when none was given or it did not validate."
    },
    "json_error": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why the reply did not parse or validate against `response_format`."
    },
    "artifacts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Artifact"
      }
    },
    "pending_approval_ids": {
      "type": "array"
    }
  },
  "required": [
    "id",
    "object",
    "task_id",
    "task_name",
    "chat_id",
    "status",
    "summary",
    "error_message",
    "test_run",
    "input_tokens",
    "output_tokens",
    "credits_consumed",
    "cancel_requested_at",
    "tool_calls_count",
    "duration_ms",
    "started_at",
    "completed_at",
    "created_at",
    "updated_at",
    "skip_reason",
    "skip_count",
    "delivery_status",
    "completion",
    "trigger_source",
    "trigger_event",
    "replay_of",
    "captured_deliveries",
    "pending_approval_ids"
  ],
  "$defs": {
    "Artifact": {
      "type": "object",
      "properties": {
        "object": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "filename": {
          "type": "string"
        },
        "content_type": {
          "type": [
            "string",
            "null"
          ]
        },
        "size": {
          "type": "integer"
        }
      },
      "required": [
        "object",
        "id",
        "filename",
        "content_type",
        "size"
      ]
    }
  }
}