KEMBAR78
Fix mutable default in ListMemoryConfig by mohiuddin-khan-shiam · Pull Request #6729 · microsoft/autogen · GitHub
Skip to content

Conversation

@mohiuddin-khan-shiam
Copy link
Contributor

Fix mutable default in ListMemoryConfig

ListMemoryConfig used a shared empty list (memory_contents: List[MemoryContent] = []) as its default, causing every ListMemory instance to share the same underlying list. This unexpected state leakage let memories written in one instance silently surface in others, breaking isolation and leading to hard-to-reproduce bugs.
Replaced the mutable default with a safe Pydantic Field(default_factory=list), ensuring each configuration—and thus each ListMemory—gets its own independent list.

T2430514 and others added 2 commits June 29, 2025 18:05
…430514/Downloads/autogen/python/packages/autogen-core/src/autogen_core/memory/_list_memory.py:12:0-18:65)

[ListMemoryConfig](cci:2://file:///c:/Users/T2430514/Downloads/autogen/python/packages/autogen-core/src/autogen_core/memory/_list_memory.py:12:0-18:65) used a shared empty list (`memory_contents: List[MemoryContent] = []`) as its default, causing every [ListMemory](cci:2://file:///c:/Users/T2430514/Downloads/autogen/python/packages/autogen-core/src/autogen_core/memory/_list_memory.py:21:0-171:79) instance to share the same underlying list. This unexpected state leakage let memories written in one instance silently surface in others, breaking isolation and leading to hard-to-reproduce bugs.
Replaced the mutable default with a safe Pydantic `Field(default_factory=list)`, ensuring each configuration—and thus each [ListMemory](cci:2://file:///c:/Users/T2430514/Downloads/autogen/python/packages/autogen-core/src/autogen_core/memory/_list_memory.py:21:0-171:79)—gets its own independent list

Co-Authored-By: S. M. Mohiuddin Khan Shiam <147746955+mohiuddin-khan-shiam@users.noreply.github.com>
Fix mutable default in ListMemoryConfig
@ekzhu
Copy link
Collaborator

ekzhu commented Jun 29, 2025

@mohiuddin-khan-shiam please check our Python developer guide: python/README.md for formatting and running local checks.

@ekzhu ekzhu enabled auto-merge (squash) June 29, 2025 15:16
@ekzhu ekzhu merged commit 2b873a4 into microsoft:main Jun 29, 2025
65 checks passed
@codecov
Copy link

codecov bot commented Jun 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.84%. Comparing base (3c73e08) to head (68bd159).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6729   +/-   ##
=======================================
  Coverage   79.84%   79.84%           
=======================================
  Files         232      232           
  Lines       17513    17513           
=======================================
  Hits        13983    13983           
  Misses       3530     3530           
Flag Coverage Δ
unittests 79.84% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants