hastekit.NewHTTPHandler accepts SDK AgentInput JSON and emits SDK response chunks as server-sent events. Use AG-UI for the embedded UI, thread APIs, namespace resolution, and reconnect support.
Register and mount
Given an initializedagent and mux:
agent query parameter:
messages is a message bundle containing an inner message list. This body is not the AG-UI RunAgentInput shape.
Stream handling
Each event has anevent name from the SDK chunk type and a JSON data payload. Handle error events even after HTTP 200. A closed stream alone does not prove the model completed successfully.
The adapter uses detached agent.Execute execution. Losing the HTTP connection disconnects the subscriber; it does not automatically stop the run. Use an application stop endpoint or the AG-UI handler when clients need run controls.