Core: Fix #5605 - Trigger values being shared by weights.yaml slots (#5636)

The "+" and "-" trigger operations modify sets/lists in-place, but
triggers could set a value to the same set/list for multiple slots using
weights.yaml.

This fix deep-copies all values set from new (trigger) weights to ensure
that the values do not get shared across multiple slots.
This commit is contained in:
Mysteryem
2025-11-14 20:58:44 +00:00
committed by GitHub
parent 5779dda937
commit a2f8877810

View File

@@ -367,7 +367,10 @@ def update_weights(weights: dict, new_weights: dict, update_type: str, name: str
f" received {type(new_value).__name__}.")
cleaned_weights[option_name] = cleaned_value
else:
cleaned_weights[option_name] = new_weights[option]
# Options starting with + and - may modify values in-place, and new_weights may be shared by multiple slots
# using the same .yaml, so ensure that the new value is a copy.
cleaned_value = copy.deepcopy(new_weights[option])
cleaned_weights[option_name] = cleaned_value
new_options = set(cleaned_weights) - set(weights)
weights.update(cleaned_weights)
if new_options: