TextMentionTermination(sources=...) drops sources on dump_component / load_component
Describe the bug
TextMentionTermination(..., sources=[...]) scopes which speakers can trigger the stop text (see #4807). On dump_component / load_component, sources is omitted from the config, so after restore the filter silently matches any source — including the user prompt that was supposed to be ignored.
To Reproduce
import asyncio
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.messages import TextMessage
async def main() -> None:
t = TextMentionTermination("TERMINATE", sources=["writer"])
assert await t([TextMessage(content="please TERMINATE", source="user")]) is None
await t.reset()
assert await t([TextMessage(content="TERMINATE", source="writer")]) is not None
cfg = t.dump_component()
print(cfg.config) # {'text': 'TERMINATE'} — no sources
t2 = TextMentionTermination.load_component(cfg)
stop = await t2([TextMessage(content="please TERMINATE now", source="user")])
assert stop is not None # BUG: user message now terminates
asyncio.run(main())Also reproduced when nested in TextMentionTermination(...) | MaxMessageTermination(5): nested dumped config still only has text.
Expected behavior
Config includes sources; restore keeps sources=["writer"]; user messages containing the phrase do not stop the run.
Actual behavior
TextMentionTerminationConfig only serializes text. _sources becomes None after load, so the filter widens to all speakers.
Environment
autogen-agentchat0.7.5- Python 3.13
Additional context
This makes declarative save/load unsafe for any team that relies on sources to avoid premature stop from user text.
Source: microsoft/autogen