Skip to content

Message Content Types (Segments) — and how to add your own

An assistant turn is a list of typed segments — text, thinking, code, a tool call, an error, or a type you register yourself (generative UI) — each drawn by its own renderer.

On this page

A segment is data, not an element: the typed pieces an assistant message is made of, each drawn by its own renderer. One turn can carry several — reasoning, then a tool call awaiting approval, then code, then prose.

  • text — Text segment - plain text content
  • thinking — Thinking/reasoning segment - collapsible.
  • code — Code segment - syntax highlighted code block Highlighting is a plugin you opt into; with none installed the block renders plain, which is what core’s zero-dependency promise costs here.
  • error — Error segment A failure card inside the turn that produced it, rather than a toast somewhere else on the page — so the reader can see which question failed.
  • custom — Custom segment - one escape hatch for the views an app draws itself.
  • tool_call — Tool call segment - rendered while waiting for a tool handler to resolve

Two seams make the list yours: registerSegmentRenderer draws a type of your own (a weather card, a domain widget — generative UI), and registerStreamBlock teaches the streaming parser a tag grammar that produces it.