From 88bbe4e1d7ddb78c99d8306ca5d8587450a77907 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 28 Aug 2026 18:22:23 +0200 Subject: [PATCH] perf: skip pipeline filter session setup when no filters exist (#29146) process_pipeline_inlet_filter() and its outlet counterpart construct and tear down an aiohttp ClientSession, with its own connector and cookie jar, on every chat completion and every task generation request just to iterate an empty filter list. On deployments without pipelines, which is the default, that is wasted setup on every message. Both functions now return the payload untouched before the session is created when there is nothing to call. The per-call saving is small, a few microseconds of object construction per request on the pinned aiohttp; the point is that requests stop paying setup for a feature that is not configured. --- backend/open_webui/routers/pipelines.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/open_webui/routers/pipelines.py b/backend/open_webui/routers/pipelines.py index 827fadf7c9..753c9fc77f 100644 --- a/backend/open_webui/routers/pipelines.py +++ b/backend/open_webui/routers/pipelines.py @@ -69,6 +69,9 @@ async def process_pipeline_inlet_filter(request, payload, user, models): if 'pipeline' in model: sorted_filters.append(model) + if not sorted_filters: + return payload + async with aiohttp.ClientSession(trust_env=True) as session: for filter in sorted_filters: urlIdx = filter.get('urlIdx') @@ -132,6 +135,9 @@ async def process_pipeline_outlet_filter(request, payload, user, models): if 'pipeline' in model: sorted_filters = [model] + sorted_filters + if not sorted_filters: + return payload + async with aiohttp.ClientSession(trust_env=True) as session: for filter in sorted_filters: urlIdx = filter.get('urlIdx')