Skip to content

Python: Fix checkpoint pickling of runtime raw representations - #8023

Merged
Evan Mattson (moonbox3) merged 7 commits into
microsoft:mainfrom
droideronline:fix/checkpoint-raw-representation-pickle
Sep 4, 2026
Merged

Python: Fix checkpoint pickling of runtime raw representations#8023
Evan Mattson (moonbox3) merged 7 commits into
microsoft:mainfrom
droideronline:fix/checkpoint-raw-representation-pickle

Conversation

@droideronline

Copy link
Copy Markdown
Contributor

Motivation & Context

Workflow checkpoint creation fails when A2A responses are present in workflow state. A2A protobuf objects such as a2a_pb2.Part can be retained in framework raw_representation fields, but the generated module is not importable by Python pickle. The workflow continues, but the affected checkpoint is skipped and durable workflow recovery can lose that checkpoint boundary.

This change ensures provider-specific runtime objects do not prevent framework-native workflow state from being persisted.

Description & Review Guide

  • What are the major changes?
    • Add pickle state hooks to SerializationMixin and Content.
    • Exclude runtime-only fields listed in _SHALLOW_COPY_FIELDS, including raw_representation, from pickle state.
    • Restore omitted shallow-copy fields as None after unpickling.
    • Add regression coverage using an intentionally unpickleable raw representation, including nested Content.
  • What is the impact of these changes?
    • A2A protobuf-backed content can be checkpointed without emitting the checkpoint failure warning.
    • Framework-native content, messages, executor state, and workflow state remain persisted.
    • Active-run provider objects remain available; only restored checkpoints omit transient raw representations.
    • This is not a breaking change to the active-run response API.
  • What do you want reviewers to focus on?
    • Confirm that _SHALLOW_COPY_FIELDS is the right source of truth for pickle exclusion.
    • Confirm that restoring runtime-only fields to None is appropriate for checkpoint resume semantics.
    • Review whether the behavior should also be covered by additional checkpoint storage integration tests.

Related Issue

Fixes #8022

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix) — a workflow keeps the label and title prefix in sync automatically.

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 3, 2026
@droideronline
Dineshsuriya D (droideronline) force-pushed the fix/checkpoint-raw-representation-pickle branch from ff2e3fa to 2d028e3 Compare September 3, 2026 07:35
Comment thread python/packages/core/agent_framework/_serialization.py Outdated
Comment thread python/packages/core/agent_framework/_serialization.py Outdated
Comment thread python/packages/core/agent_framework/_types.py Outdated
Comment thread python/packages/core/agent_framework/_serialization.py Outdated
Comment thread python/packages/core/agent_framework/_types.py Outdated
Comment thread python/packages/core/agent_framework/_serialization.py Outdated
auto-merge was automatically disabled September 3, 2026 11:20

Head branch was pushed to by a user without write access

auto-merge was automatically disabled September 4, 2026 06:08

Head branch was pushed to by a user without write access

@moonbox3
Evan Mattson (moonbox3) added this pull request to the merge queue Sep 4, 2026
Merged via the queue into microsoft:main with commit 7f20b32 Sep 4, 2026
37 checks passed
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.

Python: [Bug]: Workflow checkpointing fails on A2A protobuf raw representations

4 participants