SIGN IN SIGN UP
microsoft / autogen UNCLAIMED

A programming framework for agentic AI

0 0 104 Python

Fix mutable default in ListMemoryConfig (#6729)

### Fix mutable default in
[ListMemoryConfig](cci:2://file:///c:/Users/T2430514/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: T2430514 <t2430514@gmail.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
S
S. M. Mohiuddin Khan Shiam committed
2b873a483b3a2523277725fe165c98862f97aa4a
Parent: 3c73e08
Committed by GitHub <noreply@github.com> on 6/29/2025, 3:23:29 PM