Lifecycle

Streaming without repetition

Send only the new text from each streaming update so screen readers do not hear the whole response again and again.

Send only the new text

Send response.started when a response begins. Each response.text.delta must contain only the text that just arrived. Send response.completed to announce any useful text still waiting. Send response.failed or response.interrupted to discard that text.

typescript
runtime.dispatch({ type: "response.started", responseId: "r1" });
runtime.dispatch({
  type: "response.text.delta",
  responseId: "r1",
  delta: "First complete sentence. ",
});
runtime.dispatch({
  type: "response.text.delta",
  responseId: "r1",
  delta: "Second complete sentence.",
});
runtime.dispatch({ type: "response.completed", responseId: "r1" });

How this code works

  1. 01
    Start the response

    response.started tells the runtime that a new response is beginning.

  2. 02
    Send new text only

    Each delta contains only new text, so earlier text is not announced again.

  3. 03
    Let the runtime group text

    Your runtime waits for useful phrases instead of announcing every token.

  4. 04
    Finish the response

    response.completed sends any useful text that is still waiting and closes the response.

Meaningful units, not tokens

Balanced mode waits for a complete sentence when possible. It can also send a useful phrase after enough text arrives or a short delay. Each piece is announced once.