Skip to content

Python: fix(workflows): preserve scalar subclasses and IntEnum in checkpoint encoding - #8693

Closed
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/checkpoint-encoding-scalar-subclasses
Closed

Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/checkpoint-encoding-scalar-subclasses

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

In _checkpoint_encoding.py, _encode was using isinstance(value, _JSON_NATIVE_TYPES) to determine which scalars pass through directly into JSON. Because IntEnum, StrEnum, and custom scalar subclasses inherit from int or str, isinstance evaluates to True for them.

Consequently, workflow states holding an IntEnum had their types stripped and serialized as raw integers, losing the specific enum or subclass type upon deserialization. This was inconsistent with collection handling in the same file, where type(value) is dict and type(value) is list are checked specifically to preserve subclass fidelity.

This PR updates the scalar check to type(value) in _JSON_NATIVE_TYPES so only exact primitive types bypass pickling, ensuring scalar subclasses and IntEnums retain their class identity on decode. I also added unit tests in test_checkpoint_encode.py.

…encoding

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 23, 2026
@github-actions github-actions Bot changed the title fix(workflows): preserve scalar subclasses and IntEnum in checkpoint encoding Python: fix(workflows): preserve scalar subclasses and IntEnum in checkpoint encoding Sep 23, 2026
@eavanvalkenburg

Copy link
Copy Markdown
Member

Thank you for proposing this change. I am closing this PR for now because it has no linked issue, and I could not find an issue covering this specific problem. Our contribution guidelines ask contributors to create or reuse an issue and discuss the approach before nontrivial changes (with an exception for trivial changes). The repository PR template asks for Motivation & Context, Description & Review Guide, a Related Issue linked with a closing keyword such as Fixes #123, and the contribution checklist; it notes that PRs without an issue link may be closed. This description does not follow that template. Please open or identify an issue, agree on the approach with the maintainers, then submit an updated PR using the template and linking the issue. Thanks.

This branch was previously deployed

1 inactive deployment
github-app-auth — c13488b9 Deployed Sep 23, 2026 by ManoharPaturi via team_check #5164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants