Vibeleaderboard
← All Intel
Intel / article

Chat SDK agents can now stream generative UI with json-render

Source
vercel.com
Author
Railly Hugo
Date

Context

Agents built with Vercel's Chat SDK, a library for bots that post to Slack, Teams and other chat platforms through per-platform adapters, can now answer with generated interface elements such as tables, charts and buttons instead of plain text, according to Vercel's changelog. The work is done by json-render. A developer defines a typed catalog of components, the model is prompted with that catalog and writes a JSON spec describing a card, and json-render converts the spec into a Chat SDK card. Each adapter then posts the card in its platform's own format, Block Kit on Slack and Adaptive Cards on Teams, so the model writes one description and the adapters handle the translation. Vercel's case for this is that one catalog replaces a separate tool the developer would otherwise build and maintain for each shape of message.

Cards appear while the model is still writing. The streamCard function posts the card as soon as its root element has content and then edits the message as further elements arrive, at most once every 500 milliseconds by default, which matches Chat SDK's normal interval. When the stream ends, the message shows the final, validated card.

Validation checks the model's output against the catalog. The toCard function checks every element's properties against its component's schema and throws a CardSpecError when a spec is invalid, listing each problem as a separate readable issue that can be sent back to the model to get a corrected spec. Platform limits are handled the same way when the developer asks for it. Chat platforms cap what a single message can hold, and Chat SDK adapters normally degrade content past those caps; the Slack adapter, for example, turns a second table into a code block. Passing limits makes json-render reject such a spec instead of letting the adapter quietly downgrade it.

Key takeaways · AI-distilled
  • With json-render, a Chat SDK writes a JSON spec against a typed component catalog, and each adapter posts it in the platform's native format, such as Block Kit on Slack and Adaptive Cards on Teams, instead of needing a separate tool per message shape.
  • streamCard posts a card once its root element has content, then edits the message as elements stream in, at most once every 500 ms by default to match Chat SDK's streaming interval. The final message shows the validated card.
  • toCard checks every element's props against its schema and throws CardSpecError with one issue per problem, which can go back to the model for a fix. Passing limits rejects specs an adapter would degrade, like Slack turning a second table into a code block.
Terms in this piece · Glossary
  • streaming — Sending a model's response token by token as it is generated, so the reader sees text immediately instead of waiting for the whole answer.
  • AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
Recommended reads
Comments

Checking sign-in…

Loading comments…