All contracts

Workspace Intelligence / JSON Schema

Workspai Model and Agent Usage Event

A privacy-bounded usage observation. Prompt and response bodies are deliberately excluded; consumers may provide hashes instead.

Schema version
model-usage-event.v1
Contract path
contracts/workspace-intelligence/model-usage-event.v1.json
Publication
json-schema
Defined fields
35
Artifact bindings
0

Why this contract exists

Architecture role

Defines canonical workspace state or a versioned projection of that state.

Consumption boundary

  • Workspai CLI
  • Workspace Intelligence consumers
  • IDEs and agents

Related commands

Commands are linked only when the runtime contract identifies a direct production relationship. Supporting contracts may be consumed without having a single producer command.

This is a supporting, capability, cache, compatibility, or consumer contract. It has no single direct producer command in the canonical Workspace Intelligence execution registry.

Produced artifacts

These durable files are emitted by registered commands and validated against this contract.

No canonical file artifact is registered for this contract. It may describe capabilities, embedded data, runtime exchange, or supporting state instead of a standalone report.

Field reference

Every declared schema property or published capability path is listed here. Required means the contract declares or publishes that field at the shown boundary.

Field pathTypeRequiredMeaningConstraints
eventIdstringYesDefines the eventid value at this contract boundary.minLength: 1
kindenumYesDefines the kind value at this contract boundary.enum: model-call, tool-call, outcome, milestone
milestoneobjectNoDefines the milestone value at this contract boundary.additionalProperties: false
milestone.detailstringNoDefines the detail value at this contract boundary.minLength: 1
milestone.namestringYesDefines the name value at this contract boundary.minLength: 1
modelCallobjectNoDefines the modelcall value at this contract boundary.additionalProperties: false
modelCall.cachedInputTokensinteger | nullYesDefines the cachedinputtokens value at this contract boundary.minimum: 0
modelCall.costobjectNoDefines the cost value at this contract boundary.additionalProperties: false
modelCall.cost.amountnumberYesDefines the amount value at this contract boundary.minimum: 0
modelCall.cost.currencystringYesDefines the currency value at this contract boundary.pattern: ^[A-Z]{3}$
modelCall.cost.sourceenumYesDefines the source value at this contract boundary.enum: provider-reported, catalog-estimated
modelCall.inputTokensinteger | nullYesDefines the inputtokens value at this contract boundary.minimum: 0
modelCall.latencyMsnumber | nullYesDefines the latencyms value at this contract boundary.minimum: 0
modelCall.modelstringYesDefines the model value at this contract boundary.minLength: 1
modelCall.outputTokensinteger | nullYesDefines the outputtokens value at this contract boundary.minimum: 0
modelCall.promptHashstringNoDefines the prompthash value at this contract boundary.pattern: ^[a-f0-9]{64}$
modelCall.providerstringYesDefines the provider value at this contract boundary.minLength: 1
modelCall.reasoningTokensinteger | nullYesDefines the reasoningtokens value at this contract boundary.minimum: 0
modelCall.responseHashstringNoDefines the responsehash value at this contract boundary.pattern: ^[a-f0-9]{64}$
modelCall.sourceenumYesDefines the source value at this contract boundary.enum: provider-reported, tokenizer-counted, estimated, unavailable
modelCall.tokenizerstringNoDefines the tokenizer value at this contract boundary.minLength: 1
outcomeobjectNoDefines the outcome value at this contract boundary.additionalProperties: false
outcome.blockersResolvedintegerYesDefines the blockersresolved value at this contract boundary.minimum: 0
outcome.statusenumYesDefines the status value at this contract boundary.enum: passed, failed, blocked, unknown
outcome.summarystringNoDefines the summary value at this contract boundary.minLength: 1
outcome.verifiedbooleanYesDefines the verified value at this contract boundary.
recordedAtstringYesDefines the recordedat value at this contract boundary.format: date-time
schemaVersionstringYesDefines the schemaversion value at this contract boundary.const: "model-usage-event.v1"
stagestringNoDefines the stage value at this contract boundary.minLength: 1
toolCallobjectNoDefines the toolcall value at this contract boundary.additionalProperties: false
toolCall.artifactstringNoDefines the artifact value at this contract boundary.minLength: 1
toolCall.changedSourcebooleanYesDefines the changedsource value at this contract boundary.
toolCall.durationMsnumber | nullYesDefines the durationms value at this contract boundary.minimum: 0
toolCall.resultenumYesDefines the result value at this contract boundary.enum: passed, failed, blocked, skipped
toolCall.toolstringYesDefines the tool value at this contract boundary.minLength: 1

Canonical machine-readable definition

The raw synchronized contract remains authoritative. The educational sections above are projections of this definition.

Show raw JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getrapidkit.com/schemas/model-usage-event.v1.json",
  "title": "Workspai Model and Agent Usage Event",
  "description": "A privacy-bounded usage observation. Prompt and response bodies are deliberately excluded; consumers may provide hashes instead.",
  "type": "object",
  "required": [
    "schemaVersion",
    "eventId",
    "recordedAt",
    "kind"
  ],
  "properties": {
    "schemaVersion": {
      "const": "model-usage-event.v1"
    },
    "eventId": {
      "type": "string",
      "minLength": 1
    },
    "recordedAt": {
      "type": "string",
      "format": "date-time"
    },
    "kind": {
      "enum": [
        "model-call",
        "tool-call",
        "outcome",
        "milestone"
      ]
    },
    "stage": {
      "type": "string",
      "minLength": 1
    },
    "modelCall": {
      "type": "object",
      "required": [
        "provider",
        "model",
        "source",
        "inputTokens",
        "outputTokens",
        "cachedInputTokens",
        "reasoningTokens",
        "latencyMs"
      ],
      "properties": {
        "provider": {
          "type": "string",
          "minLength": 1
        },
        "model": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "enum": [
            "provider-reported",
            "tokenizer-counted",
            "estimated",
            "unavailable"
          ]
        },
        "tokenizer": {
          "type": "string",
          "minLength": 1
        },
        "inputTokens": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "outputTokens": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "cachedInputTokens": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "reasoningTokens": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "latencyMs": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "promptHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "responseHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "cost": {
          "type": "object",
          "required": [
            "amount",
            "currency",
            "source"
          ],
          "properties": {
            "amount": {
              "type": "number",
              "minimum": 0
            },
            "currency": {
              "type": "string",
              "pattern": "^[A-Z]{3}$"
            },
            "source": {
              "enum": [
                "provider-reported",
                "catalog-estimated"
              ]
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "toolCall": {
      "type": "object",
      "required": [
        "tool",
        "result",
        "changedSource",
        "durationMs"
      ],
      "properties": {
        "tool": {
          "type": "string",
          "minLength": 1
        },
        "result": {
          "enum": [
            "passed",
            "failed",
            "blocked",
            "skipped"
          ]
        },
        "changedSource": {
          "type": "boolean"
        },
        "durationMs": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "artifact": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "outcome": {
      "type": "object",
      "required": [
        "status",
        "verified",
        "blockersResolved"
      ],
      "properties": {
        "status": {
          "enum": [
            "passed",
            "failed",
            "blocked",
            "unknown"
          ]
        },
        "verified": {
          "type": "boolean"
        },
        "blockersResolved": {
          "type": "integer",
          "minimum": 0
        },
        "summary": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "milestone": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "detail": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "kind": {
            "const": "model-call"
          }
        }
      },
      "then": {
        "properties": {
          "modelCall": {}
        },
        "required": [
          "modelCall"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "kind": {
            "const": "tool-call"
          }
        }
      },
      "then": {
        "properties": {
          "toolCall": {}
        },
        "required": [
          "toolCall"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "kind": {
            "const": "outcome"
          }
        }
      },
      "then": {
        "properties": {
          "outcome": {}
        },
        "required": [
          "outcome"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "kind": {
            "const": "milestone"
          }
        }
      },
      "then": {
        "properties": {
          "milestone": {}
        },
        "required": [
          "milestone"
        ]
      }
    }
  ],
  "additionalProperties": false
}