Skip to content

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

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 - for framework-specific views (Onboarding, Tools, etc.)
  • 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.