{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hud-ai/json-schema/hud-ai-trace-analysis-context-response-schema.json",
  "title": "TraceAnalysisContextResponse",
  "description": "Aggregate read for analysis envs; spans carry presigned artifact URLs.",
  "x-generated": "2026-10-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hud-ai-openapi.yml#/components/schemas/TraceAnalysisContextResponse",
  "properties": {
    "trace_id": {
      "type": "string",
      "format": "uuid",
      "title": "Trace Id"
    },
    "job_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Job Id"
    },
    "task_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Task Id"
    },
    "task_version_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Task Version Id"
    },
    "task_external_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Task External Id"
    },
    "task_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Task Name"
    },
    "status": {
      "type": "string",
      "title": "Status"
    },
    "reward": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Reward"
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error"
    },
    "error_code": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error Code"
    },
    "error_source": {
      "anyOf": [
        {
          "$ref": "#/$defs/ErrorSource"
        },
        {
          "type": "null"
        }
      ]
    },
    "prompt": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Prompt"
    },
    "scenario_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Scenario Name"
    },
    "scenario_args": {
      "additionalProperties": true,
      "type": "object",
      "title": "Scenario Args"
    },
    "scenario_code": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Scenario Code"
    },
    "registry_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Registry Id"
    },
    "evaluation_result": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Evaluation Result"
    },
    "metadata": {
      "additionalProperties": true,
      "type": "object",
      "title": "Metadata"
    },
    "spans": {
      "anyOf": [
        {
          "items": {
            "additionalProperties": true,
            "type": "object"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Spans"
    },
    "spans_count": {
      "type": "integer",
      "title": "Spans Count",
      "default": 0
    },
    "failed_spans": {
      "items": {
        "$ref": "#/$defs/FailedSpanInfo"
      },
      "type": "array",
      "title": "Failed Spans"
    },
    "env_logs": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/EnvLogEntry"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Env Logs"
    },
    "worker_logs": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Worker Logs"
    }
  },
  "type": "object",
  "required": [
    "trace_id",
    "status"
  ],
  "$defs": {
    "EnvLogEntry": {
      "properties": {
        "stream": {
          "type": "string",
          "title": "Stream"
        },
        "log": {
          "type": "string",
          "title": "Log"
        },
        "time": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Time"
        }
      },
      "type": "object",
      "required": [
        "stream",
        "log"
      ],
      "title": "EnvLogEntry",
      "description": "A single line of container output."
    },
    "ErrorSource": {
      "type": "string",
      "enum": [
        "user",
        "platform",
        "provider"
      ],
      "title": "ErrorSource",
      "description": "Who is at fault for a failure.\n\n``user``: the customer's input, account, environment, or agent code.\n``platform``: HUD infrastructure or a broken platform invariant.\n``provider``: a third-party dependency (cloud runtime, upstream LLM API)."
    },
    "FailedSpanInfo": {
      "properties": {
        "seq": {
          "type": "integer",
          "title": "Seq"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Error"
        }
      },
      "type": "object",
      "required": [
        "seq"
      ],
      "title": "FailedSpanInfo",
      "description": "A telemetry span that failed to ingest — a gap in the trajectory."
    }
  }
}