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.
This commit is contained in:
Classic298 2026-10-24 21:46:48 +02:00 • committed by GitHub
parent a6cf0b23ab
commit ee7c9ff5c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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