[BREAKING] Python: Refactor SharedState to State with sync methods and superstep caching#3667
Merged
TaoChenOSU merged 9 commits intomicrosoft:mainfrom Feb 5, 2026
Merged
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a breaking refactoring of workflow state management, renaming SharedState to State, converting all async methods to sync, and implementing superstep caching semantics to align with .NET behavior.
Changes:
- Renamed
SharedStateclass toStateand file_shared_state.pyto_state.py - Converted all state methods from async to sync (removing asyncio.Lock)
- Implemented superstep caching: writes go to pending buffer, committed at boundaries via
commit() - Added
get(key, default=None)API andhas(key)method - Renamed
WorkflowCheckpoint.shared_state→WorkflowCheckpoint.state - Updated all references across codebase (workflow context, runner, executors, tests, samples)
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
_state.py |
New State class with sync methods and superstep caching implementation |
_workflow.py |
Updated to use State with commit() call after kwargs initialization |
_runner.py |
Integrated commit() at superstep boundaries |
_workflow_context.py |
Changed to sync get_state/set_state methods |
_checkpoint.py |
Renamed shared_state field to state |
__init__.py |
Updated exports (but State still exported - should be removed) |
| Test files | Updated all test mocks and assertions to use State |
| Sample files | Updated comments and documentation references |
| Frontend | Updated TypeScript interfaces and references |
python/packages/devui/frontend/src/components/features/workflow/checkpoint-info-modal.tsx
Outdated
Show resolved
Hide resolved
python/samples/getting_started/workflows/state-management/state_with_agents.py
Show resolved
Hide resolved
dmytrostruk
approved these changes
Feb 4, 2026
TaoChenOSU
approved these changes
Feb 4, 2026
python/packages/core/agent_framework/_workflows/_agent_executor.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_workflow_context.py
Outdated
Show resolved
Hide resolved
TaoChenOSU
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.
Motivation and Context
Refactors the workflow state management system with breaking changes:
SharedState->Stateclass and_shared_state.py->_state.pycommit(), which is now consistent with the .NET behavior.get(key, default=None)API that returns default instead of raising KeyErrorhas(key)method for existence checksWorkflowCheckpoint.shared_state→WorkflowCheckpoint.stateStatefrom public exports (internal implementation detail)Breaking Changes
SharedStateStatectx.shared_statectx.stateawait ctx.get_shared_state(key)ctx.get_state(key, default=None)await ctx.set_shared_state(key, value)ctx.set_state(key, value)checkpoint.shared_statecheckpoint.stateDescription
Contribution Checklist