agui

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package agui is a hand-rolled codec for the AG-UI ("Agent-User Interaction") protocol: an open, event-based protocol that standardizes how AI agents stream structured and unstructured output, tool calls, and state mutations to user-facing applications.

This package is codec-only. It contains the canonical AG-UI event model, the RunAgentInput request shape, JSON encode/decode, and a Server-Sent Events (SSE) reader/writer over text/event-stream. It has no dependency on the Nexus engine or event bus so that both the serve plugin and the consume client can reuse it.

Targeted spec version

This implementation targets the AG-UI protocol as documented at https://docs.ag-ui.com (concepts/events, concepts/interrupts) as fetched 2026-07-10. The taxonomy tracked here corresponds to AG-UI spec version v1 (the JSON/SSE wire, RFC 6902 JSON Patch StateDelta, and the terminal-run interrupt/resume model). Event structs are deliberately kept isolated so that spec drift can be absorbed with localized edits.

No third-party AG-UI SDK is used; this is pure standard-library Go.

Index

Constants

View Source
const (
	// OutcomeInterrupt marks a RunFinished that ends the run because the agent
	// is awaiting human (or client-executed-tool) input. The Result carries an
	// Interrupt payload the client renders and later resolves via the resume[]
	// field of a continuation RunAgentInput.
	OutcomeInterrupt = "interrupt"
	// OutcomeCancelled marks a RunFinished for a run terminated before it
	// completed (e.g. the pending interrupt was retracted).
	OutcomeCancelled = "cancelled"
)

RunFinished outcome discriminators. The AG-UI terminal-run model ends a run with an outcome; an interrupt outcome signals the client that the agent is awaiting a resume (see concepts/interrupts). A cancelled outcome marks a run that was abandoned before completion.

View Source
const ContentType = "text/event-stream"

ContentType is the media type of an AG-UI SSE stream.

View Source
const SpecVersion = "v1 (docs.ag-ui.com, 2026-07-10)"

SpecVersion is the AG-UI protocol spec version this codec targets.

Variables

This section is empty.

Functions

func ApplyPatch

func ApplyPatch(doc json.RawMessage, patch JSONPatch) (json.RawMessage, error)

ApplyPatch replays an RFC 6902 patch onto a JSON document and returns the resulting document. It supports the add/remove/replace operation set DiffState emits over object and scalar shapes; unsupported ops return an error. It is used to verify that snapshot+deltas reconstructs the intended state.

func EncodeEvent

func EncodeEvent(e Event) ([]byte, error)

EncodeEvent serializes an AG-UI event to JSON. The concrete event struct must already carry its discriminator via the embedded BaseEvent (constructors set this); EncodeEvent does not mutate the event.

func ValidateSequence

func ValidateSequence(events []Event) error

ValidateSequence checks that a slice of events forms a well-formed AG-UI run: it must open with RunStarted and close with a terminal event (RunFinished or RunError), with no events outside that envelope. It also enforces basic nesting for streamed messages, tool calls, and steps.

This is an optional helper for tests and conformance checking; the codec does not enforce ordering during encode/decode.

func WriteHeaders

func WriteHeaders(h http.Header)

WriteHeaders sets the SSE response headers on an http.ResponseWriter. It is a convenience for server handlers and is optional.

Types

type ActivityDeltaEvent

type ActivityDeltaEvent struct {
	BaseEvent
	MessageID    string    `json:"messageId"`
	ActivityType string    `json:"activityType"`
	Patch        JSONPatch `json:"patch"`
}

ActivityDeltaEvent carries an incremental activity mutation as a JSON Patch.

type ActivitySnapshotEvent

type ActivitySnapshotEvent struct {
	BaseEvent
	MessageID    string          `json:"messageId"`
	ActivityType string          `json:"activityType"`
	Content      json.RawMessage `json:"content"`
	Replace      bool            `json:"replace,omitempty"`
}

ActivitySnapshotEvent carries a full snapshot of an activity stream.

type BaseEvent

type BaseEvent struct {
	Type EventType `json:"type"`
	// Timestamp is an optional epoch-millisecond timestamp.
	Timestamp *int64 `json:"timestamp,omitempty"`
	// RawEvent optionally carries the provider-native event this was derived from.
	RawEvent json.RawMessage `json:"rawEvent,omitempty"`
	// Metadata is AG-UI's open-by-key extension slot, declared once here because
	// the spec declares it once on the base event. A consumer merges an event's
	// metadata into the object that event builds -- for the TOOL_CALL_* family
	// that is the tool call itself rather than the parent message, which is what
	// keeps the merge independent of how calls interleave on the stream.
	Metadata map[string]any `json:"metadata,omitempty"`
}

BaseEvent carries fields common to every AG-UI event. It is embedded into each concrete event struct.

func (BaseEvent) EventType

func (b BaseEvent) EventType() EventType

EventType returns the discriminator carried by the event.

type ContextItem

type ContextItem struct {
	Description string `json:"description,omitempty"`
	Value       string `json:"value"`
}

ContextItem is a supplemental context entry attached to a run.

type CustomEvent

type CustomEvent struct {
	BaseEvent
	Name  string          `json:"name"`
	Value json.RawMessage `json:"value"`
}

CustomEvent carries an application-defined named value. Nexus rides non-canonical bus events (workflow progress, code-exec stdout, etc.) on this.

func NewCustom

func NewCustom(name string, value []byte) CustomEvent

NewCustom builds a Custom named-value event.

type Event

type Event interface {
	EventType() EventType
}

Event is implemented by every AG-UI event struct. Type returns the value carried in the "type" JSON field.

func DecodeEvent

func DecodeEvent(data []byte) (Event, error)

DecodeEvent parses a JSON AG-UI event, dispatching on its "type" field to the matching concrete struct. The returned Event is a pointer to that struct.

type EventType

type EventType string

EventType is the discriminator carried in every AG-UI event's "type" field.

const (
	// Lifecycle.
	EventRunStarted   EventType = "RUN_STARTED"
	EventRunFinished  EventType = "RUN_FINISHED"
	EventRunError     EventType = "RUN_ERROR"
	EventStepStarted  EventType = "STEP_STARTED"
	EventStepFinished EventType = "STEP_FINISHED"

	// Text message.
	EventTextMessageStart   EventType = "TEXT_MESSAGE_START"
	EventTextMessageContent EventType = "TEXT_MESSAGE_CONTENT"
	EventTextMessageEnd     EventType = "TEXT_MESSAGE_END"
	EventTextMessageChunk   EventType = "TEXT_MESSAGE_CHUNK"

	// Tool call.
	EventToolCallStart  EventType = "TOOL_CALL_START"
	EventToolCallArgs   EventType = "TOOL_CALL_ARGS"
	EventToolCallEnd    EventType = "TOOL_CALL_END"
	EventToolCallResult EventType = "TOOL_CALL_RESULT"
	EventToolCallChunk  EventType = "TOOL_CALL_CHUNK"

	// State.
	EventStateSnapshot    EventType = "STATE_SNAPSHOT"
	EventStateDelta       EventType = "STATE_DELTA"
	EventMessagesSnapshot EventType = "MESSAGES_SNAPSHOT"

	// Activity.
	EventActivitySnapshot EventType = "ACTIVITY_SNAPSHOT"
	EventActivityDelta    EventType = "ACTIVITY_DELTA"

	// Reasoning (thinking).
	EventReasoningStart          EventType = "REASONING_START"
	EventReasoningMessageStart   EventType = "REASONING_MESSAGE_START"
	EventReasoningMessageContent EventType = "REASONING_MESSAGE_CONTENT"
	EventReasoningMessageEnd     EventType = "REASONING_MESSAGE_END"
	EventReasoningMessageChunk   EventType = "REASONING_MESSAGE_CHUNK"
	EventReasoningEnd            EventType = "REASONING_END"
	EventReasoningEncryptedValue EventType = "REASONING_ENCRYPTED_VALUE"

	// Special.
	EventRaw    EventType = "RAW"
	EventCustom EventType = "CUSTOM"
	EventMeta   EventType = "META_EVENT"
)

Canonical AG-UI event types.

type Interrupt

type Interrupt struct {
	// InterruptID uniquely identifies this interrupt for the lifetime of the
	// pending request. The client echoes it in ResumeItem.InterruptID.
	InterruptID string `json:"interruptId"`
	// Prompt is the rendered question/approval text to show the user.
	Prompt string `json:"prompt,omitempty"`
	// Mode controls whether the response is freeform, a choice, or either.
	Mode InterruptMode `json:"mode,omitempty"`
	// Choices lists the options when Mode is choices or both.
	Choices []InterruptChoice `json:"choices,omitempty"`
	// DefaultChoiceID is the choice applied if the user does not answer (the
	// server-side deadline default).
	DefaultChoiceID string `json:"defaultChoiceId,omitempty"`
}

Interrupt is the payload carried in a RunFinished(interrupt) Result. It gives the client everything needed to render a prompt and, on resume, to correlate its resolution back to the pending server-side request via InterruptID.

type InterruptChoice

type InterruptChoice struct {
	ID    string `json:"id"`
	Label string `json:"label"`
	Kind  string `json:"kind,omitempty"`
}

InterruptChoice is one option the client presents to the user when an interrupt is a choice (or both) mode.

type InterruptMode

type InterruptMode string

InterruptMode mirrors the response shape an interrupt accepts so the client can render the correct prompt affordance. Values align with the Nexus HITL modes (free_text, choices, both) but are duplicated here to keep pkg/agui free of any dependency on the engine or events packages.

const (
	InterruptModeFreeText InterruptMode = "free_text"
	InterruptModeChoices  InterruptMode = "choices"
	InterruptModeBoth     InterruptMode = "both"
)

type JSONPatch

type JSONPatch []JSONPatchOp

JSONPatch is an RFC 6902 JSON Patch document (an ordered array of operations).

func DiffState

func DiffState(oldState, newState json.RawMessage) (JSONPatch, error)

DiffState computes an RFC 6902 JSON Patch that transforms oldState into newState. Both inputs are raw JSON documents; a nil/empty input is treated as the JSON null document. The returned patch is deterministic (object keys are visited in sorted order) so successive diffs over the same states are stable, and applying it in order to oldState via ApplyPatch reproduces newState.

type JSONPatchOp

type JSONPatchOp struct {
	Op    string          `json:"op"`
	Path  string          `json:"path"`
	From  string          `json:"from,omitempty"`
	Value json.RawMessage `json:"value,omitempty"`
}

JSONPatchOp is a single RFC 6902 operation.

type Message

type Message struct {
	ID         string     `json:"id"`
	Role       string     `json:"role"`
	Content    string     `json:"content,omitempty"`
	Name       string     `json:"name,omitempty"`
	ToolCallID string     `json:"toolCallId,omitempty"`
	ToolCalls  []ToolCall `json:"toolCalls,omitempty"`
	// Metadata is the per-message half of the extension slot above. It is the
	// vehicle for provider continuity state that a later request has to echo
	// back verbatim; see pkg/roundtrip for which keys those are and why.
	Metadata map[string]any `json:"metadata,omitempty"`
}

Message is a single conversation message as carried in MessagesSnapshot and RunAgentInput.

type MessagesSnapshotEvent

type MessagesSnapshotEvent struct {
	BaseEvent
	Messages []Message `json:"messages"`
}

MessagesSnapshotEvent carries a full snapshot of the conversation messages.

func NewMessagesSnapshot

func NewMessagesSnapshot(messages []Message) MessagesSnapshotEvent

NewMessagesSnapshot builds a MessagesSnapshot event.

type MetaEvent

type MetaEvent struct {
	BaseEvent
	Name  string          `json:"name,omitempty"`
	Value json.RawMessage `json:"value,omitempty"`
}

MetaEvent is a draft meta-event carrier.

type RawEvent

type RawEvent struct {
	BaseEvent
	Event  json.RawMessage `json:"event"`
	Source string          `json:"source,omitempty"`
}

RawEvent wraps a provider-native event for pass-through.

func NewRaw

func NewRaw(event []byte) RawEvent

NewRaw builds a Raw pass-through event.

type ReasoningEncryptedValueEvent

type ReasoningEncryptedValueEvent struct {
	BaseEvent
	Value string `json:"value"`
}

ReasoningEncryptedValueEvent carries an opaque encrypted reasoning payload.

type ReasoningEndEvent

type ReasoningEndEvent struct {
	BaseEvent
}

ReasoningEndEvent closes a reasoning (thinking) section.

func NewReasoningEnd

func NewReasoningEnd() ReasoningEndEvent

NewReasoningEnd builds a ReasoningEnd event.

type ReasoningMessageChunkEvent

type ReasoningMessageChunkEvent struct {
	BaseEvent
	MessageID string `json:"messageId,omitempty"`
	Role      string `json:"role,omitempty"`
	Delta     string `json:"delta,omitempty"`
}

ReasoningMessageChunkEvent is the combined form for a reasoning message.

type ReasoningMessageContentEvent

type ReasoningMessageContentEvent struct {
	BaseEvent
	MessageID string `json:"messageId,omitempty"`
	Delta     string `json:"delta"`
}

