Skip to main content
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 initialized agent and mux:
The method restriction is on your mux. The handler selects the agent from the 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 an event 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.

Application boundary

Wrap this handler with authentication, authorization, request-body limits, and appropriate server timeouts. In particular, the SDK-native input accepts namespace and run-context fields: a public caller must not be allowed to choose privileged values unchecked. This minimal handler does not implement the AG-UI namespace resolver. Registry names are unique within one registry. Registration does not start an HTTP server or durable worker, and does not make the agent discoverable in other processes.