{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ag-ui.com/spec/1.0/schema.json",
  "title": "AG-UI Protocol",
  "description": "The machine-readable contract for the AG-UI protocol. Validating a document against this file validates it as an AG-UI event; every other definition is addressable by its own anchor, so this file's own address followed by #RunAgentInput names the request body. Addresses are written relative to $id rather than spelled out, so a frozen copy of this file describes itself rather than the draft it came from. Field names are camelCase because this describes the wire format rather than any language's idiom. Objects are exact: this file defines what exists in this version of the protocol, so a property it does not declare fails validation. Compatibility with newer minor versions is a behavioural rule for receivers, who tolerate what they do not recognise rather than rejecting it; a validator has no way to express tolerance, so that rule lives in the prose specification. How events may be ordered and whether a patch applies to the state it targets are behavioural rules for the same reason. Exactness has three kinds of exception: the compositional fragments — BaseEvent, Attributable, BaseMessage — which are open in themselves because the definitions composing them close the whole shape; objects that are open by meaning, because arbitrary keys are their data rather than unrecognised fields — metadata, activity content, a carried JSON Schema — and the JSON Patch operations, which stay open because RFC 6902 requires members an operation does not define to be ignored rather than rejected.",
  "$ref": "#/$defs/Event",
  "$defs": {
    "Event": {
      "$anchor": "Event",
      "description": "Any AG-UI event. Every member is normative: there is no optional tier and no event a consumer may decline to implement. Discriminated by the type property.",
      "oneOf": [
        { "$ref": "#/$defs/TextMessageStartEvent" },
        { "$ref": "#/$defs/TextMessageContentEvent" },
        { "$ref": "#/$defs/TextMessageEndEvent" },
        { "$ref": "#/$defs/TextMessageChunkEvent" },
        { "$ref": "#/$defs/ToolCallStartEvent" },
        { "$ref": "#/$defs/ToolCallArgsEvent" },
        { "$ref": "#/$defs/ToolCallEndEvent" },
        { "$ref": "#/$defs/ToolCallChunkEvent" },
        { "$ref": "#/$defs/ToolCallResultEvent" },
        { "$ref": "#/$defs/StateSnapshotEvent" },
        { "$ref": "#/$defs/StateDeltaEvent" },
        { "$ref": "#/$defs/MessagesSnapshotEvent" },
        { "$ref": "#/$defs/ActivitySnapshotEvent" },
        { "$ref": "#/$defs/ActivityDeltaEvent" },
        { "$ref": "#/$defs/RawEvent" },
        { "$ref": "#/$defs/CustomEvent" },
        { "$ref": "#/$defs/RunStartedEvent" },
        { "$ref": "#/$defs/RunFinishedEvent" },
        { "$ref": "#/$defs/RunErrorEvent" },
        { "$ref": "#/$defs/StepStartedEvent" },
        { "$ref": "#/$defs/StepFinishedEvent" },
        { "$ref": "#/$defs/ReasoningStartEvent" },
        { "$ref": "#/$defs/ReasoningMessageStartEvent" },
        { "$ref": "#/$defs/ReasoningMessageContentEvent" },
        { "$ref": "#/$defs/ReasoningMessageEndEvent" },
        { "$ref": "#/$defs/ReasoningMessageChunkEvent" },
        { "$ref": "#/$defs/ReasoningEndEvent" },
        { "$ref": "#/$defs/ReasoningEncryptedValueEvent" },
        { "$ref": "#/$defs/SubagentStartedEvent" },
        { "$ref": "#/$defs/SubagentFinishedEvent" },
        { "$ref": "#/$defs/SubagentErrorEvent" }
      ]
    },
    "EventType": {
      "$anchor": "EventType",
      "type": "string",
      "description": "The discriminator carried by every event.",
      "enum": [
        "TEXT_MESSAGE_START",
        "TEXT_MESSAGE_CONTENT",
        "TEXT_MESSAGE_END",
        "TEXT_MESSAGE_CHUNK",
        "TOOL_CALL_START",
        "TOOL_CALL_ARGS",
        "TOOL_CALL_END",
        "TOOL_CALL_CHUNK",
        "TOOL_CALL_RESULT",
        "STATE_SNAPSHOT",
        "STATE_DELTA",
        "MESSAGES_SNAPSHOT",
        "ACTIVITY_SNAPSHOT",
        "ACTIVITY_DELTA",
        "RAW",
        "CUSTOM",
        "RUN_STARTED",
        "RUN_FINISHED",
        "RUN_ERROR",
        "STEP_STARTED",
        "STEP_FINISHED",
        "REASONING_START",
        "REASONING_MESSAGE_START",
        "REASONING_MESSAGE_CONTENT",
        "REASONING_MESSAGE_END",
        "REASONING_MESSAGE_CHUNK",
        "REASONING_END",
        "REASONING_ENCRYPTED_VALUE",
        "SUBAGENT_STARTED",
        "SUBAGENT_FINISHED",
        "SUBAGENT_ERROR"
      ]
    },
    "BaseEvent": {
      "$anchor": "BaseEvent",
      "type": "object",
      "description": "The fields every event carries, whatever its type. Composed into each event definition rather than repeated, so a change here reaches every event at once.",
      "properties": {
        "type": {
          "$ref": "#/$defs/EventType",
          "description": "Which event this is. Each event definition narrows this to a single value."
        },
        "timestamp": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "When the event was created. Bounded to the range JSON numbers survive a round trip in, so the value a consumer reads is the value the producer wrote. Deliberately not a float. The unit is not constrained here, because it never has been stated normatively; every SDK that sets it in practice uses milliseconds since the Unix epoch, and a producer choosing another unit will be misread by consumers even though it validates. Nothing in the protocol computes with this value."
        },
        "rawEvent": {
          "not": { "type": "null" },
          "description": "The provider-native event this one was translated from, carried verbatim for debugging and for consumers that need detail the protocol does not model. Any JSON value."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this event."
        }
      },
      "required": ["type"]
    },
    "Attributable": {
      "$anchor": "Attributable",
      "type": "object",
      "description": "Composed into everything that can belong to a subagent's work: the events that describe content or progress, the message types, and each interrupt. Run-scoped events omit it — RUN_STARTED, RUN_FINISHED and RUN_ERROR describe the run itself and MESSAGES_SNAPSHOT is conversation-wide, so none of them can belong to one subagent. A tool call omits it too and inherits its containing message's attribution.",
      "properties": {
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The subagent invocation this belongs to. Absent means the parent agent produced it directly."
        }
      }
    },
    "SubagentRunId": {
      "$anchor": "SubagentRunId",
      "type": "string",
      "description": "An opaque handle for one subagent invocation, not a reusable name for a subagent definition: two invocations of the same subagent carry two different values. Named to mirror runId one level down, the way the subagent's name mirrors agentId."
    },
    "Metadata": {
      "$anchor": "Metadata",
      "type": "object",
      "description": "Extra information attached to an event, a message, a tool call, a tool, an interrupt or a resume entry. Open by key: any JSON value is allowed under a key, including null, because a null there is meaningful data. The object itself may be absent but is never null when present. The key ag-ui is reserved for the protocol's own use; reservation is by convention, since validating the shape of a key's value would contradict being open by key.",
      "additionalProperties": true
    },
    "State": {
      "$anchor": "State",
      "description": "Agent state. Any JSON value: the protocol carries state without interpreting it, so an object, an array, a string and a number are all valid."
    },
    "TextMessageRole": {
      "$anchor": "TextMessageRole",
      "type": "string",
      "description": "The roles a streamed text message may take. Excludes tool, which is carried by TOOL_CALL_RESULT rather than streamed as text.",
      "enum": ["developer", "system", "assistant", "user"]
    },
    "Role": {
      "$anchor": "Role",
      "type": "string",
      "description": "Every role a materialised message may have.",
      "enum": [
        "developer",
        "system",
        "assistant",
        "user",
        "tool",
        "activity",
        "reasoning"
      ]
    },
    "TextMessageStartEvent": {
      "$anchor": "TextMessageStartEvent",
      "type": "object",
      "description": "Opens a streamed text message. The content arrives as TEXT_MESSAGE_CONTENT events and the message closes with TEXT_MESSAGE_END.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_START" },
        "messageId": {
          "type": "string",
          "description": "Identifies the message this stream builds, and ties the later content and end events to it."
        },
        "role": {
          "$ref": "#/$defs/TextMessageRole",
          "default": "assistant",
          "description": "Who the message is from. An absent role means assistant; that meaning is normative and stated in the prose, because a validator treats a default as documentation rather than as behaviour."
        },
        "name": {
          "type": "string",
          "description": "An optional display name for the author, for providers that distinguish several participants in one role."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "TextMessageContentEvent": {
      "$anchor": "TextMessageContentEvent",
      "type": "object",
      "description": "Appends a fragment to a streamed text message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_CONTENT" },
        "messageId": {
          "type": "string",
          "description": "The message this fragment belongs to."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string: providers emit empty deltas as keep-alives and while a tool call is being decided, and rejecting them would kill runs that are working correctly."
        }
      },
      "required": ["type", "messageId", "delta"],
      "unevaluatedProperties": false
    },
    "TextMessageEndEvent": {
      "$anchor": "TextMessageEndEvent",
      "type": "object",
      "description": "Closes a streamed text message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_END" },
        "messageId": {
          "type": "string",
          "description": "The message being closed."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "TextMessageChunkEvent": {
      "$anchor": "TextMessageChunkEvent",
      "type": "object",
      "description": "A shorthand that stands in for a start, content and end sequence, for producers that cannot know in advance where a message begins. Every field is optional because a continuation chunk omits what has not changed; which message a field-less chunk continues is a sequence question the prose specification answers.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TEXT_MESSAGE_CHUNK" },
        "messageId": {
          "type": "string",
          "description": "The message this chunk belongs to. Absent continues the message already open."
        },
        "role": {
          "$ref": "#/$defs/TextMessageRole",
          "description": "Who the message is from, on the chunk that opens it."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string."
        },
        "name": {
          "type": "string",
          "description": "An optional display name for the author."
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "ToolCallStartEvent": {
      "$anchor": "ToolCallStartEvent",
      "type": "object",
      "description": "Opens a tool call. The arguments arrive as TOOL_CALL_ARGS events and the call closes with TOOL_CALL_END.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_START" },
        "toolCallId": {
          "type": "string",
          "description": "Identifies the call, and ties the later args, end and result events to it."
        },
        "toolCallName": {
          "type": "string",
          "description": "Which tool is being called."
        },
        "parentMessageId": {
          "type": "string",
          "description": "The assistant message that holds this call. Absent means the producer did not attribute it to one."
        }
      },
      "required": ["type", "toolCallId", "toolCallName"],
      "unevaluatedProperties": false
    },
    "ToolCallArgsEvent": {
      "$anchor": "ToolCallArgsEvent",
      "type": "object",
      "description": "Appends a fragment of a tool call's arguments.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_ARGS" },
        "toolCallId": {
          "type": "string",
          "description": "The call these arguments belong to."
        },
        "delta": {
          "type": "string",
          "description": "A fragment of the arguments, which concatenate into the call's argument text — conventionally a JSON document, though the protocol does not validate it (see FunctionCall.arguments). Deliberately a string rather than parsed JSON: a fragment is not itself a document. May be the empty string."
        }
      },
      "required": ["type", "toolCallId", "delta"],
      "unevaluatedProperties": false
    },
    "ToolCallEndEvent": {
      "$anchor": "ToolCallEndEvent",
      "type": "object",
      "description": "Closes a tool call, meaning its arguments are complete.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_END" },
        "toolCallId": {
          "type": "string",
          "description": "The call being closed."
        }
      },
      "required": ["type", "toolCallId"],
      "unevaluatedProperties": false
    },
    "ToolCallChunkEvent": {
      "$anchor": "ToolCallChunkEvent",
      "type": "object",
      "description": "A shorthand that stands in for a tool call's start, args and end sequence. Every field is optional for the same reason as TEXT_MESSAGE_CHUNK.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_CHUNK" },
        "toolCallId": {
          "type": "string",
          "description": "The call this chunk belongs to. Absent continues the call already open."
        },
        "toolCallName": {
          "type": "string",
          "description": "Which tool is being called, on the chunk that opens it."
        },
        "parentMessageId": {
          "type": "string",
          "description": "The assistant message that holds this call."
        },
        "delta": {
          "type": "string",
          "description": "A fragment of the arguments. May be the empty string."
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "ToolCallResultEvent": {
      "$anchor": "ToolCallResultEvent",
      "type": "object",
      "description": "Carries what a tool returned. Mints a tool message rather than appending to an existing one, which is why it has its own messageId.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "TOOL_CALL_RESULT" },
        "messageId": {
          "type": "string",
          "description": "The tool message this result becomes."
        },
        "toolCallId": {
          "type": "string",
          "description": "The call being answered."
        },
        "content": {
          "description": "What the tool returned: either plain text, or an ordered list of parts, exactly as on the tool message this event mints. A tool returning structured data serialises it into text; media travel as parts of their own.",
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "$ref": "#/$defs/ContentPart" } }
          ]
        },
        "role": {
          "const": "tool",
          "description": "Present only for symmetry with the message it mints; the value is fixed, so a producer may leave it out."
        }
      },
      "required": ["type", "messageId", "toolCallId", "content"],
      "unevaluatedProperties": false
    },
    "StateSnapshotEvent": {
      "$anchor": "StateSnapshotEvent",
      "type": "object",
      "description": "Replaces the agent state wholesale. Sent when a delta cannot express the change, or to resynchronise a consumer.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STATE_SNAPSHOT" },
        "snapshot": {
          "$ref": "#/$defs/State",
          "description": "The complete new state."
        }
      },
      "required": ["type", "snapshot"],
      "unevaluatedProperties": false
    },
    "StateDeltaEvent": {
      "$anchor": "StateDeltaEvent",
      "type": "object",
      "description": "Changes the agent state incrementally.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STATE_DELTA" },
        "delta": {
          "$ref": "#/$defs/JsonPatch",
          "description": "The change, as an RFC 6902 patch against the current state. Structural validity here does not mean the patch applies: a well-formed operation may point at a path that does not exist, which RFC 6902 leaves to the applier."
        }
      },
      "required": ["type", "delta"],
      "unevaluatedProperties": false
    },
    "MessagesSnapshotEvent": {
      "$anchor": "MessagesSnapshotEvent",
      "type": "object",
      "description": "The complete set of messages the producer owns, in order. Conversation-wide rather than a plain overwrite: a consumer may keep messages of its own that no producer tracks, so exactly how a snapshot reconciles with those is behavioural and belongs in the prose. Being conversation-wide it cannot belong to a single subagent, so it carries no attribution; it does establish which subagent owns each message it contains, through the messages themselves.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "MESSAGES_SNAPSHOT" },
        "messages": {
          "type": "array",
          "description": "The messages the producer is declaring, in order.",
          "items": { "$ref": "#/$defs/Message" }
        }
      },
      "required": ["type", "messages"],
      "unevaluatedProperties": false
    },
    "ActivitySnapshotEvent": {
      "$anchor": "ActivitySnapshotEvent",
      "type": "object",
      "description": "Reports structured progress that is not conversation content, such as a step a UI renders as its own widget.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "ACTIVITY_SNAPSHOT" },
        "messageId": {
          "type": "string",
          "description": "The activity message this describes."
        },
        "activityType": {
          "type": "string",
          "description": "What kind of activity this is. An open string: the set is the producer's, not the protocol's."
        },
        "content": {
          "type": "object",
          "description": "The activity's payload, open by key.",
          "additionalProperties": true
        },
        "replace": {
          "type": "boolean",
          "default": true,
          "description": "Whether this snapshot overwrites the activity's existing content. Absent means it does, and that meaning is normative; only an explicit false asks a consumer to leave what is already there. It does not ask for a merge — ACTIVITY_DELTA is how content is changed incrementally. What a consumer does with a non-overwriting snapshot is behavioural and belongs in the prose."
        }
      },
      "required": ["type", "messageId", "activityType", "content"],
      "unevaluatedProperties": false
    },
    "ActivityDeltaEvent": {
      "$anchor": "ActivityDeltaEvent",
      "type": "object",
      "description": "Changes an activity message's content incrementally.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "ACTIVITY_DELTA" },
        "messageId": {
          "type": "string",
          "description": "The activity message being changed."
        },
        "activityType": {
          "type": "string",
          "description": "What kind of activity this is."
        },
        "patch": {
          "$ref": "#/$defs/JsonPatch",
          "description": "The change, as an RFC 6902 patch against the activity's content."
        }
      },
      "required": ["type", "messageId", "activityType", "patch"],
      "unevaluatedProperties": false
    },
    "RawEvent": {
      "$anchor": "RawEvent",
      "type": "object",
      "description": "Passes a provider-native event through untranslated, for consumers that need detail the protocol does not model.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "RAW" },
        "event": {
          "description": "The provider's own event. Any JSON value, and required: an event whose only purpose is to carry this would say nothing without it."
        },
        "source": {
          "type": "string",
          "description": "Which provider or framework the event came from."
        }
      },
      "required": ["type", "event"],
      "unevaluatedProperties": false
    },
    "CustomEvent": {
      "$anchor": "CustomEvent",
      "type": "object",
      "description": "The protocol's extension point for an application's own events. Anything a consumer does with one is outside the protocol.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "CUSTOM" },
        "name": {
          "type": "string",
          "description": "What this custom event is. Required: without it a consumer cannot route the value."
        },
        "value": { "description": "The payload. Any JSON value, and required." }
      },
      "required": ["type", "name", "value"],
      "unevaluatedProperties": false
    },
    "RunStartedEvent": {
      "$anchor": "RunStartedEvent",
      "type": "object",
      "description": "Opens a run. Run-scoped, so it carries no subagent attribution.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "RUN_STARTED" },
        "threadId": {
          "type": "string",
          "description": "The conversation this run belongs to."
        },
        "runId": { "type": "string", "description": "Identifies this run." },
        "protocolVersion": {
          "type": "string",
          "description": "The protocol version this producer speaks, such as \"1.0\" — the producer's own version, not an echo of the input's, which is what makes the pair a negotiation: each side declares itself and the consumer sees a downgrade the moment it happens. Absent means a producer from before the protocol carried a version."
        },
        "parentRunId": {
          "type": "string",
          "description": "The run that spawned this one, when an agent invokes another agent as a separate run rather than as a subagent within one."
        },
        "input": {
          "$ref": "#/$defs/RunAgentInput",
          "description": "The request this run was started from, echoed back so a consumer that did not make the request can still see what the agent was asked."
        }
      },
      "required": ["type", "threadId", "runId"],
      "unevaluatedProperties": false
    },
    "RunFinishedEvent": {
      "$anchor": "RunFinishedEvent",
      "type": "object",
      "description": "Closes a run that did not fail. Run-scoped, so it carries no subagent attribution.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "RUN_FINISHED" },
        "threadId": {
          "type": "string",
          "description": "The conversation this run belongs to."
        },
        "runId": { "type": "string", "description": "The run being closed." },
        "result": {
          "not": { "type": "null" },
          "description": "The run's return value, if it has one. Any JSON value."
        },
        "outcome": {
          "$ref": "#/$defs/RunFinishedOutcome",
          "description": "Why the run ended. Absent means success, so every producer written before outcomes existed is already conformant."
        },
        "usage": {
          "type": "array",
          "description": "Token usage for the run, one entry per provider and model, so a run that invoked several models keeps them separate. A consumer that only wants totals sums across the entries. The run is the accounting boundary: usage covers every model call made within the run, calls made by its subagents included; an agent invoked as a separate run under parentRunId reports its own usage on its own terminal event; and a run that resumes an interrupted one reports only the calls it made itself, not the interrupted run's.",
          "items": { "$ref": "#/$defs/TokenUsage" }
        }
      },
      "required": ["type", "threadId", "runId"],
      "unevaluatedProperties": false
    },
    "RunErrorEvent": {
      "$anchor": "RunErrorEvent",
      "type": "object",
      "description": "Ends a run that failed. Run-scoped, so it carries no subagent attribution; a subagent that fails without ending the run reports SUBAGENT_ERROR instead.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "RUN_ERROR" },
        "message": {
          "type": "string",
          "description": "What went wrong, for a person to read."
        },
        "code": {
          "type": "string",
          "description": "A machine-readable error code. An open string: the protocol defines no vocabulary."
        },
        "usage": {
          "type": "array",
          "description": "Token usage accrued before the failure, for a run that completed one or more model calls before dying. Scoped as on RUN_FINISHED: the run's own calls, subagents included.",
          "items": { "$ref": "#/$defs/TokenUsage" }
        }
      },
      "required": ["type", "message"],
      "unevaluatedProperties": false
    },
    "StepStartedEvent": {
      "$anchor": "StepStartedEvent",
      "type": "object",
      "description": "Opens a named step within a run, for producers whose frameworks have a step concept worth surfacing.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STEP_STARTED" },
        "stepName": {
          "type": "string",
          "description": "The step's name. Identifies it: the matching STEP_FINISHED carries the same name."
        }
      },
      "required": ["type", "stepName"],
      "unevaluatedProperties": false
    },
    "StepFinishedEvent": {
      "$anchor": "StepFinishedEvent",
      "type": "object",
      "description": "Closes a named step.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "STEP_FINISHED" },
        "stepName": {
          "type": "string",
          "description": "The step being closed."
        }
      },
      "required": ["type", "stepName"],
      "unevaluatedProperties": false
    },
    "ReasoningStartEvent": {
      "$anchor": "ReasoningStartEvent",
      "type": "object",
      "description": "Opens a span of reasoning. A span may contain several reasoning messages.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_START" },
        "messageId": {
          "type": "string",
          "description": "The span being opened."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageStartEvent": {
      "$anchor": "ReasoningMessageStartEvent",
      "type": "object",
      "description": "Opens a streamed reasoning message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_START" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message this stream builds."
        },
        "role": {
          "const": "reasoning",
          "description": "Fixed, and required rather than defaulted. The requirement is inherited from the SDKs rather than chosen."
        }
      },
      "required": ["type", "messageId", "role"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageContentEvent": {
      "$anchor": "ReasoningMessageContentEvent",
      "type": "object",
      "description": "Appends a fragment to a streamed reasoning message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_CONTENT" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message this fragment belongs to."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string."
        }
      },
      "required": ["type", "messageId", "delta"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageEndEvent": {
      "$anchor": "ReasoningMessageEndEvent",
      "type": "object",
      "description": "Closes a streamed reasoning message.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_END" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message being closed."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "ReasoningMessageChunkEvent": {
      "$anchor": "ReasoningMessageChunkEvent",
      "type": "object",
      "description": "A shorthand that stands in for a reasoning message's start, content and end sequence.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_MESSAGE_CHUNK" },
        "messageId": {
          "type": "string",
          "description": "The reasoning message this chunk belongs to. Absent continues the one already open."
        },
        "delta": {
          "type": "string",
          "description": "The fragment to append. May be the empty string."
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "ReasoningEndEvent": {
      "$anchor": "ReasoningEndEvent",
      "type": "object",
      "description": "Closes a span of reasoning.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_END" },
        "messageId": {
          "type": "string",
          "description": "The span being closed."
        }
      },
      "required": ["type", "messageId"],
      "unevaluatedProperties": false
    },
    "ReasoningEncryptedValueEvent": {
      "$anchor": "ReasoningEncryptedValueEvent",
      "type": "object",
      "description": "Carries a provider's opaque, encrypted reasoning artefact, which a consumer stores and returns on a later turn without being able to read it.",
      "allOf": [
        { "$ref": "#/$defs/BaseEvent" },
        { "$ref": "#/$defs/Attributable" }
      ],
      "properties": {
        "type": { "const": "REASONING_ENCRYPTED_VALUE" },
        "subtype": {
          "$ref": "#/$defs/ReasoningEncryptedValueSubtype",
          "description": "What kind of thing entityId names, which decides where the value is stored."
        },
        "entityId": {
          "type": "string",
          "description": "What the value belongs to: a message id or a tool call id, according to subtype."
        },
        "encryptedValue": {
          "type": "string",
          "description": "The provider's opaque artefact."
        }
      },
      "required": ["type", "subtype", "entityId", "encryptedValue"],
      "unevaluatedProperties": false
    },
    "ReasoningEncryptedValueSubtype": {
      "$anchor": "ReasoningEncryptedValueSubtype",
      "type": "string",
      "description": "Whether a REASONING_ENCRYPTED_VALUE belongs to a message or to a tool call.",
      "enum": ["tool-call", "message"]
    },
    "SubagentStartedEvent": {
      "$anchor": "SubagentStartedEvent",
      "type": "object",
      "description": "Announces that a subagent invocation has begun. Everything the subagent produces afterwards is attributed by carrying its subagentRunId, so a consumer can group the work without replaying the stream. Composed from BaseEvent alone rather than Attributable, because here subagentRunId identifies the subagent rather than attributing the event to one; attribution to an enclosing subagent is parentSubagentRunId.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "SUBAGENT_STARTED" },
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The invocation being announced."
        },
        "name": {
          "type": "string",
          "description": "The subagent's name, which is reusable across invocations, unlike subagentRunId."
        },
        "description": {
          "type": "string",
          "description": "What this subagent is for, for a consumer to display."
        },
        "parentSubagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The subagent invocation that spawned this one, for nested delegation. Absent means the parent agent spawned it directly."
        },
        "parentToolCallId": {
          "type": "string",
          "description": "The tool call that spawned this subagent, for the pattern where agents are exposed to a model as tools. Lets a consumer tie the subagent to the call without reading rawEvent."
        },
        "parentMessageId": {
          "type": "string",
          "description": "The message that held the spawning tool call."
        }
      },
      "required": ["type", "subagentRunId", "name"],
      "unevaluatedProperties": false
    },
    "SubagentFinishedEvent": {
      "$anchor": "SubagentFinishedEvent",
      "type": "object",
      "description": "Ends a subagent invocation's segment of this run, either because the work completed or because it is suspended awaiting outside input.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "SUBAGENT_FINISHED" },
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The invocation being closed."
        },
        "result": {
          "not": { "type": "null" },
          "description": "The subagent's return value, if it has one. Any JSON value, mirroring RUN_FINISHED.result."
        },
        "outcome": {
          "$ref": "#/$defs/SubagentFinishedOutcome",
          "description": "Why the segment ended. Absent means success. A suspended subagent is neither a success nor a failure, which is why saying so needs its own value rather than being inferred from a later interrupt."
        }
      },
      "required": ["type", "subagentRunId"],
      "unevaluatedProperties": false
    },
    "SubagentErrorEvent": {
      "$anchor": "SubagentErrorEvent",
      "type": "object",
      "description": "Reports that a subagent invocation failed. The run may continue: a parent agent is free to handle a failed subagent, which is why this is not RUN_ERROR.",
      "allOf": [{ "$ref": "#/$defs/BaseEvent" }],
      "properties": {
        "type": { "const": "SUBAGENT_ERROR" },
        "subagentRunId": {
          "$ref": "#/$defs/SubagentRunId",
          "description": "The invocation that failed."
        },
        "message": {
          "type": "string",
          "description": "What went wrong, for a person to read."
        },
        "code": {
          "type": "string",
          "description": "A machine-readable error code. An open string."
        }
      },
      "required": ["type", "subagentRunId", "message"],
      "unevaluatedProperties": false
    },
    "RunFinishedOutcome": {
      "$anchor": "RunFinishedOutcome",
      "description": "Why a run ended.",
      "oneOf": [
        { "$ref": "#/$defs/RunFinishedSuccessOutcome" },
        { "$ref": "#/$defs/RunFinishedInterruptOutcome" },
        { "$ref": "#/$defs/RunFinishedCancelledOutcome" }
      ]
    },
    "RunFinishedSuccessOutcome": {
      "$anchor": "RunFinishedSuccessOutcome",
      "type": "object",
      "description": "The run completed. Equivalent to an absent outcome. Closed like every other object, which is also what keeps it from carrying the suspended sibling's interrupts — a success with an interrupt still pending would be a contradiction, not an extension. A completed run may still have left frontend tool calls for the application to answer; pendingToolCallIds names them.",
      "properties": {
        "type": { "const": "success", "description": "Discriminator." },
        "pendingToolCallIds": {
          "type": "array",
          "description": "The tool calls this run started and left unanswered — no TOOL_CALL_RESULT in the run — for the application to answer in the next input's messages, in the order they were made. Absent or empty means the producer named none, and a consumer derives the list from the stream; otherwise it is the list, and it agrees with the stream. On the success outcome rather than the event because a run that stopped on a frontend tool call is a completed run: whether the application continues the thread is its own decision, so the producer reports what it knows and no more.",
          "items": {
            "type": "string",
            "description": "A tool call id, as carried by TOOL_CALL_START."
          }
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "RunFinishedInterruptOutcome": {
      "$anchor": "RunFinishedInterruptOutcome",
      "type": "object",
      "description": "The run is paused, waiting for something outside it. Resuming means starting a new run whose resume entries answer these interrupts.",
      "properties": {
        "type": { "const": "interrupt", "description": "Discriminator." },
        "interrupts": {
          "type": "array",
          "description": "What the run is waiting for. At least one: an interrupt outcome with nothing to answer would leave a consumer with nothing to do.",
          "minItems": 1,
          "items": { "$ref": "#/$defs/Interrupt" }
        }
      },
      "required": ["type", "interrupts"],
      "unevaluatedProperties": false
    },
    "RunFinishedCancelledOutcome": {
      "$anchor": "RunFinishedCancelledOutcome",
      "type": "object",
      "description": "The run was stopped before it completed, by whoever was running it, and did not fail. Neither success nor interrupt: nothing was produced as a result, and nothing is waited for, so the next run on the thread is an ordinary new run rather than a resume. Closed like its siblings: a cancelled run has no interrupts to carry. Named in the schema before 1.0 because an outcome a consumer does not recognise is stripped and read as success — a cancellation added later would reach every 1.0 consumer as a completed run.",
      "properties": {
        "type": { "const": "cancelled", "description": "Discriminator." }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "SubagentFinishedOutcome": {
      "$anchor": "SubagentFinishedOutcome",
      "description": "Why a subagent's segment of a run ended. Mirrors RunFinishedOutcome one level down.",
      "oneOf": [
        { "$ref": "#/$defs/SubagentFinishedSuccessOutcome" },
        { "$ref": "#/$defs/SubagentFinishedSuspendedOutcome" }
      ]
    },
    "SubagentFinishedSuccessOutcome": {
      "$anchor": "SubagentFinishedSuccessOutcome",
      "type": "object",
      "description": "The subagent completed its work. Equivalent to an absent outcome.",
      "properties": {
        "type": { "const": "success", "description": "Discriminator." }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "SubagentFinishedSuspendedOutcome": {
      "$anchor": "SubagentFinishedSuspendedOutcome",
      "type": "object",
      "description": "The subagent is paused awaiting outside input. Terminal for this stream, not for the subagent: a later run may continue the same invocation once the interrupts are answered.",
      "properties": {
        "type": { "const": "suspended", "description": "Discriminator." },
        "interruptIds": {
          "type": "array",
          "description": "The run-level interrupts this subagent raised itself. May be empty or absent: a subagent suspended because a descendant interrupted owns no interrupt of its own.",
          "items": { "type": "string", "description": "An Interrupt.id." }
        }
      },
      "required": ["type"],
      "unevaluatedProperties": false
    },
    "Interrupt": {
      "$anchor": "Interrupt",
      "type": "object",
      "description": "Something a run needs from outside before it can continue, such as an approval or a missing value.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": {
          "type": "string",
          "description": "Identifies the interrupt. A resume entry answers it by this id."
        },
        "reason": {
          "type": "string",
          "description": "Why the run stopped. An open string rather than an enumeration: the protocol does not attempt to classify every reason an agent might need input."
        },
        "message": {
          "type": "string",
          "description": "A human-readable prompt for whoever answers."
        },
        "toolCallId": {
          "type": "string",
          "description": "The tool call this interrupt concerns, when it is a tool approval."
        },
        "responseSchema": {
          "type": "object",
          "description": "A JSON Schema describing the answer this interrupt expects, so a consumer can build a form for it. Carried opaquely: the protocol does not constrain or validate it. Restricted to an object because TypeScript and Python both declare it that way; .NET holds it as any JSON, and the ticket that commissioned this schema lists it among the arbitrary-JSON fields. Following the two that constrain it keeps the schema from accepting documents the reference client rejects, at the cost of rejecting the boolean schemas JSON Schema also permits — a bare true for \"any answer\". Recorded as a known divergence rather than settled.",
          "additionalProperties": true
        },
        "expiresAt": {
          "type": "string",
          "description": "When the interrupt stops being answerable. Deliberately unconstrained rather than a date-time format, because producers already disagree about the representation and tightening it here would reject streams that work today. The documented convention is ISO 8601, and a consumer comparing this value will parse it as a date, so a value that is not one leaves the interrupt looking permanently unexpired."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this interrupt."
        }
      },
      "required": ["id", "reason"],
      "unevaluatedProperties": false
    },
    "ResumeEntry": {
      "$anchor": "ResumeEntry",
      "type": "object",
      "description": "An answer to one interrupt, sent on the run that continues from it.",
      "properties": {
        "interruptId": {
          "type": "string",
          "description": "The interrupt being answered."
        },
        "status": {
          "type": "string",
          "description": "Whether the interrupt was answered or abandoned.",
          "enum": ["resolved", "cancelled"]
        },
        "payload": {
          "not": { "type": "null" },
          "description": "The answer the agent asked for and will act on. Any JSON value."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Envelope information about the response, such as signatures or routing keys, as opposed to payload, which is the answer itself."
        }
      },
      "required": ["interruptId", "status"],
      "unevaluatedProperties": false
    },
    "TokenUsage": {
      "$anchor": "TokenUsage",
      "type": "object",
      "description": "Token counts for one provider and model, in the protocol's own accounting: every count is either a total or a named part of one, so entries from different providers add up without double-counting. inputTokens and outputTokens are the totals; reasoningTokens, cachedInputTokens and cacheWriteInputTokens are parts of them, never additions to them; totalTokens is the two totals summed. Every field is a label or a number — nothing content-bearing or identifying, no prompts, completions, messages, or thread, run and user identifiers.",
      "properties": {
        "provider": {
          "type": "string",
          "description": "Which provider served the request."
        },
        "model": {
          "type": "string",
          "description": "Which model served the request."
        },
        "inputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Every prompt token the call was charged for: tokens read from a provider cache, tokens written to one, and audio or other non-text input all count here. cachedInputTokens and cacheWriteInputTokens break this number down and are never added to it — a provider that reports its cache counts beside a smaller input count has them added in by the producer before the entry leaves. Bounded like timestamp and for the same reason: a count above the JSON safe-integer range does not survive a round trip, so a consumer would silently read a different number than the producer wrote."
        },
        "outputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Every generated token, reasoning included where the provider distinguishes it. reasoningTokens breaks this number down and is never added to it — a provider that reports reasoning tokens beside a smaller completion count has them added in by the producer."
        },
        "totalTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "inputTokens plus outputTokens, under the accounting above. A producer MAY compute it rather than copy a provider's total, and copies a provider's total only when that total counts the same way, so a consumer can read this field as the sum of the other two."
        },
        "reasoningTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Output tokens spent on reasoning, where the provider distinguishes them. Part of outputTokens, not in addition to it."
        },
        "cachedInputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Input tokens read from a provider cache. Part of inputTokens, not in addition to it, and disjoint from cacheWriteInputTokens."
        },
        "cacheWriteInputTokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Input tokens written to a provider cache on this call, where the provider distinguishes them. Part of inputTokens, not in addition to it, and disjoint from cachedInputTokens. Its own field because providers price a cache write differently from a cache read, so a consumer computing cost cannot do without it."
        }
      },
      "unevaluatedProperties": false
    },
    "Message": {
      "$anchor": "Message",
      "description": "Any message in a conversation. Discriminated by role.",
      "oneOf": [
        { "$ref": "#/$defs/DeveloperMessage" },
        { "$ref": "#/$defs/SystemMessage" },
        { "$ref": "#/$defs/AssistantMessage" },
        { "$ref": "#/$defs/UserMessage" },
        { "$ref": "#/$defs/ToolMessage" },
        { "$ref": "#/$defs/ActivityMessage" },
        { "$ref": "#/$defs/ReasoningMessage" }
      ]
    },
    "BaseMessage": {
      "$anchor": "BaseMessage",
      "type": "object",
      "description": "The fields shared by the developer, system, assistant and user messages. Deliberately excludes content, because a user message's content may be an array while the others are strings, and composition here intersects rather than overrides: a base that constrained content to a string would make an array content invalid. The tool, activity and reasoning messages do not compose this, because they carry no name.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": {
          "type": "string",
          "description": "Identifies the message within the conversation."
        },
        "role": {
          "type": "string",
          "description": "Who the message is from. Each message definition narrows this to a single value."
        },
        "name": {
          "type": "string",
          "description": "An optional display name for the author."
        },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque artefact belonging to this message, stored by a consumer and returned on a later turn."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role"]
    },
    "DeveloperMessage": {
      "$anchor": "DeveloperMessage",
      "type": "object",
      "description": "Instructions from the application developer.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "developer" },
        "content": {
          "type": "string",
          "description": "The instructions. Required: a developer message with nothing in it says nothing."
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "SystemMessage": {
      "$anchor": "SystemMessage",
      "type": "object",
      "description": "Instructions from the system.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "system" },
        "content": {
          "type": "string",
          "description": "The instructions. Required."
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "AssistantMessage": {
      "$anchor": "AssistantMessage",
      "type": "object",
      "description": "A message from the agent. Content is optional because a turn may consist only of tool calls.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "assistant" },
        "content": {
          "type": "string",
          "description": "What the agent said, if it said anything."
        },
        "toolCalls": {
          "type": "array",
          "description": "The tool calls this turn made.",
          "items": { "$ref": "#/$defs/ToolCall" }
        }
      },
      "required": ["id", "role"],
      "unevaluatedProperties": false
    },
    "UserMessage": {
      "$anchor": "UserMessage",
      "type": "object",
      "description": "A message from the person using the application.",
      "allOf": [{ "$ref": "#/$defs/BaseMessage" }],
      "properties": {
        "role": { "const": "user" },
        "content": {
          "description": "What the person sent: either plain text, or an ordered list of parts for a multimodal message.",
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "$ref": "#/$defs/ContentPart" } }
          ]
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "ToolMessage": {
      "$anchor": "ToolMessage",
      "type": "object",
      "description": "What a tool returned, as a message in the conversation. Stands alone rather than composing BaseMessage, because it carries no name.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": { "type": "string", "description": "Identifies the message." },
        "role": {
          "const": "tool",
          "description": "Fixed. Declared here rather than inherited, because this message does not compose BaseMessage."
        },
        "content": {
          "description": "What the tool returned: either plain text, or an ordered list of parts. A tool returning structured data serialises it into text; media travel as parts of their own.",
          "oneOf": [
            { "type": "string" },
            { "type": "array", "items": { "$ref": "#/$defs/ContentPart" } }
          ]
        },
        "toolCallId": {
          "type": "string",
          "description": "The call this answers."
        },
        "error": {
          "type": "string",
          "description": "Why the tool failed, when it did. Present alongside content rather than instead of it, so a partial result survives a failure."
        },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque artefact belonging to this message."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role", "content", "toolCallId"],
      "unevaluatedProperties": false
    },
    "ActivityMessage": {
      "$anchor": "ActivityMessage",
      "type": "object",
      "description": "Structured progress that is not conversation content, materialised as a message so it keeps its place in the sequence. Stands alone rather than composing BaseMessage, because its content is an object rather than a string.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": { "type": "string", "description": "Identifies the message." },
        "role": {
          "const": "activity",
          "description": "Fixed. Declared here rather than inherited, because this message does not compose BaseMessage."
        },
        "activityType": {
          "type": "string",
          "description": "What kind of activity this is. An open string: the set is the producer's."
        },
        "content": {
          "type": "object",
          "description": "The activity's payload, open by key.",
          "additionalProperties": true
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role", "activityType", "content"],
      "unevaluatedProperties": false
    },
    "ReasoningMessage": {
      "$anchor": "ReasoningMessage",
      "type": "object",
      "description": "A span of the agent's reasoning, materialised as a message. Stands alone rather than composing BaseMessage, because it carries no name.",
      "allOf": [{ "$ref": "#/$defs/Attributable" }],
      "properties": {
        "id": { "type": "string", "description": "Identifies the message." },
        "role": {
          "const": "reasoning",
          "description": "Fixed. Declared here rather than inherited, because this message does not compose BaseMessage."
        },
        "content": { "type": "string", "description": "The reasoning text." },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque reasoning artefact belonging to this message."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this message."
        }
      },
      "required": ["id", "role", "content"],
      "unevaluatedProperties": false
    },
    "ToolCall": {
      "$anchor": "ToolCall",
      "type": "object",
      "description": "A call an assistant message made. Carries no subagent attribution of its own and inherits its containing message's, since several calls can share one parent.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Identifies the call. The answering tool message carries this as its toolCallId."
        },
        "type": {
          "const": "function",
          "description": "The only kind of call the protocol models."
        },
        "function": {
          "$ref": "#/$defs/FunctionCall",
          "description": "What is being called, and with what."
        },
        "encryptedValue": {
          "type": "string",
          "description": "A provider's opaque artefact belonging to this call."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information attached to this call. Carried here rather than folded into the containing message, because several calls can share one parent and merging them would make the result depend on their order."
        }
      },
      "required": ["id", "type", "function"],
      "unevaluatedProperties": false
    },
    "FunctionCall": {
      "$anchor": "FunctionCall",
      "type": "object",
      "description": "The name and arguments of a tool call.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Which tool is being called."
        },
        "arguments": {
          "type": "string",
          "description": "The arguments as a JSON string, not as parsed JSON. Kept as written because a model can emit arguments that are not valid JSON, and losing them at the protocol boundary would hide the fault from the consumer that has to handle it."
        }
      },
      "required": ["name", "arguments"],
      "unevaluatedProperties": false
    },
    "ContentPart": {
      "$anchor": "ContentPart",
      "description": "One part of a message body: what a person sends in a user message, or what a tool returns in a tool message. Discriminated by type. Named by what the part is rather than by direction, because the same part travels into the model inside a user message and back out of the stream inside a tool result.",
      "oneOf": [
        { "$ref": "#/$defs/TextPart" },
        { "$ref": "#/$defs/ImagePart" },
        { "$ref": "#/$defs/AudioPart" },
        { "$ref": "#/$defs/VideoPart" },
        { "$ref": "#/$defs/DocumentPart" }
      ]
    },
    "TextPart": {
      "$anchor": "TextPart",
      "type": "object",
      "description": "A text part.",
      "properties": {
        "type": { "const": "text", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved so that a streamed part can be matched to its entry in history once assistant messages carry parts too."
        },
        "text": { "type": "string", "description": "The text." },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the media parts. This is where a text search hit carries its source and title, rather than the protocol modelling a search-result part of its own."
        }
      },
      "required": ["type", "text"],
      "unevaluatedProperties": false
    },
    "ImagePart": {
      "$anchor": "ImagePart",
      "type": "object",
      "description": "An image part.",
      "properties": {
        "type": { "const": "image", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the image comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained rather than an object: inherited from the SDKs, which declare it unknown rather than a record; listed under known divergences in the README rather than resolved here."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "AudioPart": {
      "$anchor": "AudioPart",
      "type": "object",
      "description": "An audio part.",
      "properties": {
        "type": { "const": "audio", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the audio comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the other media parts."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "VideoPart": {
      "$anchor": "VideoPart",
      "type": "object",
      "description": "A video part.",
      "properties": {
        "type": { "const": "video", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the video comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the other media parts."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "DocumentPart": {
      "$anchor": "DocumentPart",
      "type": "object",
      "description": "A document part.",
      "properties": {
        "type": { "const": "document", "description": "Discriminator." },
        "id": {
          "type": "string",
          "description": "Identifies this part within its message. Optional, and nothing reads it yet: reserved as on the text part."
        },
        "source": {
          "$ref": "#/$defs/PartSource",
          "description": "Where the document comes from."
        },
        "metadata": {
          "not": { "type": "null" },
          "description": "Extra information about this part. Unconstrained, as on the other media parts."
        }
      },
      "required": ["type", "source"],
      "unevaluatedProperties": false
    },
    "PartSource": {
      "$anchor": "PartSource",
      "description": "Where a media part's bytes come from: carried inline, referenced by URL, or already at the provider under a handle it issued.",
      "oneOf": [
        { "$ref": "#/$defs/DataSource" },
        { "$ref": "#/$defs/UrlSource" },
        { "$ref": "#/$defs/FileSource" }
      ]
    },
    "DataSource": {
      "$anchor": "DataSource",
      "type": "object",
      "description": "Bytes carried inline.",
      "properties": {
        "type": { "const": "data", "description": "Discriminator." },
        "value": {
          "type": "string",
          "contentEncoding": "base64",
          "description": "The bytes, base64-encoded. contentEncoding is an annotation rather than a constraint in 2020-12, so a malformed string still validates here; rejecting one is the decoder's job."
        },
        "mimeType": {
          "type": "string",
          "description": "What the bytes are. Required here, unlike on a URL source, because nothing else can tell a consumer how to read them."
        }
      },
      "required": ["type", "value", "mimeType"],
      "unevaluatedProperties": false
    },
    "UrlSource": {
      "$anchor": "UrlSource",
      "type": "object",
      "description": "Bytes referenced by URL, fetched by whoever needs them.",
      "properties": {
        "type": { "const": "url", "description": "Discriminator." },
        "value": {
          "type": "string",
          "description": "The URL. Deliberately not constrained to a URI format, so a scheme a producer already uses is not rejected here."
        },
        "mimeType": {
          "type": "string",
          "description": "What the resource is, when the producer knows. Optional, because the response can say."
        }
      },
      "required": ["type", "value"],
      "unevaluatedProperties": false
    },
    "FileSource": {
      "$anchor": "FileSource",
      "type": "object",
      "description": "Bytes already at the provider, named by a handle the provider issued: an OpenAI or Anthropic file id, a Gemini file URI, a storage URL only that provider can read. No bytes travel and nothing is fetched. Only the provider that minted the handle can resolve it; a peer that cannot drops the part as it drops any part it cannot use.",
      "properties": {
        "type": { "const": "file", "description": "Discriminator." },
        "value": {
          "type": "string",
          "description": "The handle, exactly as the provider issued it. Opaque: a consumer MUST NOT fetch it, parse it or read a scheme out of it."
        },
        "provider": {
          "type": "string",
          "description": "Who issued the handle, when the producer knows. Optional: an agent already knows which provider it talks to. When present, SHOULD be the lowercase vendor id (openai, anthropic, google) that TokenUsage.provider uses, so a peer can tell before sending whether a handle is one it can use."
        },
        "mimeType": {
          "type": "string",
          "description": "What the file is, when the producer knows. Optional, because the provider that holds the bytes knows."
        }
      },
      "required": ["type", "value"],
      "unevaluatedProperties": false
    },
    "Context": {
      "$anchor": "Context",
      "type": "object",
      "description": "A named piece of ambient information given to the agent for the run, distinct from the conversation.",
      "properties": {
        "description": {
          "type": "string",
          "description": "What this context is, for the agent to interpret."
        },
        "value": { "type": "string", "description": "The context itself." }
      },
      "required": ["description", "value"],
      "unevaluatedProperties": false
    },
    "Tool": {
      "$anchor": "Tool",
      "type": "object",
      "description": "A tool the agent may call.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The tool's name, as the agent will call it."
        },
        "description": {
          "type": "string",
          "description": "What the tool does, for the agent to decide when to use it."
        },
        "parameters": {
          "not": { "type": "null" },
          "description": "A JSON Schema describing the tool's arguments. Carried opaquely: the protocol does not constrain or validate it. Optional, because all three SDKs already treat it that way and a tool that takes no arguments has nothing to declare; an absent schema and an empty one mean the same thing to an agent."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Extra information about the tool, for consumers that attach their own rendering or routing information to it."
        }
      },
      "required": ["name", "description"],
      "unevaluatedProperties": false
    },
    "RunAgentInput": {
      "$anchor": "RunAgentInput",
      "type": "object",
      "description": "A request to run an agent. Also echoed back as RUN_STARTED.input. Only threadId, runId and messages are required: those are the three the SDKs already agree on, and for tools and context an absent key and an empty array mean the same thing, so requiring them would catch nothing a producer could get wrong.",
      "properties": {
        "threadId": {
          "type": "string",
          "description": "The conversation this run belongs to."
        },
        "runId": { "type": "string", "description": "Identifies this run." },
        "protocolVersion": {
          "type": "string",
          "description": "The protocol version this consumer speaks, such as \"1.0\". Absent means the input was produced before the protocol carried a version — the versioning rules in the prose govern what each side does with that. Sent in-band rather than by the transport, so a recorded exchange stays self-describing."
        },
        "parentRunId": {
          "type": "string",
          "description": "The run that spawned this one."
        },
        "state": {
          "not": { "type": "null" },
          "$ref": "#/$defs/State",
          "description": "The state the run starts from."
        },
        "messages": {
          "type": "array",
          "description": "The conversation so far, in order.",
          "items": { "$ref": "#/$defs/Message" }
        },
        "tools": {
          "type": "array",
          "description": "The tools the agent may call. Absent means none.",
          "items": { "$ref": "#/$defs/Tool" }
        },
        "context": {
          "type": "array",
          "description": "Ambient information for the run. Absent means none.",
          "items": { "$ref": "#/$defs/Context" }
        },
        "forwardedProps": {
          "not": { "type": "null" },
          "description": "Application-specific values passed through to the agent untouched. Any JSON value."
        },
        "resume": {
          "type": "array",
          "description": "Answers to the interrupts that ended a previous run, when this run continues from one.",
          "items": { "$ref": "#/$defs/ResumeEntry" }
        }
      },
      "required": ["threadId", "runId", "messages"],
      "unevaluatedProperties": false
    },
    "SubagentInfo": {
      "$anchor": "SubagentInfo",
      "type": "object",
      "description": "Describes a subagent that can be invoked by a parent agent.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Unique name or identifier of the subagent."
        },
        "description": {
          "type": "string",
          "description": "What this subagent specializes in. Helps clients build agent selection UIs."
        }
      },
      "required": ["name"],
      "unevaluatedProperties": false
    },
    "IdentityCapabilities": {
      "$anchor": "IdentityCapabilities",
      "type": "object",
      "description": "Basic metadata about the agent. Useful for discovery UIs, agent marketplaces, and debugging. Set these when you want clients to display agent information or when multiple agents are available and users need to pick one.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Human-readable name shown in UIs and agent selectors."
        },
        "type": {
          "type": "string",
          "description": "The framework or platform powering this agent (e.g., \"langgraph\", \"mastra\", \"crewai\")."
        },
        "description": {
          "type": "string",
          "description": "What this agent does — helps users and routing logic decide when to use it."
        },
        "version": {
          "type": "string",
          "description": "Semantic version of the agent (e.g., \"1.2.0\"). Useful for compatibility checks."
        },
        "provider": {
          "type": "string",
          "description": "Organization or team that maintains this agent."
        },
        "documentationUrl": {
          "type": "string",
          "description": "URL to the agent's documentation or homepage."
        },
        "metadata": {
          "$ref": "#/$defs/Metadata",
          "description": "Arbitrary key-value pairs for integration-specific identity info."
        }
      },
      "unevaluatedProperties": false
    },
    "TransportCapabilities": {
      "$anchor": "TransportCapabilities",
      "type": "object",
      "description": "Declares which transport mechanisms the agent supports. Clients use this to pick the best connection strategy. Only set flags to true for transports your agent actually handles — omit or set false for unsupported ones.",
      "properties": {
        "streaming": {
          "type": "boolean",
          "description": "Set true if the agent streams responses via SSE. Most agents enable this."
        },
        "websocket": {
          "type": "boolean",
          "description": "Set true if the agent accepts persistent WebSocket connections."
        },
        "httpBinary": {
          "type": "boolean",
          "description": "Set true if the agent supports the AG-UI binary protocol (protobuf over HTTP)."
        },
        "pushNotifications": {
          "type": "boolean",
          "description": "Set true if the agent can send async updates via webhooks after a run finishes."
        },
        "resumable": {
          "type": "boolean",
          "description": "Set true if the agent supports resuming interrupted streams via sequence numbers."
        }
      },
      "unevaluatedProperties": false
    },
    "ToolsCapabilities": {
      "$anchor": "ToolsCapabilities",
      "type": "object",
      "description": "Tool calling capabilities. Distinguishes between tools the agent itself provides (listed in items) and tools the client passes at runtime via RunAgentInput.tools. Enable this when your agent can call functions, search the web, execute code, etc.",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent can make tool calls at all. Set false to explicitly signal tool calling is disabled even if items are present."
        },
        "items": {
          "type": "array",
          "description": "The tools this agent provides on its own (full JSON Schema definitions). These are distinct from client-provided tools passed in RunAgentInput.tools.",
          "items": { "$ref": "#/$defs/Tool" }
        },
        "parallelCalls": {
          "type": "boolean",
          "description": "Set true if the agent can invoke multiple tools concurrently within a single step."
        },
        "clientProvided": {
          "type": "boolean",
          "description": "Set true if the agent accepts and uses tools provided by the client at runtime."
        }
      },
      "unevaluatedProperties": false
    },
    "OutputCapabilities": {
      "$anchor": "OutputCapabilities",
      "type": "object",
      "description": "Output format support. Enable structuredOutput when your agent can return responses conforming to a JSON schema, which is useful for programmatic consumption.",
      "properties": {
        "structuredOutput": {
          "type": "boolean",
          "description": "Set true if the agent can produce structured JSON output matching a provided schema."
        },
        "supportedMimeTypes": {
          "type": "array",
          "description": "MIME types the agent can produce (e.g., [\"text/plain\", \"application/json\"]). Omit if the agent only produces plain text.",
          "items": { "type": "string" }
        }
      },
      "unevaluatedProperties": false
    },
    "StateCapabilities": {
      "$anchor": "StateCapabilities",
      "type": "object",
      "description": "State and memory management capabilities. These tell the client how the agent handles shared state and whether conversation context persists across runs.",
      "properties": {
        "snapshots": {
          "type": "boolean",
          "description": "Set true if the agent emits STATE_SNAPSHOT events (full state replacement)."
        },
        "deltas": {
          "type": "boolean",
          "description": "Set true if the agent emits STATE_DELTA events (JSON Patch incremental updates)."
        },
        "memory": {
          "type": "boolean",
          "description": "Set true if the agent has long-term memory beyond the current thread (e.g., vector store, knowledge base, or cross-session recall)."
        },
        "persistentState": {
          "type": "boolean",
          "description": "Set true if state is preserved across multiple runs within the same thread. When false, state resets on each run."
        }
      },
      "unevaluatedProperties": false
    },
    "MultiAgentCapabilities": {
      "$anchor": "MultiAgentCapabilities",
      "type": "object",
      "description": "Multi-agent coordination capabilities. Enable these when your agent can orchestrate or hand off work to other agents.",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent participates in any form of multi-agent coordination."
        },
        "delegation": {
          "type": "boolean",
          "description": "Set true if the agent can delegate subtasks to other agents while retaining control."
        },
        "handoffs": {
          "type": "boolean",
          "description": "Set true if the agent can transfer the conversation entirely to another agent."
        },
        "subagents": {
          "type": "array",
          "description": "List of subagents this agent can invoke. Helps clients build agent selection UIs.",
          "items": { "$ref": "#/$defs/SubagentInfo" }
        }
      },
      "unevaluatedProperties": false
    },
    "ReasoningCapabilities": {
      "$anchor": "ReasoningCapabilities",
      "type": "object",
      "description": "Reasoning and thinking capabilities. Enable these when your agent exposes its internal thought process (e.g., chain-of-thought, extended thinking).",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent produces reasoning/thinking tokens visible to the client."
        },
        "streaming": {
          "type": "boolean",
          "description": "Set true if reasoning tokens are streamed incrementally (vs. returned all at once)."
        },
        "encrypted": {
          "type": "boolean",
          "description": "Set true if reasoning content is encrypted (zero-data-retention mode). Clients should expect opaque encryptedValue fields instead of readable content."
        }
      },
      "unevaluatedProperties": false
    },
    "MultimodalInputCapabilities": {
      "$anchor": "MultimodalInputCapabilities",
      "type": "object",
      "description": "Modalities the agent can accept as input. Clients use this to show or hide file upload buttons, audio recorders, image pickers, etc.",
      "properties": {
        "image": {
          "type": "boolean",
          "description": "Set true if the agent can process image inputs (e.g., screenshots, photos)."
        },
        "audio": {
          "type": "boolean",
          "description": "Set true if the agent can process audio inputs (speech, recordings)."
        },
        "video": {
          "type": "boolean",
          "description": "Set true if the agent can process video inputs."
        },
        "pdf": {
          "type": "boolean",
          "description": "Set true if the agent can process PDF documents."
        },
        "file": {
          "type": "boolean",
          "description": "Set true if the agent can process arbitrary file uploads: files of a kind the image, audio, video and document parts do not cover. Says nothing about how a file arrives; a part's source (inline, URL or provider handle) is a separate question."
        }
      },
      "unevaluatedProperties": false
    },
    "MultimodalOutputCapabilities": {
      "$anchor": "MultimodalOutputCapabilities",
      "type": "object",
      "description": "Modalities the agent can produce as output. Clients use this to anticipate rich content in the agent's response.",
      "properties": {
        "image": {
          "type": "boolean",
          "description": "Set true if the agent can generate images as part of its response."
        },
        "audio": {
          "type": "boolean",
          "description": "Set true if the agent can produce audio output (text-to-speech, audio files)."
        }
      },
      "unevaluatedProperties": false
    },
    "MultimodalCapabilities": {
      "$anchor": "MultimodalCapabilities",
      "type": "object",
      "description": "Multimodal input and output support. Organized into input and output sub-objects so clients can independently query what the agent accepts versus what it produces.",
      "properties": {
        "input": {
          "$ref": "#/$defs/MultimodalInputCapabilities",
          "description": "Modalities the agent can accept as input (images, audio, video, PDFs, files)."
        },
        "output": {
          "$ref": "#/$defs/MultimodalOutputCapabilities",
          "description": "Modalities the agent can produce as output (images, audio)."
        }
      },
      "unevaluatedProperties": false
    },
    "ExecutionCapabilities": {
      "$anchor": "ExecutionCapabilities",
      "type": "object",
      "description": "Execution control and limits. Declare these so clients can set expectations about how long or how many steps an agent run might take.",
      "properties": {
        "codeExecution": {
          "type": "boolean",
          "description": "Set true if the agent can execute code (e.g., Python, JavaScript) during a run."
        },
        "sandboxed": {
          "type": "boolean",
          "description": "Set true if code execution happens in a sandboxed or isolated environment. Only meaningful when codeExecution is true."
        },
        "maxIterations": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Maximum number of tool-call/reasoning iterations the agent will perform per run. Helps clients display progress or set timeout expectations."
        },
        "maxExecutionTime": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Maximum wall-clock time (in milliseconds) the agent will run before timing out."
        }
      },
      "unevaluatedProperties": false
    },
    "HumanInTheLoopCapabilities": {
      "$anchor": "HumanInTheLoopCapabilities",
      "type": "object",
      "description": "Human-in-the-loop interaction support. Enable these when your agent can pause execution to request human input, approval, or feedback before continuing.",
      "properties": {
        "supported": {
          "type": "boolean",
          "description": "Set true if the agent supports any form of human-in-the-loop interaction."
        },
        "approvals": {
          "type": "boolean",
          "description": "Set true if the agent can pause and request explicit approval before performing sensitive actions (e.g., sending emails, deleting data)."
        },
        "interventions": {
          "type": "boolean",
          "description": "Set true if the agent allows humans to intervene and modify its plan mid-execution."
        },
        "feedback": {
          "type": "boolean",
          "description": "Set true if the agent can incorporate user feedback (thumbs up/down, corrections) to improve its behavior within the current session."
        },
        "interrupts": {
          "type": "boolean",
          "description": "Set true if the agent participates in the AG-UI interrupt protocol: it ends a run with RUN_FINISHED carrying an interrupt outcome, and accepts the answers back in RunAgentInput.resume."
        },
        "approveWithEdits": {
          "type": "boolean",
          "description": "Set true if tool-call interrupts accept editedArgs in the resume payload. Only meaningful when interrupts is true."
        }
      },
      "unevaluatedProperties": false
    },
    "AgentCapabilities": {
      "$anchor": "AgentCapabilities",
      "type": "object",
      "description": "A typed, categorized snapshot of an agent's current capabilities. All fields are optional — agents only declare what they support. An omitted field means the capability is not declared (unknown), not that it is unsupported. The custom field is an escape hatch for integration-specific capabilities that do not fit into the standard categories.",
      "properties": {
        "identity": {
          "$ref": "#/$defs/IdentityCapabilities",
          "description": "Agent identity and metadata."
        },
        "transport": {
          "$ref": "#/$defs/TransportCapabilities",
          "description": "Supported transport mechanisms (SSE, WebSocket, binary, etc.)."
        },
        "tools": {
          "$ref": "#/$defs/ToolsCapabilities",
          "description": "Tools the agent provides and tool calling configuration."
        },
        "output": {
          "$ref": "#/$defs/OutputCapabilities",
          "description": "Output format support (structured output, MIME types)."
        },
        "state": {
          "$ref": "#/$defs/StateCapabilities",
          "description": "State and memory management (snapshots, deltas, persistence)."
        },
        "multiAgent": {
          "$ref": "#/$defs/MultiAgentCapabilities",
          "description": "Multi-agent coordination (delegation, handoffs, subagents)."
        },
        "reasoning": {
          "$ref": "#/$defs/ReasoningCapabilities",
          "description": "Reasoning and thinking support (chain-of-thought, encrypted thinking)."
        },
        "multimodal": {
          "$ref": "#/$defs/MultimodalCapabilities",
          "description": "Multimodal input/output support (images, audio, video, files)."
        },
        "execution": {
          "$ref": "#/$defs/ExecutionCapabilities",
          "description": "Execution control and limits (code execution, timeouts, iteration caps)."
        },
        "humanInTheLoop": {
          "$ref": "#/$defs/HumanInTheLoopCapabilities",
          "description": "Human-in-the-loop support (approvals, interventions, feedback)."
        },
        "custom": {
          "type": "object",
          "description": "Integration-specific capabilities not covered by the standard categories. Open by key: any JSON value is allowed under a key, because the categories above cannot anticipate what an integration declares.",
          "additionalProperties": true
        }
      },
      "unevaluatedProperties": false
    },
    "JsonPatch": {
      "$anchor": "JsonPatch",
      "type": "array",
      "description": "A JSON Patch document as defined by RFC 6902, referenced by STATE_DELTA.delta and ACTIVITY_DELTA.patch: an ordered sequence of operations applied to a target document. An empty array is a valid no-op patch. Whether the operations actually apply to the document they target is a runtime question RFC 6902 leaves to the applier; structural validity here says nothing about it.",
      "items": { "$ref": "#/$defs/JsonPatchOperation" }
    },
    "JsonPatchOperation": {
      "$anchor": "JsonPatchOperation",
      "description": "A single RFC 6902 operation. Exactly one of the operation shapes must match, discriminated by op. Unlike the protocol's own objects, the operations are open: RFC 6902 section 4 requires members an operation does not define to be ignored rather than rejected, so a remove carrying a leftover value is a valid patch. Two of the RFC's rules are relations between values rather than shapes, so no static schema can express them and neither is checked here: a move whose from is a proper prefix of its path (section 4.4), and any operation whose pointer does not resolve in the target document. Both are the applier's to reject.",
      "oneOf": [
        { "$ref": "#/$defs/AddOperation" },
        { "$ref": "#/$defs/RemoveOperation" },
        { "$ref": "#/$defs/ReplaceOperation" },
        { "$ref": "#/$defs/MoveOperation" },
        { "$ref": "#/$defs/CopyOperation" },
        { "$ref": "#/$defs/TestOperation" }
      ]
    },
    "AddOperation": {
      "$anchor": "AddOperation",
      "type": "object",
      "description": "Inserts value at path. RFC 6902 section 4.1.",
      "properties": {
        "op": {
          "const": "add",
          "description": "Discriminator for the add operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where to insert the value."
        },
        "value": {
          "description": "The value to insert. Any JSON value, including null, which is a legitimate thing to add."
        }
      },
      "required": ["op", "path", "value"]
    },
    "RemoveOperation": {
      "$anchor": "RemoveOperation",
      "type": "object",
      "description": "Removes the value at path. RFC 6902 section 4.2.",
      "properties": {
        "op": {
          "const": "remove",
          "description": "Discriminator for the remove operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "What to remove."
        }
      },
      "required": ["op", "path"]
    },
    "ReplaceOperation": {
      "$anchor": "ReplaceOperation",
      "type": "object",
      "description": "Replaces the value at path. RFC 6902 section 4.3.",
      "properties": {
        "op": {
          "const": "replace",
          "description": "Discriminator for the replace operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "What to replace."
        },
        "value": {
          "description": "The replacement. Any JSON value, including null."
        }
      },
      "required": ["op", "path", "value"]
    },
    "MoveOperation": {
      "$anchor": "MoveOperation",
      "type": "object",
      "description": "Moves the value at from to path. RFC 6902 section 4.4.",
      "properties": {
        "op": {
          "const": "move",
          "description": "Discriminator for the move operation."
        },
        "from": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is moved from."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is moved to."
        }
      },
      "required": ["op", "from", "path"]
    },
    "CopyOperation": {
      "$anchor": "CopyOperation",
      "type": "object",
      "description": "Copies the value at from to path. RFC 6902 section 4.5.",
      "properties": {
        "op": {
          "const": "copy",
          "description": "Discriminator for the copy operation."
        },
        "from": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is copied from."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "Where the value is copied to."
        }
      },
      "required": ["op", "from", "path"]
    },
    "TestOperation": {
      "$anchor": "TestOperation",
      "type": "object",
      "description": "Asserts that the value at path equals value. RFC 6902 section 4.6.",
      "properties": {
        "op": {
          "const": "test",
          "description": "Discriminator for the test operation."
        },
        "path": {
          "$ref": "#/$defs/JsonPointer",
          "description": "What to compare."
        },
        "value": {
          "description": "The value the target must equal. Any JSON value, including null."
        }
      },
      "required": ["op", "path", "value"]
    },
    "JsonPointer": {
      "$anchor": "JsonPointer",
      "type": "string",
      "description": "A JSON Pointer as defined by RFC 6901. Either the empty string, meaning the whole document, or a sequence of slash-prefixed reference tokens in which a tilde is escaped as ~0 and a slash as ~1. A value with no leading slash, or a tilde followed by anything other than 0 or 1, is not a JSON Pointer.",
      "pattern": "^(/([^/~]|~[01])*)*$"
    }
  }
}
