Skip to content

reflex-workflow: give the wake-during-a-pass test a runtime of its own - #7385

Merged
masenf merged 7 commits into
mainfrom
fix/wake-waits-for-running-steps
Oct 2, 2026
Merged

masenf merged 7 commits into
mainfrom
fix/wake-waits-for-running-steps

Conversation

@adhami3310

@adhami3310 adhami3310 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Summary

The engine fix this PR started with (wake waiting for in-flight steps, and not counting a pass that was woken during it) landed separately in #7382 with the same condition, so after merging main this PR keeps only the part #7382 doesn't have.

test_a_wake_during_a_pass_is_not_lost ran its worker on the module's shared runtime. A pass of the module's worker could clear the wake event this test's worker was counting on, leaving it to wait out a 30-second poll against a 5-second bound. It now builds a Runtime of its own, like the other wake tests do through only_worker.

Test plan

A pass that claimed nothing counted as caught up even while steps from the
pass before it were still running. wake then returned True mid-step, and a
host that suspends on that answer -- the reason wake holds the request open
-- would cut the step off. It is also why
test_wake_settles_once_the_worker_has_nothing_left_to_take flaked in CI: the
pass after the claim settled before the step had committed.

A pass is now counted only when no step is in flight. A finishing step
already wakes the loop, so the pass after the last one is the one counted.

The regression test holds a step open: wake must report False while it runs
and True once it has committed. It fails without this change.
@adhami3310
adhami3310 requested a review from a team as a code owner October 2, 2026 00:54
adhami3310 added a commit that referenced this pull request Oct 2, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Test setup change for workflow engine test.

The PR appears safe to merge.

Summary

The PR gives the wake-during-a-pass test its own runtime so the module’s shared worker cannot clear the wake event the test observes.

  • The previously reported blocked-step issue is fixed in the current code, and its thread is resolved.

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

A run started after a pass looked for work, but before the pass was
counted, left wake returning True with that run still due. A pass during
which the loop was woken is no longer counted: the loop looks again at
once, and that pass is. The new test starts a run in that gap and fails
without this change.
@codspeed

codspeed Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 146 untouched benchmarks
⏩ 18 skipped benchmarks1


Comparing fix/wake-waits-for-running-steps (c54124e) with main (53e48dd)

Open in CodSpeed

Footnotes

  1. 18 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

It ran its worker on the module's shared runtime, so a pass of the
module's worker could clear the wake it was counting on and leave it
waiting out a thirty-second poll. Run alongside the other wake tests on
main it failed 2 times in 40; with its own runtime, 0 in 40.
@masenf masenf added the on deck PRs lined up to review / merge next label Oct 2, 2026
masenf
masenf previously approved these changes Oct 2, 2026
Otherwise a failure there leaves the step blocked in a task the worker
started, past the end of the test.
…nning-steps

# Conflicts:
#	packages/reflex-workflow/README.md
#	packages/reflex-workflow/src/reflex_workflow/engine/runner.py
#	packages/reflex-workflow/src/reflex_workflow/engine/runtime.py
#	tests/units/reflex_workflow/engine/test_runner.py
@adhami3310 adhami3310 changed the title reflex-workflow: wake waits for the steps it started to finish reflex-workflow: give the wake-during-a-pass test a runtime of its own Oct 2, 2026
@masenf
masenf merged commit f1ad69f into main Oct 2, 2026
145 checks passed
@masenf
masenf deleted the fix/wake-waits-for-running-steps branch October 2, 2026 22:02
masenf added a commit that referenced this pull request Nov 17, 2026
* docs: add a Workflows section for reflex-workflow

Thirteen pages under docs/workflows, grouped in the Backend sidebar: an
overview, a tutorial, guides to defining workflows, steps, runs, events,
schedules, fan-out, concurrency, workers and inspecting runs, an explanation
of how the engine works and what it guarantees, and an API reference.

Also fixes the package README's wake route, which used an app.api attribute
Reflex does not have.

* docs: qualify lease-bound claims and complete example imports

* docs: retryable webhook response, precise cancel status, and what history records

* docs: acknowledge webhooks only on known delivery, guard the cancel status, describe history as committed attempts

* reflex-workflow: answer a message whose wake was refused while a held one ran

A run holds one event at a time. When the conversation example's turn was
running a held wake, a wake for a message that arrived after the turn read the
transcript was refused, and nothing read that message until the four-hour
reminder. That is what timed out test_a_burst_after_a_restart_is_answered_in_order
in CI: a message landing while the previous reply step was still committing
is held, and the next one can land in that gap.

reply now reads the transcript again under the arrival lock before it waits,
as remind already does, and takes another turn for anything new. A message
that lands after that read finds the run still stepping, so its wake is held.

The regression test drives the race deterministically: it fails on a
thirty-second timeout before this change and passes in under a second after.

* reflex-workflow: arm every conversation wait in one step that rereads first

Checking for unread messages in reply was not enough. When reply found one
it took another turn with the earlier wake still held, and the turn that
finally ran that wake found nothing new and armed the wait directly: a
message whose wake was refused while it ran then waited for the reminder.

Every wait is now armed by settle, a step of its own that rereads the
transcript under the arrival lock. reply and a turn with nothing new both
go through it. The regression test now also drives a message into the
turn that runs the stale wake, and fails without this change.

The reminder race test waited on the status, which is set as soon as a wait
is armed; it now waits until no wake is held and no step is running, since
a held wake replaying through settle takes the lock the test holds.

* docs: give Workflows its own top-level sidebar section

Moved out of the State section, between State and Recipes as masenf
suggested, with the guides grouped into Building and Running Workflows.
Single pages are one-child groups, as elsewhere in the sidebar: the index
that opens the active group counts top-level entries that way.

* docs: keep inline code out of link text, which the docs site does not render

* Revert "docs: keep inline code out of link text, which the docs site does not render"

This reverts commit efcdd2e.

* Name this PR's news fragments by its number

* docs: wake also waits for the steps it started to finish

Matches #7385.

* Revert "reflex-workflow: arm every conversation wait in one step that rereads first"

This reverts commit 47588c9.

* Revert "reflex-workflow: answer a message whose wake was refused while a held one ran"

This reverts commit 16cf37e.

* docs(workflows): bring the Workflows docs up to date with main

- Stop registering the workflow base with rx.ModelRegistry.register. Since
  #7797 a registered base turns off detection of the app's other
  DeclarativeBase bases, so reflex db makemigrations would write a revision
  dropping their tables. Explain detection, when registering is needed, and
  point MappedAsDataclass bases (the database docs' default) at
  reflex_workflow.dataclass. Same fix in the package README.
- Describe the held event being released once a worker takes it (#7396).
- Document OpenTelemetry tracing of step attempts (#7635).
- Require Python 3.11 (#7449), spell Cron's default zone as UTC, say wake
  waits for the work to run (#7382), and import rx in the wake example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ESN8DiahHo8P4FLFNr6fHK

* docs(workflows): say which bases Reflex detects, and why registering drops others

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ESN8DiahHo8P4FLFNr6fHK

* docs(reflex-workflow): rewrap the README's Reflex setup paragraph

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ESN8DiahHo8P4FLFNr6fHK

---------

Co-authored-by: Masen Furer <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on deck PRs lined up to review / merge next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants