{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api.forgeling.io/schemas/events/turn.failed.json",
  "title": "turn.failed",
  "description": "A turn ended in failure.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "error",
    "usage",
    "duration_ms"
  ],
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "enum": [
            "timeout",
            "model_auth",
            "model_billing",
            "model_error",
            "capacity_unavailable",
            "repo_policy_unmet",
            "internal"
          ]
        },
        "message": {
          "type": "string"
        }
      }
    },
    "usage": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "$ref": "https://api.forgeling.io/schemas/defs/usage.json"
        }
      ]
    },
    "duration_ms": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    }
  }
}
