mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: sub-agents in folder chats are not limited to the folder's knowledge
In a chat inside a folder with knowledge attached, the chat only searches the folder's knowledge, but a sub-agent it started could list and search every knowledge base the user can read. Sub-agents now get the folder's knowledge like the chat that started them. They already receive the folder's system prompt as part of the chat's instructions, so it is not added a second time. Fixes #31569
This commit is contained in:
parent
176d31d1db
commit
b5db2eca7f
2 changed files with 5 additions and 1 deletions
|
|
@ -2585,7 +2585,8 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
folder = None
|
||||
|
||||
if folder and folder.data:
|
||||
if 'system_prompt' in folder.data:
|
||||
# A sub-agent already gets it in the parent's system prompt
|
||||
if 'system_prompt' in folder.data and not metadata.get('internal'):
|
||||
form_data = await apply_system_prompt_to_body(folder.data['system_prompt'], form_data, metadata, user)
|
||||
if 'files' in folder.data:
|
||||
if metadata.get('params', {}).get('function_calling') == 'legacy':
|
||||
|
|
|
|||
|
|
@ -314,6 +314,7 @@ async def delegate(
|
|||
and await Config.get('code_interpreter.engine', 'pyodide') != 'jupyter'
|
||||
):
|
||||
features.pop('code_interpreter')
|
||||
folder_id = await Chats.get_chat_folder_id(parent_chat_id, user_data['id']) or metadata.get('folder_id')
|
||||
run = {
|
||||
'model_id': metadata.get('model_id') or (metadata.get('model') or {}).get('id'),
|
||||
'session_id': metadata.get('session_id'),
|
||||
|
|
@ -327,6 +328,7 @@ async def delegate(
|
|||
'files': copy.deepcopy(metadata.get('files') or []),
|
||||
'variables': copy.deepcopy(metadata.get('variables') or {}),
|
||||
'direct': bool(metadata.get('direct')),
|
||||
'folder_id': folder_id,
|
||||
}
|
||||
if not run.get('model_id'):
|
||||
return 'Error: model context is required.'
|
||||
|
|
@ -479,6 +481,7 @@ async def delegate(
|
|||
'features': run.get('features') or {},
|
||||
'files': run.get('files') or [],
|
||||
'variables': run.get('variables') or {},
|
||||
'folder_id': run.get('folder_id'),
|
||||
}
|
||||
if run.get('terminal_id'):
|
||||
form_data['terminal_id'] = run['terminal_id']
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue