Skip to main content
Agent stream events follow the AG-UI open protocol, making your agents natively compatible with AG-UI frontends — CopilotKit, custom React clients, and other SDKs — without extra integration work. Events like RUN_STARTED, TEXT_MESSAGE_CONTENT, TOOL_CALL_START, and REASONING_MESSAGE_CONTENT are emitted in the correct AG-UI sequence during every Stream call.

Basic integration

Enable streaming, then forward serialized events to your frontend over SSE, WebSocket, or Redis:
a, err := agent.NewAgent(
    agent.WithLLMClient(llmClient),
    agent.WithStream(true),
)

eventCh, err := a.Stream(ctx, prompt, nil)
if err != nil {
    return err
}

for ev := range eventCh {
    if ev == nil {
        continue
    }
    jsonBytes, err := ev.ToJSON()
    if err != nil {
        continue
    }
    // Forward jsonBytes to SSE/WebSocket client
    _ = jsonBytes
}
Call event.ToJSON() on any AgentEvent to get AG-UI-compatible JSON.

Reference app

Agent Chat — production-shaped split API/worker app with Postgres, SSE streaming, and CopilotKit UI.

Example

AG-UI

Go SSE server + CopilotKit UI

Streaming

Stream API and event types

Approvals

CUSTOM events and OnApproval

Sub-agents

Event fan-in from delegated agents

Agent Chat

Full-stack reference application