fix: preserve TextMentionTermination.sources across serialization round-trip#7933
Open
HumphreySun98 wants to merge 1 commit into
Open
fix: preserve TextMentionTermination.sources across serialization round-trip#7933HumphreySun98 wants to merge 1 commit into
HumphreySun98 wants to merge 1 commit into
Conversation
…nd-trip `TextMentionTermination` accepts a `sources` argument that restricts which message sources are checked, but `TextMentionTerminationConfig` only stored `text`, and `_to_config`/`_from_config` only serialized/restored `text`. As a result, a condition configured with `sources` silently lost that restriction after a `dump_component()` / `load_component()` round-trip and then fired on any source — a behavior change on save/load. The sibling `SourceMatchTermination` already round-trips its `sources` field correctly. Add `sources` to the config model and serialize/restore it in `_to_config`/`_from_config`, with a regression test covering both the sources-restricted and unrestricted cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ErenAta16
approved these changes
Jul 11, 2026
ErenAta16
left a comment
There was a problem hiding this comment.
Ran the round-trip test — passes for both the sources-restricted and unrestricted cases. Worth noting this brings TextMentionTermination in line with SourceMatchTermination, which the PR description says already round-trips sources correctly — so this was an inconsistency between two conceptually similar termination conditions rather than a one-off oversight, which matches what I'd expect from how these config classes tend to drift when a field gets added to the runtime class but not mirrored into _to_config/_from_config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
TextMentionTerminationaccepts asourcesargument that restricts whichmessage sources are checked for the termination text:
However
TextMentionTerminationConfigonly storedtext, and_to_config/_from_configonly serialized/restoredtext. So a conditionconfigured with
sourcessilently loses that restriction after a declarativedump_component()/load_component()round-trip, and the reloaded conditionthen fires on any source (including
useror other agents) — a behaviorchange on save/load.
The sibling
SourceMatchTerminationalready round-trips itssourcesfieldcorrectly (and the existing declarative test asserts it), which makes this an
inconsistency rather than an intentional omission.
This PR adds
sourcestoTextMentionTerminationConfigand serializes/restoresit in
_to_config/_from_config, with a regression test covering both thesources-restricted and unrestricted cases.
Related issue number
N/A — found during review. Fixes a serialization round-trip data loss;
SourceMatchTerminationis the correct reference behavior.Checks
ruff,mypy, and the relevantpytestlocally).