ReasoningMessageContentEvent carries an incremental reasoning delta.

func NewReasoningMessageContent

func NewReasoningMessageContent(delta string) ReasoningMessageContentEvent

NewReasoningMessageContent builds a ReasoningMessageContent event.

type ReasoningMessageEndEvent

type ReasoningMessageEndEvent struct {
	BaseEvent
	MessageID string `json:"messageId,omitempty"`
}

ReasoningMessageEndEvent closes a streamed reasoning message.

type ReasoningMessageStartEvent

type ReasoningMessageStartEvent struct {
	BaseEvent
	MessageID string `json:"messageId,omitempty"`
	Role      string `json:"role,omitempty"`
}

ReasoningMessageStartEvent opens a streamed reasoning message.

type ReasoningStartEvent

type ReasoningStartEvent struct {
	BaseEvent
}

ReasoningStartEvent opens a reasoning (thinking) section.

func NewReasoningStart

func NewReasoningStart() ReasoningStartEvent

NewReasoningStart builds a ReasoningStart event.

type ResumeItem

type ResumeItem struct {
	InterruptID string          `json:"interruptId"`
	Status      ResumeStatus    `json:"status"`
	Payload     json.RawMessage `json:"payload,omitempty"`
}

ResumeItem correlates a resume payload to a specific interrupt.

type ResumeStatus

type ResumeStatus string

ResumeStatus is the resolution status of an interrupt in a resume request.

const (
	// ResumeResolved indicates the user answered; Payload carries the answer.
	ResumeResolved ResumeStatus = "resolved"
	// ResumeCancelled indicates the interrupt was abandoned.
	ResumeCancelled ResumeStatus = "cancelled"
)

type RunAgentInput

type RunAgentInput struct {
	ThreadID       string          `json:"threadId"`
	RunID          string          `json:"runId"`
	Messages       []Message       `json:"messages,omitempty"`
	State          json.RawMessage `json:"state,omitempty"`
	Tools          []Tool          `json:"tools,omitempty"`
	Context        []ContextItem   `json:"context,omitempty"`
	ForwardedProps json.RawMessage `json:"forwardedProps,omitempty"`
	// Resume carries the resolution of open interrupts when starting a
	// continuation run. All open interrupts must be addressed in one request.
	Resume []ResumeItem `json:"resume,omitempty"`
}

RunAgentInput is the request body a client POSTs to start (or resume) an agent run. The server responds with a text/event-stream SSE stream.

func DecodeRunAgentInput

func DecodeRunAgentInput(data []byte) (RunAgentInput, error)

DecodeRunAgentInput parses a RunAgentInput from JSON.

func (RunAgentInput) Encode

func (in RunAgentInput) Encode() ([]byte, error)

Encode serializes the RunAgentInput to JSON.

type RunErrorEvent

type RunErrorEvent struct {
	BaseEvent
	Message string `json:"message"`
	Code    string `json:"code,omitempty"`
}

RunErrorEvent reports a fatal error for the run.

func NewRunError

func NewRunError(message string) RunErrorEvent

NewRunError builds a RunError event.

type RunFinishedEvent

type RunFinishedEvent struct {
	BaseEvent
	ThreadID string          `json:"threadId,omitempty"`
	RunID    string          `json:"runId,omitempty"`
	Outcome  string          `json:"outcome,omitempty"`
	Result   json.RawMessage `json:"result,omitempty"`
}

RunFinishedEvent signals the end of an agent run and terminates the SSE stream.

func NewRunFinished

func NewRunFinished(threadID, runID string) RunFinishedEvent

NewRunFinished builds a RunFinished event.

func NewRunFinishedCancelled

func NewRunFinishedCancelled(threadID, runID string) RunFinishedEvent

NewRunFinishedCancelled builds a RunFinished event carrying a cancelled outcome, used when a pending interrupt is retracted before it is resolved.

func NewRunFinishedInterrupt

func NewRunFinishedInterrupt(threadID, runID string, in Interrupt) RunFinishedEvent

NewRunFinishedInterrupt builds a RunFinished event carrying an interrupt outcome. The Interrupt payload is JSON-encoded into Result. A marshalling failure yields a null Result rather than a partial event; the outcome discriminator still tells the client the run was interrupted.

type RunStartedEvent

