Skip to content

AG-UI agents

Render the text an AG-UI agent streams (LangGraph, CrewAI, Mastra and others) as GistUI.

Updated View as Markdown

AG-UI is an event protocol between agents and frontends. An agent’s text arrives as TEXT_MESSAGE_CONTENT events. GistUI reads them like any other stream: the program is the text of the message.

On your server

Give the agent GistUI’s system prompt (how depends on the agent framework), then turn its event stream into text:

import { textDeltas, toReadable } from "@gistui/server";

const res = await fetch(AGENT_URL, { method: "POST", headers, body: JSON.stringify(runInput) });
return new Response(toReadable(textDeltas(res, "agui")));

In a chat

@gistui/chat has an adapter that speaks to an AG-UI endpoint directly and keeps the thread id:

import { agui, createChat } from "@gistui/chat";

const store = createChat({ adapter: agui({ url: "/api/agent" }) });

What goes back to the agent

A button press or form submit in the UI becomes the next user message, marked as coming from the UI. In @gistui/chat this is automatic. If you hold the conversation yourself, send action.message as the next user turn. See Actions and forms.

How GistUI Format maps onto AG-UI events in general is in the Bindings page of the protocol section.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close