{ "openapi": "3.1.0", "info": { "title": "AG-UI Events", "description": "OpenAPI contracts for all AG-UI protocol events. See https://docs.ag-ui.com/concepts/events", "version": "1.0.0" }, "paths": { "/agent/run": { "post": { "summary": "Run an agent and stream events", "description": "Streams AG-UI events as a Server-Sent Events response. Each SSE data payload is one BaseEvent.", "responses": { "200": { "description": "Event stream", "content": { "text/event-stream": { "schema": { "$ref": "#/components/schemas/Event" } } } } } } } }, "components": { "schemas": { "EventType": { "type": "string", "enum": [ "RunStarted", "RunFinished", "RunError", "StepStarted", "StepFinished", "TextMessageStart", "TextMessageContent", "TextMessageEnd", "TextMessageChunk", "ToolCallStart", "ToolCallArgs", "ToolCallEnd", "ToolCallResult", "ToolCallChunk", "StateSnapshot", "StateDelta", "MessagesSnapshot", "ActivitySnapshot", "ActivityDelta", "ReasoningStart", "ReasoningMessageStart", "ReasoningMessageContent", "ReasoningMessageEnd", "ReasoningMessageChunk", "ReasoningEnd", "ReasoningEncryptedValue", "Raw", "Custom", "MetaEvent" ] }, "Role": { "type": "string", "enum": ["developer", "system", "assistant", "user", "tool"] }, "JSONPatchOperation": { "type": "object", "description": "A single JSON Patch operation (RFC 6902).", "properties": { "op": { "type": "string", "enum": ["add", "remove", "replace", "move", "copy", "test"] }, "path": { "type": "string" }, "from": { "type": "string" }, "value": {} }, "required": ["op", "path"] }, "BaseEvent": { "type": "object", "description": "Properties common to all events.", "properties": { "type": { "$ref": "#/components/schemas/EventType" }, "timestamp": { "type": "string", "description": "Event creation time." }, "rawEvent": { "type": "object", "description": "Original event data if transformed.", "additionalProperties": true } }, "required": ["type"] }, "RunStarted": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "RunStarted" }, "threadId": { "type": "string", "description": "Conversation thread identifier." }, "runId": { "type": "string", "description": "Agent run identifier." }, "parentRunId": { "type": "string", "description": "Prior run reference for branching." }, "input": { "type": "object", "description": "Agent input payload.", "additionalProperties": true } }, "required": ["type", "threadId", "runId"] } ] }, "RunFinished": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "RunFinished" }, "outcome": { "description": "Run outcome discriminated union.", "oneOf": [ { "type": "object", "properties": { "type": { "const": "success" } }, "required": ["type"] }, { "type": "object", "properties": { "type": { "const": "interrupt" }, "interrupts": { "type": "array", "items": {} } }, "required": ["type", "interrupts"] } ] }, "result": { "type": "object", "description": "Free-form completion payload.", "additionalProperties": true } }, "required": ["type"] } ] }, "RunError": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "RunError" }, "message": { "type": "string", "description": "Error description." }, "code": { "type": "string", "description": "Error code." } }, "required": ["type", "message"] } ] }, "StepStarted": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "StepStarted" }, "stepName": { "type": "string", "description": "Step identifier." } }, "required": ["type", "stepName"] } ] }, "StepFinished": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "StepFinished" }, "stepName": { "type": "string", "description": "Step identifier (must match StepStarted)." } }, "required": ["type", "stepName"] } ] }, "TextMessageStart": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "TextMessageStart" }, "messageId": { "type": "string", "description": "Unique message identifier." }, "role": { "$ref": "#/components/schemas/Role" } }, "required": ["type", "messageId", "role"] } ] }, "TextMessageContent": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "TextMessageContent" }, "messageId": { "type": "string", "description": "References TextMessageStart." }, "delta": { "type": "string", "minLength": 1, "description": "Text chunk." } }, "required": ["type", "messageId", "delta"] } ] }, "TextMessageEnd": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "TextMessageEnd" }, "messageId": { "type": "string", "description": "References TextMessageStart." } }, "required": ["type", "messageId"] } ] }, "TextMessageChunk": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "TextMessageChunk" }, "messageId": { "type": "string", "description": "Required on first chunk." }, "role": { "$ref": "#/components/schemas/Role" }, "delta": { "type": "string", "description": "Text content." } }, "required": ["type"] } ] }, "ToolCallStart": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ToolCallStart" }, "toolCallId": { "type": "string", "description": "Unique tool call identifier." }, "toolCallName": { "type": "string", "description": "Tool name." }, "parentMessageId": { "type": "string", "description": "Associated message reference." } }, "required": ["type", "toolCallId", "toolCallName"] } ] }, "ToolCallArgs": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ToolCallArgs" }, "toolCallId": { "type": "string", "description": "References ToolCallStart." }, "delta": { "type": "string", "description": "Argument chunk (often JSON)." } }, "required": ["type", "toolCallId", "delta"] } ] }, "ToolCallEnd": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ToolCallEnd" }, "toolCallId": { "type": "string", "description": "References ToolCallStart." } }, "required": ["type", "toolCallId"] } ] }, "ToolCallResult": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ToolCallResult" }, "messageId": { "type": "string", "description": "Conversation message identifier." }, "toolCallId": { "type": "string", "description": "References ToolCallStart." }, "content": { "type": "string", "description": "Tool output." }, "role": { "$ref": "#/components/schemas/Role" } }, "required": ["type", "messageId", "toolCallId", "content"] } ] }, "ToolCallChunk": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ToolCallChunk" }, "toolCallId": { "type": "string", "description": "Required on first chunk." }, "toolCallName": { "type": "string", "description": "Required on first chunk." }, "parentMessageId": { "type": "string", "description": "Associated message reference." }, "delta": { "type": "string", "description": "Argument chunk." } }, "required": ["type"] } ] }, "StateSnapshot": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "StateSnapshot" }, "snapshot": { "type": "object", "description": "Complete state representation.", "additionalProperties": true } }, "required": ["type", "snapshot"] } ] }, "StateDelta": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "StateDelta" }, "delta": { "type": "array", "description": "JSON Patch operations (RFC 6902).", "items": { "$ref": "#/components/schemas/JSONPatchOperation" } } }, "required": ["type", "delta"] } ] }, "MessagesSnapshot": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "MessagesSnapshot" }, "messages": { "type": "array", "description": "Message objects.", "items": { "type": "object", "additionalProperties": true } } }, "required": ["type", "messages"] } ] }, "ActivitySnapshot": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ActivitySnapshot" }, "messageId": { "type": "string", "description": "Activity message identifier." }, "activityType": { "type": "string", "description": "Activity discriminator (e.g. PLAN, SEARCH)." }, "content": { "type": "object", "description": "Structured activity state.", "additionalProperties": true }, "replace": { "type": "boolean", "default": true } }, "required": ["type", "messageId", "activityType", "content"] } ] }, "ActivityDelta": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ActivityDelta" }, "messageId": { "type": "string", "description": "Target activity identifier." }, "activityType": { "type": "string", "description": "Activity discriminator." }, "patch": { "type": "array", "description": "JSON Patch operations (RFC 6902).", "items": { "$ref": "#/components/schemas/JSONPatchOperation" } } }, "required": ["type", "messageId", "activityType", "patch"] } ] }, "ReasoningStart": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ReasoningStart" }, "messageId": { "type": "string", "description": "Reasoning context identifier." } }, "required": ["type", "messageId"] } ] }, "ReasoningMessageStart": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ReasoningMessageStart" }, "messageId": { "type": "string", "description": "Message identifier." }, "role": { "type": "string", "const": "reasoning" } }, "required": ["type", "messageId", "role"] } ] }, "ReasoningMessageContent": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ReasoningMessageContent" }, "messageId": { "type": "string", "description": "References ReasoningMessageStart." }, "delta": { "type": "string", "minLength": 1, "description": "Reasoning content chunk." } }, "required": ["type", "messageId", "delta"] } ] }, "ReasoningMessageEnd": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ReasoningMessageEnd" }, "messageId": { "type": "string", "description": "References ReasoningMessageStart." } }, "required": ["type", "messageId"] } ] }, "ReasoningMessageChunk": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ReasoningMessageChunk" }, "messageId": { "type": "string", "description": "Message identifier." }, "delta": { "type": "string", "description": "Content chunk; empty string closes message." } }, "required": ["type", "messageId"] } ] }, "ReasoningEnd": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ReasoningEnd" }, "messageId": { "type": "string", "description": "Reasoning context identifier." } }, "required": ["type", "messageId"] } ] }, "ReasoningEncryptedValue": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "ReasoningEncryptedValue" }, "subtype": { "type": "string", "enum": ["message", "tool-call"], "description": "Entity type." }, "entityId": { "type": "string", "description": "Message or tool call identifier." }, "encryptedValue": { "type": "string", "description": "Encrypted reasoning blob." } }, "required": ["type", "subtype", "entityId", "encryptedValue"] } ] }, "Raw": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "Raw" }, "event": { "type": "object", "description": "Original event data.", "additionalProperties": true }, "source": { "type": "string", "description": "System identifier." } }, "required": ["type", "event"] } ] }, "Custom": { "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "Custom" }, "name": { "type": "string", "description": "Custom event type identifier." }, "value": { "description": "Associated data (any type)." } }, "required": ["type", "name", "value"] } ] }, "MetaEvent": { "description": "DRAFT event.", "allOf": [ { "$ref": "#/components/schemas/BaseEvent" }, { "type": "object", "properties": { "type": { "const": "MetaEvent" }, "metaType": { "type": "string", "description": "Application-defined type." }, "payload": { "type": "object", "description": "Application-defined data.", "additionalProperties": true } }, "required": ["type", "metaType", "payload"] } ] }, "Event": { "description": "Discriminated union of all AG-UI events, keyed on `type`.", "oneOf": [ { "$ref": "#/components/schemas/RunStarted" }, { "$ref": "#/components/schemas/RunFinished" }, { "$ref": "#/components/schemas/RunError" }, { "$ref": "#/components/schemas/StepStarted" }, { "$ref": "#/components/schemas/StepFinished" }, { "$ref": "#/components/schemas/TextMessageStart" }, { "$ref": "#/components/schemas/TextMessageContent" }, { "$ref": "#/components/schemas/TextMessageEnd" }, { "$ref": "#/components/schemas/TextMessageChunk" }, { "$ref": "#/components/schemas/ToolCallStart" }, { "$ref": "#/components/schemas/ToolCallArgs" }, { "$ref": "#/components/schemas/ToolCallEnd" }, { "$ref": "#/components/schemas/ToolCallResult" }, { "$ref": "#/components/schemas/ToolCallChunk" }, { "$ref": "#/components/schemas/StateSnapshot" }, { "$ref": "#/components/schemas/StateDelta" }, { "$ref": "#/components/schemas/MessagesSnapshot" }, { "$ref": "#/components/schemas/ActivitySnapshot" }, { "$ref": "#/components/schemas/ActivityDelta" }, { "$ref": "#/components/schemas/ReasoningStart" }, { "$ref": "#/components/schemas/ReasoningMessageStart" }, { "$ref": "#/components/schemas/ReasoningMessageContent" }, { "$ref": "#/components/schemas/ReasoningMessageEnd" }, { "$ref": "#/components/schemas/ReasoningMessageChunk" }, { "$ref": "#/components/schemas/ReasoningEnd" }, { "$ref": "#/components/schemas/ReasoningEncryptedValue" }, { "$ref": "#/components/schemas/Raw" }, { "$ref": "#/components/schemas/Custom" }, { "$ref": "#/components/schemas/MetaEvent" } ], "discriminator": { "propertyName": "type", "mapping": { "RunStarted": "#/components/schemas/RunStarted", "RunFinished": "#/components/schemas/RunFinished", "RunError": "#/components/schemas/RunError", "StepStarted": "#/components/schemas/StepStarted", "StepFinished": "#/components/schemas/StepFinished", "TextMessageStart": "#/components/schemas/TextMessageStart", "TextMessageContent": "#/components/schemas/TextMessageContent", "TextMessageEnd": "#/components/schemas/TextMessageEnd", "TextMessageChunk": "#/components/schemas/TextMessageChunk", "ToolCallStart": "#/components/schemas/ToolCallStart", "ToolCallArgs": "#/components/schemas/ToolCallArgs", "ToolCallEnd": "#/components/schemas/ToolCallEnd", "ToolCallResult": "#/components/schemas/ToolCallResult", "ToolCallChunk": "#/components/schemas/ToolCallChunk", "StateSnapshot": "#/components/schemas/StateSnapshot", "StateDelta": "#/components/schemas/StateDelta", "MessagesSnapshot": "#/components/schemas/MessagesSnapshot", "ActivitySnapshot": "#/components/schemas/ActivitySnapshot", "ActivityDelta": "#/components/schemas/ActivityDelta", "ReasoningStart": "#/components/schemas/ReasoningStart", "ReasoningMessageStart": "#/components/schemas/ReasoningMessageStart", "ReasoningMessageContent": "#/components/schemas/ReasoningMessageContent", "ReasoningMessageEnd": "#/components/schemas/ReasoningMessageEnd", "ReasoningMessageChunk": "#/components/schemas/ReasoningMessageChunk", "ReasoningEnd": "#/components/schemas/ReasoningEnd", "ReasoningEncryptedValue": "#/components/schemas/ReasoningEncryptedValue", "Raw": "#/components/schemas/Raw", "Custom": "#/components/schemas/Custom", "MetaEvent": "#/components/schemas/MetaEvent" } } } } } }