AgUiBackend
The AG-UI protocol (1.x): POST a RunAgentInput, receive the run's events over SSE. Served by Pydantic AI, LangGraph, CrewAI, Mastra, and the bundled server/main.py at /api/agui.
The agent runs server-side; this backend implements the client half of the protocol:
Frontend tools: tools are advertised in
RunAgentInput.tools. When the agent calls one, the run finishes with the call pending; the tool runs here (after approver if it needs approval) and a follow-up run carries thetoolmessage.Interrupts (human in the loop): a run finishing with
outcome: interruptasks approver — to decide on a tool call (the resume payload is{approved, reason?, editedArgs?}, AG-UI's approve-with-edits pattern), or, without a tool call, for input matching the interrupt'sresponseSchema(ToolApprover.input) — then resumes withRunAgentInput.resume(resolvedwith the payload, orcancelled).Subagents:
SUBAGENT_STARTEDand the events carrying itssubagentRunIdare folded into the delegating tool call's nested run.Shared state:
STATE_SNAPSHOT/STATE_DELTA(JSON Patch) become astatedata part, sent back asRunAgentInput.stateon the next turn;ACTIVITY_*become data parts named by theiractivityType; steps a chain-of-thought part.Context: context entries (e.g. capability instructions) go into
RunAgentInput.context.