{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ErrorNotification",
  "type": "object",
  "required": ["error", "threadId", "turnId", "willRetry"],
  "properties": {
    "error": {
      "$ref": "#/definitions/TurnError"
    },
    "threadId": {
      "type": "string"
    },
    "turnId": {
      "type": "string"
    },
    "willRetry": {
      "type": "boolean"
    }
  },
  "definitions": {
    "CodexErrorInfo": {
      "description": "This translation layer make sure that we expose codex error code in camel case.\n\nWhen an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant.",
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "contextWindowExceeded",
            "usageLimitExceeded",
            "serverOverloaded",
            "cyberPolicy",
            "internalServerError",
            "unauthorized",
            "badRequest",
            "threadRollbackFailed",
            "sandboxError",
            "other"
          ]
        },
        {
          "type": "object",
          "required": ["httpConnectionFailed"],
          "properties": {
            "httpConnectionFailed": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "HttpConnectionFailedCodexErrorInfo"
        },
        {
          "description": "Failed to connect to the response SSE stream.",
          "type": "object",
          "required": ["responseStreamConnectionFailed"],
          "properties": {
            "responseStreamConnectionFailed": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ResponseStreamConnectionFailedCodexErrorInfo"
        },
        {
          "description": "The response SSE stream disconnected in the middle of a turn before completion.",
          "type": "object",
          "required": ["responseStreamDisconnected"],
          "properties": {
            "responseStreamDisconnected": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ResponseStreamDisconnectedCodexErrorInfo"
        },
        {
          "description": "Reached the retry limit for responses.",
          "type": "object",
          "required": ["responseTooManyFailedAttempts"],
          "properties": {
            "responseTooManyFailedAttempts": {
              "type": "object",
              "properties": {
                "httpStatusCode": {
                  "type": ["integer", "null"],
                  "format": "uint16",
                  "minimum": 0.0
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ResponseTooManyFailedAttemptsCodexErrorInfo"
        },
        {
          "description": "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
          "type": "object",
          "required": ["activeTurnNotSteerable"],
          "properties": {
            "activeTurnNotSteerable": {
              "type": "object",
              "required": ["turnKind"],
              "properties": {
                "turnKind": {
                  "$ref": "#/definitions/NonSteerableTurnKind"
                }
              }
            }
          },
          "additionalProperties": false,
          "title": "ActiveTurnNotSteerableCodexErrorInfo"
        }
      ]
    },
    "NonSteerableTurnKind": {
      "type": "string",
      "enum": ["review", "compact"]
    },
    "TurnError": {
      "type": "object",
      "required": ["message"],
      "properties": {
        "additionalDetails": {
          "default": null,
          "type": ["string", "null"]
        },
        "codexErrorInfo": {
          "anyOf": [
            {
              "$ref": "#/definitions/CodexErrorInfo"
            },
            {
              "type": "null"
            }
          ]
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}
