diff --git a/haystack/tools/pipeline_tool.py b/haystack/tools/pipeline_tool.py index 0c0b6e1397..2152b5bbc2 100644 --- a/haystack/tools/pipeline_tool.py +++ b/haystack/tools/pipeline_tool.py @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 +import copy from typing import Any, Callable from haystack import AsyncPipeline, Pipeline, SuperComponent, logging @@ -221,7 +222,8 @@ def from_dict(cls, data: dict[str, Any]) -> "PipelineTool": :returns: The deserialized PipelineTool instance. """ - inner_data = data["data"] + # Create a deep copy to avoid mutating the input dictionary + inner_data = copy.deepcopy(data["data"]) is_pipeline_async = inner_data.get("is_pipeline_async", False) pipeline_class = AsyncPipeline if is_pipeline_async else Pipeline pipeline = pipeline_class.from_dict(inner_data["pipeline"])