mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
fix: a folder's instruction file is left out when it and the home AGENTS.md fit 32 KiB together (#35564)
The 32 KiB limit for AGENTS.md files counted the heading added in front of the one in the machine's home folder as if it were file content. A home file and a folder's AGENTS.md or CLAUDE.md that together are exactly 32 KiB therefore lost the folder's instructions, while a single 32 KiB home file was accepted. The limit now counts only the files themselves, the same way for one file and for two. Fixes #35559
This commit is contained in:
1 parent
2026de4bcb
commit
b6317157f3
1 file changed
+4
-2
@@ -907,6 +907,7 @@ async def get_machine_agents_md(request, user, metadata: dict, extra_params: dic
|
||||
if not isinstance(home, str) or not (posixpath.isabs(home) or ntpath.isabs(home)):
|
||||
return None
|
||||
contents = []
|
||||
total_bytes = 0
|
||||
candidates = [[home, ('AGENTS.md',)]]
|
||||
directory = await get_chat_folder_directory(metadata)
|
||||
if directory and directory != home:
|
||||
@@ -918,10 +919,11 @@ async def get_machine_agents_md(request, user, metadata: dict, extra_params: dic
|
||||
content = data.get('content') if isinstance(data, dict) else None
|
||||
if not isinstance(content, str) or not content.strip():
|
||||
continue
|
||||
size = sum(len(text.encode('utf-8')) for text in [*contents, content])
|
||||
if size > MAX_AGENTS_MD_BYTES:
|
||||
size = len(content.encode('utf-8'))
|
||||
if total_bytes + size > MAX_AGENTS_MD_BYTES:
|
||||
log.warning('Skipping machine %s: exceeds %s bytes', name, MAX_AGENTS_MD_BYTES)
|
||||
else:
|
||||
total_bytes += size
|
||||
contents.append(f'# {name}\n\n{content}')
|
||||
break
|
||||
return '\n\n'.join(contents) or None
|
||||
|
||||
Reference in new issue
Block a user