microsoft / microsoft/agent-framework
Python: checkpoints flatten dict subclasses (defaultdict/Counter/OrderedDict become plain dict)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
Description
### Motivation & Context
workflow checkpoint state that contains dict subclasses (defaultdict, Counter, OrderedDict) loses its type through a save/load round-trip: it comes back as a plain dict. the encode path uses isinstance(value, dict) and reconstructs a plain dict on decode, even though the module documents full python object fidelity and the unpickler allowlist already covers collections types.
workflows that resume from a checkpoint crash or silently change behavior when their state was a defaultdict or Counter (missing-key defaulting, counter arithmetic).
### Reproduction
```python
from collections import Counter
# executor state: {"counts": Counter({"a": 2})}
# save via FileCheckpointStorage, then load:
type(state["counts"]) # dict, not Counter
```
new tests in the PR build the round-trip and assert the subclass survives.
### Expected behavior
dict subclasses round-trip with their type intact.
env: python main
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at FileCheckpointStorage and trace the checkpoint encode/decode path, then review the existing unpickler allowlist for collections types. Run the checkpoint round-trip tests and add coverage showing defaultdict, Counter, and OrderedDict retain their types after save and load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100