{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/grepr/json-schema/grepr-agent-session-analytics-job-schema.json",
  "title": "AgentSessionAnalyticsJob",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grepr-agent-session-analytics-api-openapi.yml#/components/schemas/AgentSessionAnalyticsJob",
  "properties": {
    "analysisVersion": {
      "type": "string"
    },
    "analyzedSessionCount": {
      "format": "int64",
      "type": "integer"
    },
    "artifactByteSize": {
      "format": "int64",
      "type": "integer"
    },
    "clusteringAlgorithmVersion": {
      "type": "string"
    },
    "completedAt": {
      "format": "date-time",
      "type": "string"
    },
    "createdAt": {
      "format": "date-time",
      "type": "string"
    },
    "dashboardSummary": {
      "$ref": "#/$defs/AgentAnalyticsDashboardSummary"
    },
    "datasetId": {
      "type": "string"
    },
    "downloadAvailable": {
      "type": "boolean"
    },
    "embeddingDimensions": {
      "format": "int32",
      "type": "integer"
    },
    "embeddingModel": {
      "type": "string"
    },
    "exportedSessionCount": {
      "format": "int64",
      "type": "integer"
    },
    "failureReason": {
      "type": "string"
    },
    "jobId": {
      "type": "string"
    },
    "jobState": {
      "enum": [
        "CREATED",
        "PENDING",
        "INFRA_UPDATE",
        "INFRA_UPDATE_WAIT",
        "VERIFYING",
        "WAITING",
        "RUNNING",
        "STOPPED",
        "FINISHED",
        "FAILED",
        "CANCELLED",
        "DELETED",
        "UPDATING",
        "STARTING",
        "RESTARTING",
        "STOPPING",
        "ROLLING_BACK",
        "DELETING"
      ],
      "type": "string"
    },
    "labelModel": {
      "type": "string"
    },
    "matchingSessionCount": {
      "format": "int64",
      "type": "integer"
    },
    "miscellaneousSessionCount": {
      "format": "int32",
      "type": "integer"
    },
    "namedGroupCount": {
      "format": "int32",
      "type": "integer"
    },
    "request": {
      "$ref": "#/$defs/CreateAgentSessionAnalyticsJob"
    },
    "resultWasCapped": {
      "type": "boolean"
    },
    "state": {
      "enum": [
        "RUNNING",
        "COMPLETED",
        "FAILED",
        "CANCELLED"
      ],
      "type": "string"
    },
    "warningCount": {
      "format": "int32",
      "type": "integer"
    }
  },
  "type": "object",
  "$defs": {
    "AgentAnalyticsDashboardSummary": {
      "properties": {
        "dataQuality": {
          "$ref": "#/$defs/DataQuality"
        },
        "emitters": {
          "items": {
            "$ref": "#/$defs/Breakdown"
          },
          "type": "array"
        },
        "intentToolMatrix": {
          "items": {
            "$ref": "#/$defs/MatrixCell"
          },
          "type": "array"
        },
        "intentUsage": {
          "items": {
            "$ref": "#/$defs/Breakdown"
          },
          "type": "array"
        },
        "models": {
          "items": {
            "$ref": "#/$defs/Breakdown"
          },
          "type": "array"
        },
        "topIntents": {
          "items": {
            "$ref": "#/$defs/Intent"
          },
          "type": "array"
        },
        "topTools": {
          "items": {
            "$ref": "#/$defs/Tool"
          },
          "type": "array"
        },
        "totals": {
          "$ref": "#/$defs/Totals"
        }
      },
      "type": "object"
    },
    "AndEventPredicate": {
      "properties": {
        "queries": {
          "default": [],
          "description": "List of predicates that must all match for this predicate to match.",
          "items": {
            "$ref": "#/$defs/EventPredicate"
          },
          "maxItems": 2147483647,
          "minItems": 1,
          "title": "Child predicates",
          "type": "array"
        },
        "type": {
          "description": "A predicate that matches when every child predicate matches.",
          "enum": [
            "and-predicate"
          ],
          "type": "string"
        }
      },
      "required": [
        "queries",
        "type"
      ],
      "type": "object"
    },
    "Breakdown": {
      "properties": {
        "cacheReadTokens": {
          "format": "int64",
          "type": "integer"
        },
        "cacheWriteTokens": {
          "format": "int64",
          "type": "integer"
        },
        "calls": {
          "format": "int64",
          "type": "integer"
        },
        "callsWithUsage": {
          "format": "int64",
          "type": "integer"
        },
        "costReportingComplete": {
          "type": "boolean"
        },
        "inputTokens": {
          "format": "int64",
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "outputTokens": {
          "format": "int64",
          "type": "integer"
        },
        "reasoningTokens": {
          "format": "int64",
          "type": "integer"
        },
        "reportedCostUsd": {
          "format": "double",
          "type": "number"
        },
        "sessions": {
          "format": "int64",
          "type": "integer"
        }
      },
      "type": "object"
    },
    "CreateAgentSessionAnalyticsJob": {
      "properties": {
        "datasetId": {
          "type": "string"
        },
        "end": {
          "format": "date-time",
          "type": "string"
        },
        "maximumNamedGroups": {
          "default": 20,
          "format": "int32",
          "maximum": 100,
          "minimum": 1,
          "type": "integer"
        },
        "modelIntegrationId": {
          "type": "string"
        },
        "query": {
          "$ref": "#/$defs/EventPredicate"
        },
        "sessionCap": {
          "default": 10000,
          "format": "int32",
          "maximum": 100000,
          "minimum": 1,
          "type": "integer"
        },
        "start": {
          "format": "date-time",
          "type": "string"
        }
      },
      "required": [
        "datasetId",
        "end",
        "modelIntegrationId",
        "query",
        "start"
      ],
      "type": "object"
    },
    "DataQuality": {
      "properties": {
        "embeddingFailures": {
          "format": "int64",
          "type": "integer"
        },
        "incompleteContentSessions": {
          "format": "int64",
          "type": "integer"
        },
        "labelFailures": {
          "format": "int64",
          "type": "integer"
        },
        "metadataOnlyEvents": {
          "format": "int64",
          "type": "integer"
        },
        "missingUsageSessions": {
          "format": "int64",
          "type": "integer"
        },
        "truncatedEvents": {
          "format": "int64",
          "type": "integer"
        },
        "warnings": {
          "format": "int64",
          "type": "integer"
        }
      },
      "type": "object"
    },
    "DatadogQueryPredicate": {
      "properties": {
        "query": {
          "default": "",
          "description": "The datadog query used by the predicate. See https://docs.datadoghq.com/tracing/trace_explorer/query_syntax",
          "type": "string"
        },
        "type": {
          "description": "A predicate that checks if an event matches a datadog query.",
          "enum": [
            "datadog-query"
          ],
          "type": "string"
        }
      },
      "required": [
        "query",
        "type"
      ],
      "type": "object"
    },
    "EventPredicate": {
      "description": "Predicate applied to rows before analytical aggregation.",
      "oneOf": [
        {
          "$ref": "#/$defs/AndEventPredicate"
        },
        {
          "$ref": "#/$defs/DatadogQueryPredicate"
        },
        {
          "$ref": "#/$defs/MetricEventPredicate"
        },
        {
          "$ref": "#/$defs/NewRelicQueryPredicate"
        },
        {
          "$ref": "#/$defs/NrqlQueryPredicate"
        }
      ],
      "properties": {
        "query": {
          "type": "string"
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "type": "object"
    },
    "Intent": {
      "properties": {
        "description": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "miscellaneous": {
          "type": "boolean"
        },
        "percentage": {
          "format": "double",
          "type": "number"
        },
        "sessions": {
          "format": "int64",
          "type": "integer"
        }
      },
      "type": "object"
    },
    "MatrixCell": {
      "properties": {
        "intent": {
          "type": "string"
        },
        "operation": {
          "type": "string"
        },
        "sessionsUsing": {
          "format": "int64",
          "type": "integer"
        }
      },
      "type": "object"
    },
    "MetricEventPredicate": {
      "properties": {
        "filterTags": {
          "additionalProperties": {
            "default": {},
            "description": "The set of tags to query for. If unspecified, all tags are queried.",
            "items": {
              "default": "{}",
              "description": "The set of tags to query for. If unspecified, all tags are queried.",
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          },
          "default": {},
          "description": "The set of tags to query for. If unspecified, all tags are queried.",
          "type": "object"
        },
        "metricNames": {
          "default": [],
          "description": "The names of the metrics to query. Must not be empty.",
          "items": {
            "description": "The names of the metrics to query. Must not be empty.",
            "type": "string"
          },
          "maxItems": 2147483647,
          "minItems": 1,
          "type": "array"
        },
        "query": {
          "type": "string"
        },
        "type": {
          "description": "A predicate that checks if an event matches a metrics query.",
          "enum": [
            "metric-predicate"
          ],
          "type": "string"
        }
      },
      "required": [
        "metricNames",
        "query",
        "type"
      ],
      "type": "object"
    },
    "NewRelicQueryPredicate": {
      "properties": {
        "query": {
          "default": "",
          "description": "The New Relic query used by the predicate. See https://docs.newrelic.com/docs/logs/ui-data/query-syntax-logs/ ",
          "type": "string"
        },
        "type": {
          "description": "A predicate that checks if an event matches a New Relic query.",
          "enum": [
            "newrelic-query"
          ],
          "type": "string"
        }
      },
      "required": [
        "query",
        "type"
      ],
      "type": "object"
    },
    "NrqlQueryPredicate": {
      "properties": {
        "query": {
          "default": "",
          "description": "The Nrql query used by the predicate. See https://docs.newrelic.com/docs/nrql",
          "type": "string"
        },
        "strict": {
          "default": true,
          "description": "Whether the query should be parsed in strict mode.",
          "type": "boolean"
        },
        "type": {
          "description": "A predicate that checks if an event matches an NRQL query.",
          "enum": [
            "nrql-query"
          ],
          "type": "string"
        }
      },
      "required": [
        "query",
        "type"
      ],
      "type": "object"
    },
    "Tool": {
      "properties": {
        "calls": {
          "format": "int64",
          "type": "integer"
        },
        "costReportingComplete": {
          "type": "boolean"
        },
        "durationMs": {
          "format": "int64",
          "type": "integer"
        },
        "errors": {
          "format": "int64",
          "type": "integer"
        },
        "operation": {
          "type": "string"
        },
        "reportedCostUsd": {
          "format": "double",
          "type": "number"
        },
        "resultBytes": {
          "format": "int64",
          "type": "integer"
        },
        "sessionsUsing": {
          "format": "int64",
          "type": "integer"
        }
      },
      "type": "object"
    },
    "Totals": {
      "properties": {
        "analyzedSessions": {
          "format": "int64",
          "type": "integer"
        },
        "cacheReadTokens": {
          "format": "int64",
          "type": "integer"
        },
        "cacheWriteTokens": {
          "format": "int64",
          "type": "integer"
        },
        "costReportingComplete": {
          "type": "boolean"
        },
        "exportedSessions": {
          "format": "int64",
          "type": "integer"
        },
        "inputTokens": {
          "format": "int64",
          "type": "integer"
        },
        "matchingSessions": {
          "format": "int64",
          "type": "integer"
        },
        "miscellaneousSessions": {
          "format": "int64",
          "type": "integer"
        },
        "modelCalls": {
          "format": "int64",
          "type": "integer"
        },
        "namedGroupSessions": {
          "format": "int64",
          "type": "integer"
        },
        "outputTokens": {
          "format": "int64",
          "type": "integer"
        },
        "reasoningTokens": {
          "format": "int64",
          "type": "integer"
        },
        "reportedCostUsd": {
          "format": "double",
          "type": "number"
        },
        "sessionDurationMs": {
          "format": "int64",
          "type": "integer"
        },
        "toolCalls": {
          "format": "int64",
          "type": "integer"
        },
        "toolDurationMs": {
          "format": "int64",
          "type": "integer"
        },
        "toolErrors": {
          "format": "int64",
          "type": "integer"
        },
        "toolResultBytes": {
          "format": "int64",
          "type": "integer"
        }
      },
      "type": "object"
    }
  }
}