Skip to content

Allowed external-stream publishes from the workflow constructor. - #40

Open
moedash wants to merge 1 commit into
moe/AI-198-if-pyext-3-replay-schedulefrom
moe/AI-198-if-pyext-4-constructor-publish
Open

moedash wants to merge 1 commit into
moe/AI-198-if-pyext-3-replay-schedulefrom
moe/AI-198-if-pyext-4-constructor-publish

Conversation

@moedash

@moedash moedash commented Oct 3, 2026

Copy link
Copy Markdown
Owner

This PR lets a workflow publish to and subscribe to external streams from its @workflow.init constructor.

What changed?

  • Per-run stream state hangs off the SDK's own object for the run, reached through _run_holder(), not off the user's workflow object.
  • The worker installs the stream runtime before the constructor runs.
  • The tests patch _run_holder instead of workflow.instance, and a new integration case subscribes from the constructor.

Part of AI-198 (epic AI-37).

Why?

The user's workflow object doesn't exist yet while @workflow.init runs, so a constructor that touched a stream found no runtime and failed the task. The SDK's run object exists for the whole run, which is also the lifetime the state needs. Without that, an evicted run would hand its wait ids to the next one.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

poe lint is clean, and the external stream suite passes on the dev server, the constructor case included. The test fakes from the old branch that place records with an offset aren't needed by any fix so far. They'll come with the first test that needs them.

Per-Run state lives on the SDK's Run object and the runtime is installed before the constructor runs, since the user's object does not exist yet while @workflow.init executes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Changelog entry rides another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant