stream=true and pipe a Vercel AI SDK UIMessageStream v1 into its body.
Relay consumes the whole stream and commits one canonical message when it
finishes.
There is no Relay draft to open, append, edit, or clean up.
Pipe an AI SDK response
Use theconversation_id from message.received and derive the idempotency key
from that event’s event_id.
Wire request
The same contract can be exercised without a framework:reply.sse uses the AI SDK’s existing framing:
202 message response after the canonical commit.
What Relay preserves
The external agent owns the full loop. Relay is the messaging channel and
presentation surface.
Completion and recovery
finishis semantic completion.[DONE]only closes the transport; it does not commit a message by itself.abort,error, malformed ordering, or an early disconnect writes no transcript row.- A successful stream produces one durable
message.createdevent and one notification. - Retry the whole request with the same
Idempotency-Key. The same completed stream returns the original message; different content returns409 idempotency_conflict. - A disconnected app recovers the final message through normal cursor sync and history.