From ee7c9ff5c19d7d8c24c991028b08ff6672c6e653 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 24 Oct 2026 21:46:48 +0200 Subject: [PATCH] fix: tool server tools change their schema on every restart and break prompt caching (#33000) The required parameters of OpenAPI tool server tools, Open Terminal included, were sent to the model in a random order that could change every time Open WebUI restarted. The tool list sits at the start of every prompt, so a different order made every prefix cache on the model side miss, and long chats were processed again from scratch after a restart. The required parameters now keep the order the tool server declares, so the tool list stays identical across restarts. --- backend/open_webui/utils/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index a8e507d383..f523b6ea0d 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -1285,7 +1285,7 @@ def convert_openapi_to_tool_payload(openapi_spec): tool['parameters']['properties'].update(resolved_schema['properties']) if 'required' in resolved_schema: tool['parameters']['required'] = list( - set(tool['parameters']['required'] + resolved_schema['required']) + dict.fromkeys(tool['parameters']['required'] + resolved_schema['required']) ) elif resolved_schema.get('type') == 'array': tool['parameters'] = resolved_schema # special case for array