AgentUserInteractionProtocol
class AgentUserInteractionProtocol extends StreamProtocol
The Agent User Interaction (AG-UI) protocol.
Properties
| protected bool | $started | from StreamProtocol | |
| protected bool | $errored | from StreamProtocol | |
| protected Throwable|null | $exception | from StreamProtocol | |
| protected int | $step | ||
| protected bool | $finished | ||
| protected StreamableAgentResponse|null | $response |
Methods
Get the protocol parts that represent the given response's events.
Get the protocol parts that terminate a stream interrupted by an exception.
Create an HTTP response that represents the given response using the protocol.
Encode the given protocol part as a server-sent event line.
Encode the given value as JSON, substituting bytes a provider streamed as invalid UTF-8.
Create an Agent User Interaction protocol formatter.
Get the given protocol part, preceded by the run started events when the run has not begun yet.
Get the events that begin the run and its first step.
Get the event that starts the next step.
Get the event that finishes the current step.
Get the event that finishes the run with the given additional attributes.
Get the run finished attributes that report how the run completed.
Get the interrupts that represent the given approval request's pending approvals.
Get the protocol part for a tool still producing its output, which AG-UI has no tool result for.
Get the protocol part that represents the given tool result event.
Details
at line 61
protected Generator
parts(StreamableAgentResponse $response)
Get the protocol parts that represent the given response's events.
at line 151
protected Generator
maskedErrorParts()
Get the protocol parts that terminate a stream interrupted by an exception.
in
StreamProtocol at line 38
protected array
headers()
Get the response headers for the protocol.
in
StreamProtocol at line 49
Response
response(StreamableAgentResponse $response)
Create an HTTP response that represents the given response using the protocol.
in
StreamProtocol at line 88
protected string|null
terminator()
Get the raw frame that terminates the stream, if any.
in
StreamProtocol at line 98
protected string
encode(array $part)
Encode the given protocol part as a server-sent event line.
in
StreamProtocol at line 106
protected string
json(mixed $value)
Encode the given value as JSON, substituting bytes a provider streamed as invalid UTF-8.
at line 52
__construct(string|null $threadId = null, string|null $runId = null)
Create an Agent User Interaction protocol formatter.
at line 179
protected Generator
yieldPart(array $part)
Get the given protocol part, preceded by the run started events when the run has not begun yet.
at line 193
protected Generator
beginRunParts()
Get the events that begin the run and its first step.
at line 214
protected array
startNextStepPart()
Get the event that starts the next step.
at line 224
protected array
stepFinishedPart()
Get the event that finishes the current step.
at line 235
protected array
runFinishedPart(array $attributes = [])
Get the event that finishes the run with the given additional attributes.
at line 257
protected array
completionAttributes(TextUsage|null $usage, string|null $reason, string|null $provider, string|null $model)
Get the run finished attributes that report how the run completed.
at line 278
protected array
interrupts(ToolApprovalRequest $event)
Get the interrupts that represent the given approval request's pending approvals.
at line 295
protected array
toolCallParts(ToolCall $call)
Get the protocol parts that represent the given tool call.
at line 309
protected array
mapEvent(StreamEvent $event)
Get the protocol parts that represent the given event.
at line 369
protected array
preliminaryToolResultPart(ToolResult $event)
Get the protocol part for a tool still producing its output, which AG-UI has no tool result for.
at line 387
protected array
toolResultPart(ToolResult $event)
Get the protocol part that represents the given tool result event.
at line 410
protected array
citationParts(Citation $event)
Get the protocol parts that represent the given citation event.
at line 428
protected string
toolResultContent(ToolResult $event)
Get the tool message content for the given tool result event.