Repository navigation
Conversation
3 tasks
moetemp
force-pushed
the
moe/streams-api
branch
from
November 14, 2026 02:14
566c3ec to
fc6b8d3
Compare
This was referenced Nov 14, 2026
2 of 3 tasks
moetemp
force-pushed
the
moe/streams-api
branch
from
November 15, 2026 18:51
4c5003d to
09d01f5
Compare
moetemp
force-pushed
the
moe/streams-api
branch
from
November 15, 2026 20:23
09d01f5 to
acf7b46
Compare
moetemp
force-pushed
the
moe/streams-api
branch
from
November 16, 2026 17:14
acf7b46 to
5c6e8a8
Compare
moetemp
force-pushed
the
moe/streams-api
branch
from
November 16, 2026 17:33
5c6e8a8 to
d6d4073
Compare
moetemp
force-pushed
the
moe/streams-api
branch
from
November 16, 2026 19:42
d6d4073 to
d6dda76
Compare
A client takes its Stream Stores in a `StreamConfig`, and each call of the generated Streams API goes to one of them. The Stores run Core's Stream runtime through the bridge.
The Stream WIT now gives the Workflow target `append` and `close`, and keeps `read` out of it.
The Workflow `Stream` has `append` again, and Workflow code can't do I/O. The Local Activity writes as its own Producer with a fixed attempt, so a retry in one Workflow Task writes once.
A Local Activity reaches the Store before its Workflow Task completes, so a failed task would leave a closed Stream. A Worker with Stream Stores now polls for Activity Tasks, so it can run the close.
A create can name its Store with `store=`, so a config with several Stores needs no selector. A call that names no Store on such a config raises `StreamConfigError` at the call.
A failed Workflow Task retries for good, and a Worker with no Stream config never recovers. Workflow code now gets a non-retryable `ApplicationError`, so a user sees the failed Workflow.
A timer of the Workflow event loop goes into History, so in Workflow code the appender starts its write at the next yield instead. The appends of one activation become one Local Activity.
The public Streams API is the generated code. A helper on top of it is a library, so it belongs in contrib.
The other contrib packages have one, and the appender's rules for Workflow code need a place.
A design review decided that Workflow code needs no Activity Task Queue for a Stream. A Worker with Workflows and Stream Stores polls for Activity Tasks only for its own Activities. The docs state that a failed Workflow Task after a close leaves the Stream closed.
Code can keep the Producer of its attempt and pass it to a later append with `producer=`. The tests cover each kind of Producer as an Activity argument and an Activity result.
Heartbeat details decode with no type hint, so a stored Producer comes back as its proto message. `as_producer` gives the `Producer` back, so an Activity's retry can append as its first attempt.
The API docs have two classes called Producer, so the short link had no target in `gen-docs`.
The Stream crate lets a Workflow Producer append with its Workflow Task as the epoch. Both crates call the option `producer_idle_ttl`, since it counts from any Producer's last write.
The Store keeps one Producer state for a run, so it fences a late write of a failed Workflow Task. A Workflow's appends and close on one Stream run one at a time, so their sequences go up in order.
The expired reason of a Stream said the old name of the Store option.
The first release step gives Streams to Activity and client code only. A Stream call of Workflow code fails its Workflow Task with one message, and the Store gets no call.
The changelog lists only what this step ships.
The regenerated Stream terminal calls `_schedule_system_nexus_operation`, as upstream nexgen does. An interceptor of Workflow code then sees a Stream operation only in its operation-specific method.
A loop over Records uses `read`, a loop over pages uses `read_pages`, and one request uses `read_page`. The Stream package is generated from commit 07b565b6 of the nexgen fork.
moetemp
force-pushed
the
moe/streams-api
branch
from
November 18, 2026 02:13
9367bfa to
1b73059
Compare
The Store is now the `temporalio-streams-redis` package, so the bridge has no code for one Store only. A user's Store has the same path as this one.
The next commit removes the memory Store from the SDK. `DictStreamStore` now has the three behaviors that the tests took from it. These are the resend of a batch, the fence of an older epoch and the wait of a read.
The memory Store moves to the `temporalio-streams-memory` package. The bridge has no Stream code left, so a Store is any subclass of `StreamStore`. Core keeps only the protos and the WIT that the generated code needs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
This PR adds the Streams API to the Python SDK, for Activity and client code. It's experimental.
A Stream is an ordered log of Records, for example the tokens of a model call. An Activity or a client writes it, and any of them reads it.
The public API is the code that nexgen generates from the Stream WIT, which is in #2128. This PR is the hand-written part.
StreamConfiggives a client its Stores, in the shape ofExternalStorage, and a Worker uses the config of its client. A Store is a Python class with the five operations,StreamStore. The SDK has no Store of its own, and its bridge has no Stream code. A Store gives the limits of one batch asStreamStore.limits, at most 1,000 Records and 4 MiB.RedisStreamStoreand aMemoryStreamStorefor tests are packages with their own native modules, in feat: add the Python packages of the Redis Store and the memory Store temporal-community/sdk-streams#10.activity.Infofor a Local Activity #2127).appendtakes an optionalsequence, so a retried batch is written once.current_producer()gives the Producer of the calling code. An Activity that goes on from its heartbeat details stores it and passes it toappend, so its retry keeps the epoch of its first attempt.BufferedAppendercollects appends into one write. Itsmax_batch_recordscuts the batches for a Store that allows fewer Records.It depends on two things that have no release yet.
moe/streams-crate-for-sdk-python, which has the Stream protos and the WIT of feat: add the Stream protos and WIT to the vendored API sdk-rust#1733.main, sopoe gen-protosgets a second generator fromNEX_GEN_STREAM_BIN.Why?
An agent application shows partial output, such as the tokens of a model call, while the work still runs. Workflow History isn't the place for that data, so a Stream keeps its Records in a Store outside History.
How did you test it?
The tests are in
tests/nexus/test_stream_store*.pyandtests/contrib/streams/. They run on a Store that is written in Python,DictStreamStoreintests/helpers/streams.py. The tests of the Redis Store moved to its package.Link to a test plan if any -