Add random seed access and callback methods to temporalio.workflow#1320
Merged
tconley1428 merged 4 commits intomainfrom Feb 5, 2026
Merged
Add random seed access and callback methods to temporalio.workflow#1320tconley1428 merged 4 commits intomainfrom
tconley1428 merged 4 commits intomainfrom
Conversation
This commit adds three new methods to temporalio.workflow to provide access to and control over the workflow's random seed: 1. workflow.random_seed() - Returns the current random seed value from core 2. workflow.register_random_seed_callback() - Registers callbacks for seed changes 3. workflow.new_random() - Creates an auto-reseeded Random instance These methods enable workflows to: - Access the current deterministic random seed - React to seed changes during workflow resets/replays - Create additional random number generators that stay synchronized The implementation includes: - Abstract methods in _Runtime class - Concrete implementation in _WorkflowInstanceImpl - Proper callback invocation during seed updates - Comprehensive test coverage with workflow reset scenarios - Full type safety and documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
THardy98
reviewed
Feb 5, 2026
THardy98
approved these changes
Feb 5, 2026
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.
Summary
workflow.random_seed()to get current random seed from coreworkflow.register_random_seed_callback()to register for seed change notificationsworkflow.new_random()to create auto-reseeded Random instancesChanges
This PR adds three new methods to
temporalio.workflowthat provide access to and control over the workflow's random seed:workflow.random_seed()- Returns the current random seed value from coreworkflow.register_random_seed_callback(callback)- Registers callbacks that get invoked when the random seed changes (e.g., during workflow resets)workflow.new_random()- Creates a new Random instance that automatically reseeds itself when the workflow seed changesImplementation Details
_Runtimeclass inworkflow.py_WorkflowInstanceImplclass_apply_update_random_seedto invoke registered callbacksUse Cases
These methods enable workflows to:
Test Plan
Fixes #1319
🤖 Generated with Claude Code