Python: Prevent workflow checkpoints from being mutated outside of storage implementations - #7847
Python: Prevent workflow checkpoints from being mutated outside of storage implementations#7847Tao Chen (TaoChenOSU) wants to merge 3 commits into
Conversation
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Strengthens Python workflow checkpoint isolation across state and storage boundaries.
Changes:
- Deep-copies state during export and restoration.
- Returns copied checkpoints from in-memory storage.
- Adds state, runner, and storage conformance tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/agent_framework/_workflows/_state.py |
Adds deep-copy state boundaries. |
python/packages/core/agent_framework/_workflows/_checkpoint.py |
Documents ownership and copies in-memory reads. |
python/packages/core/tests/workflow/test_state.py |
Tests nested state isolation. |
python/packages/core/tests/workflow/test_runner.py |
Tests storage-less restoration isolation. |
python/packages/core/tests/workflow/test_checkpoint_storage_conformance.py |
Adds backend ownership conformance tests. |
python/packages/core/agent_framework/_workflows/_agent.py |
Formatting-only change. |
python/packages/core/agent_framework/_harness/_loop.py |
Formatting-only changes. |
python/packages/core/tests/core/test_harness_loop.py |
Import-order-only change. |
Suppressed comments (1)
python/packages/core/agent_framework/_workflows/_state.py:121
- The same custom
__deepcopy__behavior means restore isolation is still incomplete: importing a checkpoint containingContent/otherSerializationMixinvalues copiesraw_representationby reference, so later live-state mutation can mutate the caller's checkpoint. Please use a checkpoint-specific clone/sanitization policy rather than relying on genericdeepcopyfor the restoration boundary.
self._committed.update(copy.deepcopy(state))
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): a5062c6c7bc2
Model: gpt-5.6-sol
Overview
The review found 2 verified inline finding(s).
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 2 files. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/_workflows/_checkpoint.py, python/packages/core/agent_framework/_workflows/_state.py
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: Findings reported
Scope: 2 net-new commit(s): 588d16565ae6, ae8cd879229b
Model: gpt-5.6-sol
Overview
The review found 2 verified inline finding(s).
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/_workflows/_state.py
Motivation & Context
Closes #7683 and #7685
Supersedes #7697, #7712, #7830, #7848
Description & Review Guide
Related Issue
Fixes #7683, #7685
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.