Skip to content

Python: [Bug]: Workflow checkpoint serialization and deserialization reserved keywords allow overwrite #3225

@TaoChenOSU

Description

@TaoChenOSU

Description

When serializing workflow state to a checkpoint, we use two reserved keywords (__af_dataclass__ and __af_model__) to achieve polymorphic serialization.

However, we don't check for if these reserved keywords are present in objects that neither dataclasses nor Pydantic models. This leads to potential issue during deserialization where we'd mistakenly deserialize a Json into an incorrect type. We also don't check if a class is really a dataclass or a Pydantic model during deserialization.

Implement fixes for:

  1. Do not allow values to contain the reserved keyword during serialization.
  2. Check if a class is really a dataclass or a Pydantic model during deserialization.

Related modules

https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/_workflows/_checkpoint_encoding.py

Package Versions

agent-framework-core

Python Version

No response

Additional Context

No response

Metadata

Metadata

Labels

bugSomething isn't workingpython

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions