ModelConnector/schemas/transport_result.json
Meta Vens b92c63149c connector-spend (B3c): reserve-then-settle spend in the replay record, cost derived on the receipt
The replay store is the connector's one durable ledger. begin reserves the
request's worst case in the Active record it claims the request with, in one
write: a ledger that cannot be written means nothing runs. complete settles
the reservation to the charge derived from the outcome's usage under the
service's price table; a backend reports usage only, never cost, and a receipt
carrying any other cost is answered with the Provider stand-in at the whole
reservation. Amounts are integer micro-USD, prices micro-USD per million
tokens, rounded up once per request.

Refusals: CostBound (the worst case exceeds the invocation's max_cost_micro_usd,
decided before the replay lookup) and SpendCeiling (the caller's window cannot
hold the reservation, after the replay lookup). Each caller's config carries a
spend ceiling and window length, both required nonzero; windows are fixed and
aligned to the unix epoch, and a request belongs to the window it was admitted
in. The per-window spend is re-derived from the records at open.

gamecult.model.replay_record.v1 is replaced by v2 (no reader survives). The
published invocation, receipt and result schemas and their wire goldens are
regenerated; provider_request and input_reasoning_state stay byte-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 15:12:56 +01:00

394 lines
10 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TransportResult",
"type": "object",
"properties": {
"caller_runtime_id": {
"type": "string"
},
"disposition": {
"$ref": "#/$defs/TransportDisposition"
},
"request_id": {
"type": "string"
},
"schema_id": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"schema_id",
"request_id",
"caller_runtime_id",
"disposition"
],
"$defs": {
"FailureKind": {
"description": "What kind of failure a provider reported. `ResultSize` is the connector's own\nstand-in for a result whose sealed frame cannot be carried.",
"type": "string",
"enum": [
"result_size",
"invalid_request",
"authentication",
"rate_limited",
"unavailable",
"timeout",
"provider"
]
},
"Refusal": {
"type": "string",
"enum": [
"Expired",
"IdentitySubstitution",
"ProviderDigestSubstitution",
"ModelNotAllowed",
"OutputBound",
"PayloadBound",
"CostBound",
"SpendCeiling",
"Capacity",
"InFlight",
"Indeterminate",
"ReplayConflict",
"Malformed",
"ForeignReasoningState"
]
},
"StopReason": {
"description": "Why a provider stopped producing output.",
"type": "string",
"enum": [
"end_turn",
"tool_use",
"max_output_tokens",
"stop_sequence",
"refusal",
"context_window"
]
},
"TransportDisposition": {
"oneOf": [
{
"type": "object",
"properties": {
"Refused": {
"$ref": "#/$defs/Refusal"
}
},
"additionalProperties": false,
"required": [
"Refused"
]
},
{
"type": "object",
"properties": {
"Transported": {
"type": "object",
"properties": {
"events": {
"type": "array",
"items": {
"$ref": "#/$defs/TransportEvent"
}
},
"receipt": {
"$ref": "#/$defs/TransportReceipt"
}
},
"additionalProperties": false,
"required": [
"events",
"receipt"
]
}
},
"additionalProperties": false,
"required": [
"Transported"
]
}
]
},
"TransportEvent": {
"type": "object",
"properties": {
"payload": {
"$ref": "#/$defs/TransportEventPayload"
},
"sequence": {
"type": "integer",
"format": "uint64",
"minimum": 0
}
},
"additionalProperties": false,
"required": [
"sequence",
"payload"
]
},
"TransportEventPayload": {
"oneOf": [
{
"type": "object",
"properties": {
"TextDelta": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"text"
]
}
},
"additionalProperties": false,
"required": [
"TextDelta"
]
},
{
"type": "object",
"properties": {
"ToolCall": {
"type": "object",
"properties": {
"arguments": {
"type": "string"
},
"call_id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"call_id",
"name",
"arguments"
]
}
},
"additionalProperties": false,
"required": [
"ToolCall"
]
},
{
"description": "One reasoning block of the provider that answered. It carries no\nprovider or model: the receipt names them, so a backend cannot tag its\nown state.",
"type": "object",
"properties": {
"ReasoningState": {
"type": "object",
"properties": {
"state": {
"description": "MessagePack bin: raw bytes, never an array of integers",
"type": "string",
"format": "binary"
}
},
"additionalProperties": false,
"required": [
"state"
]
}
},
"additionalProperties": false,
"required": [
"ReasoningState"
]
}
]
},
"TransportOutcome": {
"oneOf": [
{
"type": "object",
"properties": {
"Completed": {
"type": "object",
"properties": {
"provider_response_id": {
"type": [
"string",
"null"
]
},
"stop_reason": {
"$ref": "#/$defs/StopReason"
},
"usage": {
"$ref": "#/$defs/Usage"
}
},
"additionalProperties": false,
"required": [
"stop_reason",
"usage"
]
}
},
"additionalProperties": false,
"required": [
"Completed"
]
},
{
"type": "object",
"properties": {
"Failed": {
"type": "object",
"properties": {
"kind": {
"$ref": "#/$defs/FailureKind"
},
"message": {
"type": "string"
},
"usage": {
"description": "What the provider billed for the failed request: `Some` when it\nreported usage (`Some` of zeros when it billed nothing), `None`\nwhen unknown.",
"anyOf": [
{
"$ref": "#/$defs/Usage"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"required": [
"kind",
"message"
]
}
},
"additionalProperties": false,
"required": [
"Failed"
]
}
]
},
"TransportReceipt": {
"type": "object",
"properties": {
"caller_runtime_id": {
"type": "string"
},
"cost_micro_usd": {
"description": "What the request cost, in micro-USD. The service derives it from the\noutcome's usage and its price table; a backend never writes it.",
"type": "integer",
"format": "uint64",
"minimum": 0
},
"foreign_reasoning_dropped": {
"description": "How many foreign `ReasoningState` items the service removed from the\nrequest before the backend saw it.",
"type": "integer",
"format": "uint32",
"minimum": 0
},
"model": {
"type": "string"
},
"native_request_sha256": {
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"maximum": 255,
"minimum": 0
},
"maxItems": 32,
"minItems": 32
},
"outcome": {
"$ref": "#/$defs/TransportOutcome"
},
"provider": {
"type": "string"
},
"provider_request_sha256": {
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"maximum": 255,
"minimum": 0
},
"maxItems": 32,
"minItems": 32
},
"request_id": {
"type": "string"
},
"schema_id": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"schema_id",
"request_id",
"caller_runtime_id",
"native_request_sha256",
"provider_request_sha256",
"model",
"provider",
"foreign_reasoning_dropped",
"cost_micro_usd",
"outcome"
]
},
"Usage": {
"description": "Token accounting for one request, as the backend reports it; the service\nprices it. Cache reads and writes are counted apart from plain input.\n`output_tokens` includes reasoning tokens: `reasoning_tokens` is a detail\n(absent when the provider does not report it) and is never priced apart.",
"type": "object",
"properties": {
"cache_read_tokens": {
"type": "integer",
"format": "uint64",
"minimum": 0
},
"cache_write_tokens": {
"type": "integer",
"format": "uint64",
"minimum": 0
},
"input_tokens": {
"type": "integer",
"format": "uint64",
"minimum": 0
},
"output_tokens": {
"type": "integer",
"format": "uint64",
"minimum": 0
},
"reasoning_tokens": {
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0
}
},
"additionalProperties": false,
"required": [
"input_tokens",
"cache_read_tokens",
"cache_write_tokens",
"output_tokens"
]
}
}
}