type RunStartedEvent struct {
	BaseEvent
	ThreadID    string          `json:"threadId"`
	RunID       string          `json:"runId"`
	ParentRunID string          `json:"parentRunId,omitempty"`
	Input       json.RawMessage `json:"input,omitempty"`
}

RunStartedEvent signals the beginning of an agent run.

func NewRunStarted

func NewRunStarted(threadID, runID string) RunStartedEvent

NewRunStarted builds a RunStarted event.

type SSEReader

type SSEReader struct {
	// contains filtered or unexported fields
}

SSEReader decodes an AG-UI SSE stream into events. It handles multi-line "data:" records, comments (":" lines), and blank-line record boundaries.

func NewSSEReader

func NewSSEReader(r io.Reader) *SSEReader

NewSSEReader reads an AG-UI SSE stream from r.

func (*SSEReader) Next

func (sr *SSEReader) Next() (Event, error)

Next reads and decodes the next AG-UI event from the stream. It returns io.EOF when the stream is exhausted.

func (*SSEReader) ReadAll

func (sr *SSEReader) ReadAll() ([]Event, error)

ReadAll drains the SSE stream into a slice of events. It stops at io.EOF.

type SSEWriter

type SSEWriter struct {
	// contains filtered or unexported fields
}

SSEWriter serializes AG-UI events to an io.Writer as Server-Sent Events. Each event is written as an SSE "data:" record (JSON payload) terminated by a blank line, and the underlying writer is flushed after every event when it supports http.Flusher so clients receive events as they are produced.

func NewSSEWriter

func NewSSEWriter(w io.Writer) *SSEWriter

NewSSEWriter wraps w. If w implements http.Flusher, each event is flushed.

func (*SSEWriter) Flush

func (sw *SSEWriter) Flush()

Flush flushes the underlying writer if it supports flushing.

func (*SSEWriter) Write

func (sw *SSEWriter) Write(e Event) error

Write encodes and emits a single AG-UI event as one SSE record.

func (*SSEWriter) WriteComment

func (sw *SSEWriter) WriteComment(text string) error

WriteComment emits an SSE comment record — a line beginning ":" carrying no event. Every conforming SSE reader ignores it (SSEReader.Next skips it explicitly), so it is inert to the client and is the standard way to keep a connection from idling out.

It exists because an AG-UI stream is silent between events, and "silent" is what an intermediary measures. A turn that spends thirty seconds in one LLM call writes nothing in that time, and a proxy, load balancer or service mesh with an idle timeout below the gap closes the connection under a live turn — which the client sees as a 200 with a truncated body and no answer, and the engine sees as the stream dying under a turn it must then cancel.

A comment carrying no text is a bare ":" line, which is legal; the text is for whoever reads the raw stream.

type StateDeltaEvent

type StateDeltaEvent struct {
	BaseEvent
	Delta JSONPatch `json:"delta"`
}

StateDeltaEvent carries an incremental state mutation as an RFC 6902 JSON Patch.

func NewStateDelta

func NewStateDelta(delta JSONPatch) StateDeltaEvent

NewStateDelta builds a StateDelta event carrying an RFC 6902 JSON Patch.

type StateSnapshotEvent

type StateSnapshotEvent struct {
	BaseEvent
	Snapshot json.RawMessage `json:"snapshot"`
}

StateSnapshotEvent carries a full snapshot of the shared state.

func NewStateSnapshot

func NewStateSnapshot(snapshot []byte) StateSnapshotEvent

NewStateSnapshot builds a StateSnapshot event.

type StepFinishedEvent

type StepFinishedEvent struct {
	BaseEvent
	StepName string `json:"stepName"`
}

StepFinishedEvent marks the end of a named step within a run.

func NewStepFinished

func NewStepFinished(stepName string) StepFinishedEvent

NewStepFinished builds a StepFinished event.

type StepStartedEvent

type StepStartedEvent struct {
	BaseEvent
	StepName string `json:"stepName"`
}

StepStartedEvent marks the start of a named step within a run.

func NewStepStarted

func NewStepStarted(stepName string) StepStartedEvent

NewStepStarted builds a StepStarted event.

type TextMessageChunkEvent

type TextMessageChunkEvent struct {
	BaseEvent
	MessageID string `json:"messageId,omitempty"`
	Role      string `json:"role,omitempty"`
	Delta     string `json:"delta,omitempty"`
}

TextMessageChunkEvent is the combined start/content/end form for a text message.

func NewTextMessageChunk

func NewTextMessageChunk(messageID, delta string) TextMessageChunkEvent

