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
moetemp
force-pushed
the
moe/streams-api
branch
from
November 18, 2026 02:13
9367bfa to
1b73059
Compare
moetemp
force-pushed
the
moe/streams-api
branch
from
November 22, 2026 01:10
f93c959 to
fab988c
Compare
moetemp
force-pushed
the
moe/streams-api
branch
2 times, most recently
from
November 22, 2026 03:31
4f48bab to
066b280
Compare
This was referenced Nov 22, 2026
Open
moetemp
force-pushed
the
moe/streams-api
branch
2 times, most recently
from
November 22, 2026 10:25
c7c3f7c to
824202b
Compare
The Workflow path of Streams needs the Stream commands and jobs of this Core. The regenerated payload visitor reaches their payloads, so the rule for a Stream body is in this commit.
A Stream Store is the handler side of the Stream service, which the generated code doesn't have. The memory Store lets a test use Streams with no other service, behind the checks that Core runs for a Store of Workflow code.
The server has no Streams yet, so the last client interceptor sends each Stream call to a Store of the client's Stream config. The generated Stream code also needs its helpers, with the three that build a Producer.
Workflow code can't call a Store itself, since a replay must get the same answers. Core makes the append and the close inside the Workflow Task and records each result in a marker. A create and a describe have no command in Core, so they run in a Local Activity of the SDK.
A read of Workflow code is one command of Core with one job, as a Local Activity is, so no state of a read depends on where an activation ends. A replay reads the Records again from the Store, so a replay Worker gets the event loop that its Python Stores need.
An Activity that appends each model token pays one Store call for each token. The appender batches them with one write in flight, and stops at the first failed batch so that a reader sees no gap.
A Stream read that waits past the heartbeat of its Workflow Task completes that task with no command, and with chunking a replay takes that task and the next one as one. Workflow code then gets two results in one activation that the first run gave in two, and can run in another order, as it can with Local Activities alone. Core records the choice in the first completed Workflow Task of a Workflow, so a Workflow that started before keeps chunking.
moetemp
force-pushed
the
moe/streams-api
branch
from
November 22, 2026 11:52
824202b to
ed857de
Compare
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 hand-written part of the Streams API to the Python SDK. It's experimental.
A Stream is an ordered log of Records, for example the tokens of a model call. A client, an Activity or a Workflow 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 adds what that code calls.
StreamConfiggives a client its Stores, in the shape ofExternalStorage, and a Worker uses the config of its client. It also has the limits of a batch (max_record_bytes,max_batch_bytes,max_batch_records), asExternalStoragehaspayload_size_threshold.StreamStoreis the interface of a Store, an abstract class with the five operations. The SDK hasMemoryStreamStorefor tests. The Redis Store is a separate package, in feat: implement the Stream Store trait on Redis temporal-community/sdk-streams#12.read_pageis one read command of Core with one job. A create and a describe run in a Local Activity of the SDK.activity.Infofor a Local Activity #2127), so a Store that fences refuses the late writes of an earlier attempt. Each append has a request id, so a batch that is sent again is written once.StreamErrorhas the reason of a failed call. WithStreamReplayErrorinworkflow_failure_exception_types, a replay whose Records are gone fails the Workflow.temporalio.contrib.streamshasBufferedAppender, which collects the appends of client and Activity code into one write, andcurrent_producer()withas_producer()for an Activity that goes on from its heartbeat details.It depends on Core's Stream PRs (temporalio/sdk-rust#1817, temporalio/sdk-rust#1801 and temporalio/sdk-rust#1819), which have no release yet. The submodule points to the head of temporalio/sdk-rust#1825, so CI's proto check is expected to fail until a separate PR bumps Core.
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.
These points are open.
start_nexus_operationof the client interceptors and never reaches the server. So a tracing interceptor sees a Nexus operation for each append.COMMAND_TYPE_UNSPECIFIED, since Core's Stream commands have no command type of the server.disable_workflow_task_chunkingof Add opt-in workflow task chunking shutoff sdk-rust#1659. With chunking, a replay can give two results in one activation that the first run gave in two. A read that waits past the heartbeat makes that common, and the released SDK fails the replay of a Workflow with two Local Activities in that shape. A Workflow that started before keeps chunking. The commit is separate, so it can move to a separate PR.StreamStorerepeats the contract of the Rust trait intemporalio-streams, which is its source.How did you test it?
The tests are in
tests/nexus/test_streams*.py,tests/worker/test_workflow_streams.py,tests/testing/test_stream_store.pyandtests/contrib/streams/. A property runs over seeded inputs against a model, and the Worker tests run on the test server with a replay.Link to a test plan if any -