Skip to content

[Brook S10] Added a chat app that shows most parts of the Streams API. - #380

Draft
moetemp wants to merge 1 commit into
moe/brook/review/s9-examplesfrom
moe/brook/review/s10-chat-app
Draft

moetemp wants to merge 1 commit into
moe/brook/review/s9-examplesfrom
moe/brook/review/s10-chat-app

Conversation

@moetemp

@moetemp moetemp commented Nov 6, 2026

Copy link
Copy Markdown
Owner

What was changed

This PR adds a small chat app in tests/contrib/streams/examples/chat_app/ that uses most parts of the Streams API.

  • Each chat is a ChatSession Workflow. It publishes each Turn to a turns Stream, and its model Activity streams token deltas to a tokens Stream through a BufferedPublisher.
  • A FastAPI server reads both Streams and sends them to the browser as Server-Sent Events. The page shows the chat, and a log of each Stream item with its offset, its Producer and its kind.
  • A fail toggle fails the model's first attempt, so the retry's Superseded item crosses out the failed tokens. A reload or a server restart resumes each read at the tab's saved offset.
  • "Share a snapshot" copies the chat into a new closed Stream with a strict client.create_stream. Each copy keeps the Turn's offset and Producer in the chat.
  • The model is Claude, OpenAI or a scripted model, by CHAT_MODEL_PROVIDER or by which key is set. The app reads no key itself, and a failed call keeps only the error's class.
  • The app's README.md lists where each API feature is used, and which ones it doesn't use yet.

Why?

It shows how the API reads in a real app, not only in examples. The app also found a bug in the Workflow _nowait writes, which #377 fixes.

The app uses today's names (publish, subscribe, BufferedPublisher). It changes with the naming rename after the API review. Live Claude and OpenAI calls are untested, since no working key was available. The Claude call was checked against a local stand-in for the Messages API. The fix for an end signal during continue-as-new has no test, since the race can't be timed reliably.

Part of the Streams review series.

Checklist

  1. How was this tested:
    • poe lint, and the Streams suite with the app tests on both backends with Redis.
    • The main flows in headless Chrome: chat, fail toggle, second reader, continue-as-new, share, end chat, a reload and a server restart in the middle of a reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant