Skip to content

Commit 9f04f16

Browse files
committed
small warm_up refactor
1 parent 987b344 commit 9f04f16

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

haystack/components/agents/agent.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,6 @@ def _select_tools(self, tools: ToolsType | list[str] | None = None) -> ToolsType
628628
"tools must be a list of Tool and/or Toolset objects, a Toolset, or a list of tool names (strings)."
629629
)
630630

631-
def _runtime_checks(self) -> None:
632-
"""Warm up the agent if not already warmed up."""
633-
if not self._is_warmed_up:
634-
self.warm_up()
635-
636631
def run( # noqa: PLR0915
637632
self,
638633
messages: list[ChatMessage],
@@ -671,7 +666,8 @@ def run( # noqa: PLR0915
671666
- Any additional keys defined in the `state_schema`.
672667
"""
673668
agent_inputs = {"messages": messages, "streaming_callback": streaming_callback, **kwargs}
674-
self._runtime_checks()
669+
if not self._is_warmed_up:
670+
self.warm_up()
675671

676672
exe_context = self._initialize_fresh_execution(
677673
messages=messages,
@@ -744,7 +740,8 @@ async def run_async( # noqa: PLR0915
744740
- Any additional keys defined in the `state_schema`.
745741
"""
746742
agent_inputs = {"messages": messages, "streaming_callback": streaming_callback, **kwargs}
747-
self._runtime_checks()
743+
if not self._is_warmed_up:
744+
self.warm_up()
748745

749746
exe_context = self._initialize_fresh_execution(
750747
messages=messages,

0 commit comments

Comments
 (0)