microsoft / microsoft/agent-framework

Python: checkpoints flatten dict subclasses (defaultdict/Counter/OrderedDict become plain dict)

Open Beginner friendly
#8,517 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

python triage
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.