mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-14 04:08:46 +00:00
fix: automations never get memory tools or saved memories
Chats started by an automation had no memory: the model got no memory tools and none of the owner's saved memories, even with Memory turned on, so asking it to list memories failed with a "Tool not found" error. Replying in that same chat worked, because the web UI passes the owner's Memory setting along with every message and automations did not. Automations that post into a chat now follow the owner's Memory setting like the web UI does, while the admin's Memories switch, the Memories permission and the model's Memory capability still apply. Channel automations still run without memory, so the owner's saved memories never show up in a channel other people can read. Fixes #32337
This commit is contained in:
parent
93d25dbe3b
commit
6763f767b9
1 changed files with 14 additions and 1 deletions
|
|
@ -486,9 +486,22 @@ async def execute_automation(app, automation: AutomationModel) -> None:
|
|||
room=f'user:{automation.user_id}',
|
||||
)
|
||||
|
||||
# Same fallback chain the chat UI uses to decide whether to send features.memory.
|
||||
ui_settings = (user.settings.ui if user.settings else None) or {}
|
||||
memory_setting = ui_settings.get('memory')
|
||||
if memory_setting is None:
|
||||
default_interface_settings = await Config.get('ui.default_interface_settings') or {}
|
||||
memory_setting = default_interface_settings.get('memory')
|
||||
if memory_setting is None:
|
||||
memory_setting = await Config.get('memories.enable')
|
||||
|
||||
model_defaults = await _resolve_model_defaults(app, model_id)
|
||||
if memory_setting:
|
||||
model_defaults['features'] = {**model_defaults.get('features', {}), 'memory': True}
|
||||
|
||||
# Build the same payload the frontend sends to /api/chat/completions
|
||||
form_data = {
|
||||
**await _resolve_model_defaults(app, model_id),
|
||||
**model_defaults,
|
||||
'model': model_id,
|
||||
'messages': [{'role': 'user', 'content': prompt}],
|
||||
'stream': True,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue