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
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-11 10:11:30 +09:00
1 parent a3aa9a40d4
commit 2c8fa823f3
6 files changed
+25

No files matched your search

+3
View File
@@ -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,
+1
View File
@@ -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
+1
View File
@@ -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])
@@ -1182,6 +1182,24 @@
</div>
{/if}
{#if $config?.features?.enable_subagents}
<div class="flex flex-col w-full">
<div class="flex w-full justify-between my-1">
<div class=" self-center text-xs font-normal">
{$i18n.t('Sub-agents')}
</div>
<Switch bind:state={permissions.features.subagents} ariaLabel={$i18n.t('Sub-agents')} />
</div>
{#if defaultPermissions?.features?.subagents && !permissions.features.subagents}
<div>
<div class="text-xs text-gray-500">
{$i18n.t('This is a default user permission and will remain enabled.')}
</div>
</div>
{/if}
</div>
{/if}
{#if $config?.features?.enable_automations}
<div class="flex flex-col w-full">
<Tooltip
+1
View File
@@ -72,6 +72,7 @@ export const DEFAULT_PERMISSIONS = {
image_generation: true,
code_interpreter: true,
memories: true,
subagents: true,
automations: false,
calendar: true,
webhooks: false
@@ -4121,6 +4121,7 @@
"Strikethrough": "",
"Su_day_of_week": "",
"Sub-agent": "Sub-agent",
"Sub-agents": "",
"Submit": "",
"Submit answers": "",
"Submit question": "",