Skip to content

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

Closed
moetemp wants to merge 7 commits into
moe/brook/review/s9-examplesfrom
moe/brook/review/s10-chat-app
Closed

moetemp wants to merge 7 commits 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 with an agent loop. One message can take several rounds: a model round, tool calls, tool results, the next round, and the answer. Each round streams its tokens to a tokens Stream, and each round, tool call and tool result is a Turn in the turns Stream.
  • Tools run as Activities and write their own progress and result Turns. Two tools in one round write to the same Stream at once, so the log shows two Producers.
  • An add_message Signal adds a message during a run. It shows the Turn at once with publish_nowait, and the message joins the next round.
  • A research tool starts a child Workflow that creates its own Streams under ids it picks, and passes their refs to the parent. The page opens it as a nested panel.
  • A fail toggle fails a round'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. Continue-as-new happens between turns, and the next run keeps the Streams.
  • "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.
  • A scenario bar has one preset per case, and "Run all" plays them in one chat.
  • The model is Claude (with tool use), OpenAI or a scripted model that plans the same rounds, 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.

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, create_or_get_stream). It changes with the renames after the API review. A live Claude run with tool rounds works. OpenAI was checked only against a local stand-in. 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.
    • Each scenario in headless Chrome with the scripted model, and a live Claude run with tool rounds.

@moetemp
moetemp force-pushed the moe/brook/review/s10-chat-app branch from 5e21c87 to 3332d2d Compare November 6, 2026 18:53
…view decisions

The facade delegates `create_stream`/`get_stream` to the regenerated nexgen client and matches the approved API. Renamed `publish`/`subscribe` to `append`/`read`, added the opaque `StreamOffset`, collapsed the errors onto reason-coded `StreamError`, and made `producer()` a module-level context manager. Dropped `create_or_get_stream` and `to_stream`, and moved Retention onto the backends.
@moetemp

moetemp commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Closed in favor of #381, the combined branch, which has this change.

@moetemp moetemp closed this Nov 10, 2026
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