devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Guidance for streaming chat responses in DevTools integrations

Open onmax opened this issue 6 months ago • 1 comments

Clear and concise description of the problem

I’m working on improving the DX of Chat SDK usage in Nitro v3 and want to add a DevTools page for inspecting and interacting with chats.

A key use case is streaming assistant deltas into the DevTools iframe so chat responses render incrementally. This can be built today with an action call plus delta/done/error events, but then every integration has to invent its own stream ids, cancellation, error handling, and recovery conventions.

I’m open to contributing the necessary PRs in DevTools/devframe or birpc, depending on the preferred direction.

Suggested solution

I’d like guidance on the recommended pattern:

  1. Document action + events as the preferred approach.
  2. Add a small DevTools/devframe helper that exposes an AsyncIterable-style API over action + events.
  3. Explore explicit streaming support in birpc, such as $stream() / asStream().

Alternative

Each integration can keep implementing its own action + event streaming protocol.

Additional context

Related birpc discussion: https://github.com/antfu-collective/birpc/pull/20. I understand the concerns about cancellation, disconnects, timeouts, and keeping birpc small.

Validations

  • [x] Follow our Code of Conduct
  • [x] Read the Contributing Guide.
  • [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

onmax avatar May 05 '26 10:05 onmax

Thanks for the issue, that's indeed an important feature to provide. I will have a look and see what we can do to offer such utility/helper

antfu avatar May 07 '26 05:05 antfu