From 3f5881c5208c89e12594d4427f752262e378fbbe Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 25 Sep 2026 06:00:59 +0200 Subject: [PATCH] fix: load terminal AGENTS.md on Windows Open Terminal hosts (#31342) Fixes #31340 When the attached Open Terminal runs on Windows, the AGENTS.md in its home directory was never handed to the model. The home check only accepted POSIX absolute paths, so a drive-letter or UNC home such as C:\ProgramData\OpenTerminal\inst was treated as invalid and the file was skipped without any log line. The check now also accepts Windows absolute paths. Relative and drive-relative homes are still skipped, and POSIX homes send byte-identical requests. The file path keeps its forward-slash join. Open Terminal normalises the path on the host, so C:\Users\bob/AGENTS.md opens C:\Users\bob\AGENTS.md. Picking ntpath.join for Windows homes would give native separators on the wire but adds a second branch for no change in which file gets read. Verified against Open Terminal's own path resolution with Windows semantics for drive-letter, forward-slash, drive-root, trailing-backslash and UNC homes, over both the backend request and the browser direct-connection path. --- backend/open_webui/utils/terminals.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/terminals.py b/backend/open_webui/utils/terminals.py index 66d5f0f362..4dbd7e6b3f 100644 --- a/backend/open_webui/utils/terminals.py +++ b/backend/open_webui/utils/terminals.py @@ -2,6 +2,7 @@ import asyncio import logging +import ntpath import posixpath from urllib.parse import quote @@ -195,7 +196,7 @@ async def get_terminal_agents_md(request, user, metadata: dict, extra_params: di async with asyncio.timeout(5): data = await get_terminal_json(request, user, metadata, '/files/cwd', extra_params) home = data.get('home') if isinstance(data, dict) else None - if not isinstance(home, str) or not posixpath.isabs(home): + if not isinstance(home, str) or not (posixpath.isabs(home) or ntpath.isabs(home)): return None path = quote(posixpath.join(home, 'AGENTS.md'), safe='') data = await get_terminal_json(request, user, metadata, f'/files/read?path={path}', extra_params)