NewTextMessageChunk builds a TextMessageChunk event.

type TextMessageContentEvent

type TextMessageContentEvent struct {
	BaseEvent
	MessageID string `json:"messageId"`
	Delta     string `json:"delta"`
}

TextMessageContentEvent carries an incremental text delta.

func NewTextMessageContent

func NewTextMessageContent(messageID, delta string) TextMessageContentEvent

NewTextMessageContent builds a TextMessageContent event.

type TextMessageEndEvent

type TextMessageEndEvent struct {
	BaseEvent
	MessageID string `json:"messageId"`
}

TextMessageEndEvent closes a streamed text message.

func NewTextMessageEnd

func NewTextMessageEnd(messageID string) TextMessageEndEvent

NewTextMessageEnd builds a TextMessageEnd event.

type TextMessageStartEvent

type TextMessageStartEvent struct {
	BaseEvent
	MessageID string `json:"messageId"`
	Role      string `json:"role"`
}

TextMessageStartEvent opens a streamed text message.

func NewTextMessageStart

func NewTextMessageStart(messageID, role string) TextMessageStartEvent

NewTextMessageStart builds a TextMessageStart event.

type Tool

type Tool struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	Parameters  json.RawMessage `json:"parameters,omitempty"`
}

Tool describes a tool the client makes available to the agent.

type ToolCall

type ToolCall struct {
	ID       string           `json:"id"`
	Type     string           `json:"type,omitempty"`
	Function ToolCallFunction `json:"function"`
	// Metadata is the per-call extension slot. A reasoning provider issues its
	// continuity token against ONE call -- Gemini signs the first functionCall
	// of a parallel batch and no other -- so the token belongs here rather than
	// on the message the calls happen to share.
	Metadata map[string]any `json:"metadata,omitempty"`
}

ToolCall describes a tool invocation attached to an assistant message.

type ToolCallArgsEvent

type ToolCallArgsEvent struct {
	BaseEvent
	ToolCallID string `json:"toolCallId"`
	Delta      string `json:"delta"`
}

ToolCallArgsEvent carries an incremental tool-argument delta.

func NewToolCallArgs

func NewToolCallArgs(toolCallID, delta string) ToolCallArgsEvent

NewToolCallArgs builds a ToolCallArgs event.

type ToolCallChunkEvent

type ToolCallChunkEvent struct {
	BaseEvent
	ToolCallID      string `json:"toolCallId,omitempty"`
	ToolCallName    string `json:"toolCallName,omitempty"`
	ParentMessageID string `json:"parentMessageId,omitempty"`
	Delta           string `json:"delta,omitempty"`
}

ToolCallChunkEvent is the combined start/args/end form for a tool call.

func NewToolCallChunk

func NewToolCallChunk(toolCallID string) ToolCallChunkEvent

NewToolCallChunk builds a ToolCallChunk event.

type ToolCallEndEvent

type ToolCallEndEvent struct {
	BaseEvent
	ToolCallID string `json:"toolCallId"`
}

ToolCallEndEvent closes a streamed tool call.

func NewToolCallEnd

func NewToolCallEnd(toolCallID string) ToolCallEndEvent

NewToolCallEnd builds a ToolCallEnd event.

type ToolCallFunction

type ToolCallFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

ToolCallFunction is the function payload of a ToolCall.

type ToolCallResultEvent

type ToolCallResultEvent struct {
	BaseEvent
	MessageID  string `json:"messageId"`
	ToolCallID string `json:"toolCallId"`
	Content    string `json:"content"`
	Role       string `json:"role,omitempty"`
}

ToolCallResultEvent reports the result of a tool call.

func NewToolCallResult

func NewToolCallResult(messageID, toolCallID, content string) ToolCallResultEvent

NewToolCallResult builds a ToolCallResult event.

type ToolCallStartEvent

type ToolCallStartEvent struct {
	BaseEvent
	ToolCallID      string `json:"toolCallId"`
	ToolCallName    string `json:"toolCallName"`
	ParentMessageID string `json:"parentMessageId,omitempty"`
}

ToolCallStartEvent opens a streamed tool call.

func NewToolCallStart

func NewToolCallStart(toolCallID, toolCallName string) ToolCallStartEvent

NewToolCallStart builds a ToolCallStart event.

Directories

Path Synopsis
Package aguiclient is a reusable, pure-Go AG-UI conformance client.
Package aguiclient is a reusable, pure-Go AG-UI conformance client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL