From 52a06bd48aff34fb2211aac2879f0cd028129267 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 26 Mar 2026 18:22:14 -0500 Subject: [PATCH] refac --- backend/open_webui/utils/middleware.py | 7 ++++++- backend/open_webui/utils/tools.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index d98d6901cc..b64febd673 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2607,12 +2607,17 @@ async def process_chat_payload(request, form_data, user, metadata, model): # so system terminals work even when no other tools are selected) if terminal_id: try: - terminal_tools, system_prompt = await get_terminal_tools( + terminal_result = await get_terminal_tools( request, terminal_id, user, extra_params, ) + if isinstance(terminal_result, tuple): + terminal_tools, system_prompt = terminal_result + else: + terminal_tools = terminal_result + system_prompt = None if terminal_tools: tools_dict = {**tools_dict, **terminal_tools} if system_prompt: diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 210ff24085..226830a1fa 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -956,7 +956,7 @@ async def get_terminal_tools( terminal_id: str, user: UserModel, extra_params: dict, -) -> tuple[dict[str, dict], Optional[str]]: +) -> dict[str, dict] | tuple[dict[str, dict], Optional[str]]: """Resolve tools for a terminal server identified by terminal_id. - Finds the connection in TERMINAL_SERVER_CONNECTIONS