From 2c8fa823f3f59e56be65d075c2a32099ad082037 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:11:30 +0100 Subject: [PATCH] feat: permission to limit sub-agents to specific users and groups (#34040) Sub-agents could only be switched on or off for the whole instance, so once they were on every user could spawn them and an admin had no way to keep the extra model usage to a pilot group. The user permissions now have a Sub-agents switch under Features, both in the default permissions and in each group, next to Memories and working the same way. Users without the permission no longer get the sub-agent tool in their chats, nor the timer tool that is part of the same feature. Admins are not restricted by it, and with sub-agents off in Admin Settings nobody gets them, admins included. The permission is on by default, so existing instances behave as before until an admin turns it off; the default can also be set with the USER_PERMISSIONS_FEATURES_SUBAGENTS environment variable. Closes #34038 --- backend/open_webui/config.py | 3 +++ backend/open_webui/routers/users.py | 1 + backend/open_webui/utils/tools.py | 1 + .../admin/Users/Groups/Permissions.svelte | 18 ++++++++++++++++++ src/lib/constants/permissions.ts | 1 + src/lib/i18n/locales/en-US/translation.json | 1 + 6 files changed, 25 insertions(+) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index ad77ed9537..b6c9d27683 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1964,6 +1964,8 @@ USER_PERMISSIONS_FEATURES_API_KEYS = os.getenv('USER_PERMISSIONS_FEATURES_API_KE USER_PERMISSIONS_FEATURES_MEMORIES = os.getenv('USER_PERMISSIONS_FEATURES_MEMORIES', 'True').lower() == 'true' +USER_PERMISSIONS_FEATURES_SUBAGENTS = os.getenv('USER_PERMISSIONS_FEATURES_SUBAGENTS', 'True').lower() == 'true' + USER_PERMISSIONS_FEATURES_AUTOMATIONS = os.getenv('USER_PERMISSIONS_FEATURES_AUTOMATIONS', 'False').lower() == 'true' USER_PERMISSIONS_FEATURES_CALENDAR = os.getenv('USER_PERMISSIONS_FEATURES_CALENDAR', 'True').lower() == 'true' @@ -2052,6 +2054,7 @@ DEFAULT_USER_PERMISSIONS = { 'image_generation': USER_PERMISSIONS_FEATURES_IMAGE_GENERATION, 'code_interpreter': USER_PERMISSIONS_FEATURES_CODE_INTERPRETER, 'memories': USER_PERMISSIONS_FEATURES_MEMORIES, + 'subagents': USER_PERMISSIONS_FEATURES_SUBAGENTS, 'automations': USER_PERMISSIONS_FEATURES_AUTOMATIONS, 'calendar': USER_PERMISSIONS_FEATURES_CALENDAR, 'webhooks': USER_PERMISSIONS_FEATURES_USER_WEBHOOKS, diff --git a/backend/open_webui/routers/users.py b/backend/open_webui/routers/users.py index 7c810d7b92..1c55b77f01 100644 --- a/backend/open_webui/routers/users.py +++ b/backend/open_webui/routers/users.py @@ -265,6 +265,7 @@ class FeaturesPermissions(BaseModel): image_generation: bool = True code_interpreter: bool = True memories: bool = True + subagents: bool = True automations: bool = False calendar: bool = True webhooks: bool = False diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 37c4aefa1e..55b594876c 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -798,6 +798,7 @@ async def get_builtin_tools( and getattr(request.state, 'internal', False) is not True and getattr(request.state, 'direct', False) is not True and not is_temporary_chat_id(metadata.get('chat_id')) + and await has_user_permission('subagents') ): builtin_functions.extend([delegate_task, timer]) diff --git a/src/lib/components/admin/Users/Groups/Permissions.svelte b/src/lib/components/admin/Users/Groups/Permissions.svelte index b5255f6b20..336c7fbd9d 100644 --- a/src/lib/components/admin/Users/Groups/Permissions.svelte +++ b/src/lib/components/admin/Users/Groups/Permissions.svelte @@ -1182,6 +1182,24 @@ {/if} + {#if $config?.features?.enable_subagents} +