[GH-ISSUE #14378] bug: global filter's __init__ gets called multiple times #32757

Closed
opened 2026-04-25 06:37:10 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @suurt8ll on GitHub (May 27, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/14378

Check Existing Issues

  • I have searched the existing issues and discussions.

Problem Description

Filters that have been set to "global" started to behave weirdly after the reent 0.6.11 update. Non-global filters don't have this issue. The trigger seems to be the moment when front-end fetches the model list from the backend. This is how the problem can be reproduced:

Plugin Code

"""
title: Example Filter
author: open-webui
author_url: https://github.com/open-webui
funding_url: https://github.com/open-webui
version: 0.1
"""


class Filter:

    def __init__(self):
        print("GLOBAL FILTER __init__ CALLED.")

Console Logs

2025-05-27 09:50:23.776 | INFO     | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "POST /api/v1/utils/code/format HTTP/1.1" 200 - {}
2025-05-27 09:50:23.829 | INFO     | open_webui.utils.plugin:install_frontmatter_requirements:185 - No requirements found in frontmatter. - {}
2025-05-27 09:50:23.829 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:23.845 | INFO     | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "POST /api/v1/functions/id/example_filter/update HTTP/1.1" 200 - {}
2025-05-27 09:50:23.856 | INFO     | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "GET /api/v1/functions/ HTTP/1.1" 200 - {}
2025-05-27 09:50:23.864 | INFO     | open_webui.routers.openai:get_all_models:391 - get_all_models() - {}
2025-05-27 09:50:24.576 | INFO     | open_webui.routers.ollama:get_all_models:323 - get_all_models() - {}
2025-05-27 09:50:24.636 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.645 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.651 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.657 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.660 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.663 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.665 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.667 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.669 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.672 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.675 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.677 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.679 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.681 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.684 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.686 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.688 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.691 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.693 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.695 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.697 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.699 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.701 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.704 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.706 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.709 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.711 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.713 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.715 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.717 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.719 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.722 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {}
GLOBAL FILTER __init__ CALLED.
2025-05-27 09:50:24.725 | INFO     | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "GET /api/models HTTP/1.1" 200 - {}

Desired Solution you'd like

Global filters get loaded only once.

Alternatives Considered

No response

Additional Context

  • Version: v0.6.11
  • Set-up command: uv pip install .
  • Run command: bash start.sh
Originally created by @suurt8ll on GitHub (May 27, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/14378 ### Check Existing Issues - [x] I have searched the existing issues and discussions. ### Problem Description Filters that have been set to "global" started to behave weirdly after the reent 0.6.11 update. Non-global filters don't have this issue. The trigger seems to be the moment when front-end fetches the model list from the backend. This is how the problem can be reproduced: ***Plugin Code*** ```python """ title: Example Filter author: open-webui author_url: https://github.com/open-webui funding_url: https://github.com/open-webui version: 0.1 """ class Filter: def __init__(self): print("GLOBAL FILTER __init__ CALLED.") ``` ***Console Logs*** ``` 2025-05-27 09:50:23.776 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "POST /api/v1/utils/code/format HTTP/1.1" 200 - {} 2025-05-27 09:50:23.829 | INFO | open_webui.utils.plugin:install_frontmatter_requirements:185 - No requirements found in frontmatter. - {} 2025-05-27 09:50:23.829 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:23.845 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "POST /api/v1/functions/id/example_filter/update HTTP/1.1" 200 - {} 2025-05-27 09:50:23.856 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "GET /api/v1/functions/ HTTP/1.1" 200 - {} 2025-05-27 09:50:23.864 | INFO | open_webui.routers.openai:get_all_models:391 - get_all_models() - {} 2025-05-27 09:50:24.576 | INFO | open_webui.routers.ollama:get_all_models:323 - get_all_models() - {} 2025-05-27 09:50:24.636 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.645 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.651 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.657 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.660 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.663 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.665 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.667 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.669 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.672 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.675 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.677 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.679 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.681 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.684 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.686 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.688 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.691 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.693 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.695 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.697 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.699 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.701 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.704 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.706 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.709 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.711 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.713 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.715 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.717 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.719 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.722 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_example_filter - {} GLOBAL FILTER __init__ CALLED. 2025-05-27 09:50:24.725 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:38732 - "GET /api/models HTTP/1.1" 200 - {} ``` ### Desired Solution you'd like Global filters get loaded only once. ### Alternatives Considered _No response_ ### Additional Context - Version: `v0.6.11` - Set-up command: `uv pip install .` - Run command: `bash start.sh`
Author
Owner

@dynm commented on GitHub (May 27, 2025):

b8e16211b9/backend/open_webui/utils/models.py (L241-L244)

Maybe this function caused the problem, and the /api/models is very slow now.

<!-- gh-comment-id:2911395353 --> @dynm commented on GitHub (May 27, 2025): https://github.com/open-webui/open-webui/blob/b8e16211b9d207e91b7da0a2055a7a679c05b6ce/backend/open_webui/utils/models.py#L241-L244 Maybe this function caused the problem, and the /api/models is very slow now.
Author
Owner

@EntropyYue commented on GitHub (May 27, 2025):

I observed that the non-global filter also reloaded multiple, the phenomenon is repeated output

2025-05-27 09:22:03.045 | INFO     | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_test_func - {}

And the streaming slows down

<!-- gh-comment-id:2911835862 --> @EntropyYue commented on GitHub (May 27, 2025): I observed that the non-global filter also reloaded multiple, the phenomenon is repeated output ``` 2025-05-27 09:22:03.045 | INFO | open_webui.utils.plugin:load_function_module_by_id:147 - Loaded module: function_test_func - {} ``` And the streaming slows down
Author
Owner

@EntropyYue commented on GitHub (May 27, 2025):

If someone finds the streaming slows down, please temporarily disable all functions

<!-- gh-comment-id:2911848546 --> @EntropyYue commented on GitHub (May 27, 2025): If someone finds the streaming slows down, please temporarily disable all functions
Author
Owner

@hurxxxx commented on GitHub (May 27, 2025):

#14392
I hope this resolves issue

<!-- gh-comment-id:2911875854 --> @hurxxxx commented on GitHub (May 27, 2025): #14392 I hope this resolves issue
Author
Owner

@tjbck commented on GitHub (May 27, 2025):

Addressed

<!-- gh-comment-id:2912075493 --> @tjbck commented on GitHub (May 27, 2025): Addressed
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#32757