Schemas of the Agent User Interaction (AG-UI) protocol (Effect's AgUiSchema).
AG-UI connects an agent backend to a user-facing application: the application posts a
RunAgentInput and the agent answers with a stream of events describing the run.
These schemas follow the AG-UI 1.0 specification (https://docs.ag-ui.com) and describe
the request body, the conversation messages it carries, and every event type.
Converting to and from pyfect.ai values lives in ag_ui, the HTTP binding in
ag_ui_server.
As in mcp_schema, values are TypedDict s in the wire form, with AG-UI's camelCase
keys (threadId, toolCallId); each has a schema named in capitals
(RUN_AGENT_INPUT for RunAgentInput).
AG-UI consumers remove list elements they do not recognise (a message role, a content part type or a closed-set value added by a newer protocol version) instead of rejecting the value holding them. A recognised but malformed element still fails to decode.
Values#
| Attribute | Type | Description |
|---|---|---|
PROTOCOL_VERSION | Literal['1.0'] = '1.0' | The AG-UI protocol version these schemas implement. |
METADATA | RecordSchema[str, object, str, object, Never, Never] | |
DATA_SOURCE | StructSchema[DataSource, Never, Never] | |
URL_SOURCE | StructSchema[UrlSource, Never, Never] | |
FILE_SOURCE | StructSchema[FileSource, Never, Never] | |
PART_SOURCE | UnionSchema[DataSource | UrlSource | FileSource, Mapping[str, object], Never, Never] | |
TEXT_PART | StructSchema[TextPart, Never, Never] | |
IMAGE_PART | StructSchema[ImagePart, Never, Never] | |
AUDIO_PART | StructSchema[AudioPart, Never, Never] | |
VIDEO_PART | StructSchema[VideoPart, Never, Never] | |
DOCUMENT_PART | StructSchema[DocumentPart, Never, Never] | |
CONTENT_PART | UnionSchema[TextPart | ImagePart | AudioPart | VideoPart | DocumentPart, Mapping[str, object], Never, Never] | |
TOOL_CALL | StructSchema[ToolCall, Never, Never] | |
DEVELOPER_MESSAGE | StructSchema[DeveloperMessage, Never, Never] | |
SYSTEM_MESSAGE | StructSchema[SystemMessage, Never, Never] | |
ASSISTANT_MESSAGE | StructSchema[AssistantMessage, Never, Never] | |
USER_MESSAGE | StructSchema[UserMessage, Never, Never] | |
TOOL_MESSAGE | StructSchema[ToolMessage, Never, Never] | |
ACTIVITY_MESSAGE | StructSchema[ActivityMessage, Never, Never] | |
REASONING_MESSAGE | StructSchema[ReasoningMessage, Never, Never] | |
MESSAGE | UnionSchema[DeveloperMessage | SystemMessage | AssistantMessage | UserMessage | ToolMessage | ActivityMessage | ReasoningMessage, Mapping[str, object], Never, Never] | |
TOOL | StructSchema[Tool, Never, Never] | |
CONTEXT | StructSchema[Context, Never, Never] | |
RESUME_ENTRY | StructSchema[ResumeEntry, Never, Never] | |
RUN_AGENT_INPUT | StructSchema[RunAgentInput, Never, Never] | |
TEXT_MESSAGE_ROLE | LiteralsSchema[Literal['developer', 'system', 'assistant', 'user']] | |
JsonPatchMove | type[JsonPatchMove] | |
JsonPatchCopy | type[JsonPatchCopy] | |
JSON_PATCH_OPERATION | UnionSchema[JsonPatchAdd | JsonPatchRemove | JsonPatchReplace | JsonPatchMove | JsonPatchCopy | JsonPatchTest, Mapping[str, object], Never, Never] | |
INTERRUPT | StructSchema[Interrupt, Never, Never] | |
RUN_FINISHED_OUTCOME | UnionSchema[SuccessOutcome | InterruptOutcome | CancelledOutcome, Mapping[str, object], Never, Never] | |
TOKEN_USAGE | StructSchema[TokenUsage, Never, Never] | |
TEXT_MESSAGE_START_EVENT | StructSchema[TextMessageStartEvent, Never, Never] | |
TEXT_MESSAGE_CONTENT_EVENT | StructSchema[TextMessageContentEvent, Never, Never] | |
TEXT_MESSAGE_END_EVENT | StructSchema[TextMessageEndEvent, Never, Never] | |
TEXT_MESSAGE_CHUNK_EVENT | StructSchema[TextMessageChunkEvent, Never, Never] | |
TOOL_CALL_START_EVENT | StructSchema[ToolCallStartEvent, Never, Never] | |
TOOL_CALL_ARGS_EVENT | StructSchema[ToolCallArgsEvent, Never, Never] | |
TOOL_CALL_END_EVENT | StructSchema[ToolCallEndEvent, Never, Never] | |
TOOL_CALL_CHUNK_EVENT | StructSchema[ToolCallChunkEvent, Never, Never] | |
TOOL_CALL_RESULT_EVENT | StructSchema[ToolCallResultEvent, Never, Never] | |
STATE_SNAPSHOT_EVENT | StructSchema[StateSnapshotEvent, Never, Never] | |
STATE_DELTA_EVENT | StructSchema[StateDeltaEvent, Never, Never] | |
MESSAGES_SNAPSHOT_EVENT | StructSchema[MessagesSnapshotEvent, Never, Never] | |
ACTIVITY_SNAPSHOT_EVENT | StructSchema[ActivitySnapshotEvent, Never, Never] | |
ACTIVITY_DELTA_EVENT | StructSchema[ActivityDeltaEvent, Never, Never] | |
RAW_EVENT | StructSchema[RawEvent, Never, Never] | |
CUSTOM_EVENT | StructSchema[CustomEvent, Never, Never] | |
RUN_STARTED_EVENT | StructSchema[RunStartedEvent, Never, Never] | |
RUN_FINISHED_EVENT | StructSchema[RunFinishedEvent, Never, Never] | |
RUN_ERROR_EVENT | StructSchema[RunErrorEvent, Never, Never] | |
STEP_STARTED_EVENT | StructSchema[StepStartedEvent, Never, Never] | |
STEP_FINISHED_EVENT | StructSchema[StepFinishedEvent, Never, Never] | |
REASONING_START_EVENT | StructSchema[ReasoningStartEvent, Never, Never] | |
REASONING_MESSAGE_START_EVENT | StructSchema[ReasoningMessageStartEvent, Never, Never] | |
REASONING_MESSAGE_CONTENT_EVENT | StructSchema[ReasoningMessageContentEvent, Never, Never] | |
REASONING_MESSAGE_END_EVENT | StructSchema[ReasoningMessageEndEvent, Never, Never] | |
REASONING_MESSAGE_CHUNK_EVENT | StructSchema[ReasoningMessageChunkEvent, Never, Never] | |
REASONING_END_EVENT | StructSchema[ReasoningEndEvent, Never, Never] | |
REASONING_ENCRYPTED_VALUE_EVENT | StructSchema[ReasoningEncryptedValueEvent, Never, Never] | |
SUBAGENT_STARTED_EVENT | StructSchema[SubagentStartedEvent, Never, Never] | |
SUBAGENT_FINISHED_EVENT | StructSchema[SubagentFinishedEvent, Never, Never] | |
SUBAGENT_ERROR_EVENT | StructSchema[SubagentErrorEvent, Never, Never] | |
EVENT | S.Codec[Event, Mapping[str, object], Never, Never] |
Types#
| Type | Definition | Description |
|---|---|---|
Metadata | type Metadata = dict[str, object] | Open-ended metadata attached to events, messages, tools and other protocol values.
The |
PartSource | type PartSource = DataSource | UrlSource | FileSource | The source of a media content part. |
MediaPart | type MediaPart = ImagePart | AudioPart | VideoPart | DocumentPart | |
ContentPart | type ContentPart = TextPart | MediaPart | Any content part of a user or tool message. |
Content | type Content = str | list[ContentPart] | |
Message | type Message = DeveloperMessage | SystemMessage | AssistantMessage | UserMessage | ToolMessage | ActivityMessage | ReasoningMessage | Any message in an AG-UI conversation, discriminated by |
TextMessageRole | type TextMessageRole = Literal['developer', 'system', 'assistant', 'user'] | |
JsonPatchOperation | type JsonPatchOperation = JsonPatchAdd | JsonPatchRemove | JsonPatchReplace | JsonPatchMove | JsonPatchCopy | JsonPatchTest | One RFC 6902 JSON Patch operation. |
RunFinishedOutcome | type RunFinishedOutcome = SuccessOutcome | InterruptOutcome | CancelledOutcome | |
Event | type Event = TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | TextMessageChunkEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallChunkEvent | ToolCallResultEvent | StateSnapshotEvent | StateDeltaEvent | MessagesSnapshotEvent | ActivitySnapshotEvent | ActivityDeltaEvent | RawEvent | CustomEvent | RunStartedEvent | RunFinishedEvent | RunErrorEvent | StepStartedEvent | StepFinishedEvent | ReasoningStartEvent | ReasoningMessageStartEvent | ReasoningMessageContentEvent | ReasoningMessageEndEvent | ReasoningMessageChunkEvent | ReasoningEndEvent | ReasoningEncryptedValueEvent | SubagentStartedEvent | SubagentFinishedEvent | SubagentErrorEvent | Any AG-UI event, discriminated by |