Skip to content

Commit 427c8f2

Browse files
authored
fix: Make experimental Agent compatible with Haystack main and Haystack 2.19 (#393)
* Make experimental Agent compatible with Haystack main and Haystack 2.19 * Fix linting * Add dev comment
1 parent b2abe54 commit 427c8f2

File tree

1 file changed

+15
-2
lines changed
  • haystack_experimental/components/agents

1 file changed

+15
-2
lines changed

haystack_experimental/components/agents/agent.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# pylint: disable=wrong-import-order,wrong-import-position,ungrouped-imports
66
# ruff: noqa: I001
77

8+
import inspect
89
from dataclasses import dataclass
910
from typing import Any, Optional, Union
1011

@@ -285,7 +286,13 @@ def run( # noqa: PLR0915
285286
"snapshot": snapshot,
286287
**kwargs,
287288
}
288-
self._runtime_checks(break_point=break_point, snapshot=snapshot)
289+
# The PR https://github.com/deepset-ai/haystack/pull/9987 removed the unused snapshot parameter from
290+
# _runtime_checks. This change will be released in Haystack 2.20.0.
291+
# To maintain compatibility with Haystack 2.19 we check the number of parameters and call accordingly.
292+
if len(inspect.signature(self._runtime_checks).parameters) == 2:
293+
self._runtime_checks(break_point, snapshot)
294+
else:
295+
self._runtime_checks(break_point) # type: ignore[call-arg] # pylint: disable=no-value-for-parameter
289296

290297
if snapshot:
291298
exe_context = self._initialize_from_snapshot(
@@ -472,7 +479,13 @@ async def run_async(
472479
"snapshot": snapshot,
473480
**kwargs,
474481
}
475-
self._runtime_checks(break_point=break_point, snapshot=snapshot)
482+
# The PR https://github.com/deepset-ai/haystack/pull/9987 removed the unused snapshot parameter from
483+
# _runtime_checks. This change will be released in Haystack 2.20.0.
484+
# To maintain compatibility with Haystack 2.19 we check the number of parameters and call accordingly.
485+
if len(inspect.signature(self._runtime_checks).parameters) == 2:
486+
self._runtime_checks(break_point, snapshot)
487+
else:
488+
self._runtime_checks(break_point) # type: ignore[call-arg] # pylint: disable=no-value-for-parameter
476489

477490
if snapshot:
478491
exe_context = self._initialize_from_snapshot(

0 commit comments

Comments
 (0)