Skip to content

[Brook] Added full examples for the streams API proposal. - #349

Closed
moetemp wants to merge 5 commits into
moe/brook/v4/p26-wit-docs-and-dead-callsfrom
moe/brook/v4/p27-examples
Closed

moetemp wants to merge 5 commits into
moe/brook/v4/p26-wit-docs-and-dead-callsfrom
moe/brook/v4/p27-examples

Conversation

@moetemp

@moetemp moetemp commented Oct 22, 2026

Copy link
Copy Markdown
Owner

What changed?

This PR adds one complete, runnable example for each section of the Brook streams API proposal, in tests/contrib/streams/examples/.

Each file has the definition, the Workflow, the Activities, the Worker setup and the client code, and a module docstring that names its proposal section. README.md maps each section to its file. The Nexus examples are a later stage, so they have no file.

  • ui_backend_reads.py: StreamClient.workflow_stream, subscribe with Topics and create_wait, and Record, Superseded and Closed handling.
  • resume_from_offset.py: a Reader of a name= Stream that saves offset + 1 and resumes with from_offset.
  • client_creates_stream.py: StreamClient.create with id, retention and auto_close, the Stream passed to a Workflow as data, and the creator's close.
  • agent_publishes_turns.py: create_stream, awaited publish(*values), close_with_run, and an Activity input object that carries the Stream.
  • activity_streams_tokens.py: ActivityStream with awaited publish and BufferedPublisher, and a sync Activity with SyncActivityStream.
  • turn_scoped_stream.py: one Stream per turn with name= and async with, and an index Stream passed through continue-as-new.
  • worker_setup.py: RedisStreamPlugin on the client, name= and default=, MemoryStreamPlugin for tests, and create_stream_nowait and publish_nowait in @workflow.init.

Why?

Moe asked for full examples that match the proposal. Running them in CI keeps them from going stale.

How did you test it?

test_examples.py runs each example end to end on the memory Store and on a scratch redis-server, against the stock dev server. pytest tests/contrib/streams and poe lint pass.

  • Unit Tests
  • Staging
  • End to End Tests

@moetemp

moetemp commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Closing as stale. This layer is folded into the v5 tip, #365, and the upstream review uses a fresh series instead. Plan: https://www.notion.so/4048fc567738814990b7c796ac28fe3f

@moetemp moetemp closed this Oct 25, 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