Merge pull request #3782 from pipecat-ai/aleix/fix-mutable-default-args-aggregator-pair

Fix mutable default arguments in LLMContextAggregatorPair
This commit is contained in:
Aleix Conchillo Flaqué
2026-02-20 08:02:18 -08:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

1
changelog/3782.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed mutable default arguments in `LLMContextAggregatorPair.__init__()` that could cause shared state across instances.

View File

@@ -1257,8 +1257,8 @@ class LLMContextAggregatorPair:
self,
context: LLMContext,
*,
user_params: LLMUserAggregatorParams = LLMUserAggregatorParams(),
assistant_params: LLMAssistantAggregatorParams = LLMAssistantAggregatorParams(),
user_params: Optional[LLMUserAggregatorParams] = None,
assistant_params: Optional[LLMAssistantAggregatorParams] = None,
):
"""Initialize the LLM context aggregator pair.
@@ -1267,6 +1267,8 @@ class LLMContextAggregatorPair:
user_params: Parameters for the user context aggregator.
assistant_params: Parameters for the assistant context aggregator.
"""
user_params = user_params or LLMUserAggregatorParams()
assistant_params = assistant_params or LLMAssistantAggregatorParams()
self._user = LLMUserAggregator(context, params=user_params)
self._assistant = LLMAssistantAggregator(context, params=assistant_params)