fix: scope local backend root '/' to workspace on Windows - #197
Merged
jubaoliang merged 1 commit intoAug 9, 2026
Conversation
Georgyhongbo
force-pushed
the
fix/windows-root-dir
branch
from
August 8, 2026 09:31
4ff1782 to
b13587b
Compare
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修复 Windows 上新建 agent 因
root_dir:"/"抛Path ... outside root directory的问题。背景 / 根因
新建 agent 时,前端(
dashboard/src/pages/Experts/components/agentBackendForm.ts)对本地后端默认写入{"type":"local_shell","root_dir":"/","virtual_mode":true}。deepagents 的FilesystemBackend/LocalShellBackend在virtual_mode下把所有路径锚定在root_dir,而"/"在 Windows 上会解析为当前进程所在盘的根目录(例如进程在 D 盘 →D:\)。agent 工作区通常位于另一盘符(C:\Users\<user>\.octop\agents\<id>),跨盘读取时_resolve_path会抛出Path ... outside root directory。此问题仅影响 Windows(POSIX 下
/就是真正的全盘根,工作区路径是其子路径,校验自然通过)。上游服务端default_agent_backend_spec在 Windows 上已把默认后端锚定到工作区,只是显式写入的root_dir:"/"绕过了该默认值。改动
在服务端后端规格解析处做 Windows 归一化(服务端是唯一知道自己运行平台的位置;浏览器无法可靠探测服务器 OS,且前端修复会在 Linux 上造成全盘访问→工作区作用域的回归):
src/octop/infra/backend/resolver.py:新增windows_neutralize_host_root(spec, *, workspace_dir)与_is_host_root()。仅当os.name == "nt"且本地后端(local_shell/filesystem,或 composite 的default)显式root_dir为/、\或""时,改写为default_agent_backend_spec(workspace_dir)(工作区作用域)。src/octop/infra/agents/manager.py:_backend_spec_for_row在resolve_agent_backend_spec之后接入归一化。影响面
os.name != "nt"时函数原样返回 spec。D:\develop)、缺失root_dir、composite 的routes子后端、以及 named/state/s3/postgres/cos 等非本地后端一律不动。_backend_supports_host_skill_packages/assert_backend_supports_skill_packages)把/根与工作区根视为等价可挂载宿主——与归一化前后 spec 的映射一致,校验与运行时不打架。Target branch
Type of change
Test plan
本地 Windows 环境(octop-venv,测试需 PYTHONPATH=src):
make allpasses locally验证明细:
PYTHONPATH=src python -m pytest tests/unit -q:1353 passed, 81 skipped。唯一失败 tests/unit/browser/test_browser_setup.py::test_ensure_profile_writable_recreates_when_not_writable 为 Windows 临时目录权限的既有环境问题,只依赖 octop.infra.browser.setup,与本次改动无代码路径交叉。pytest tests/unit/backend/test_resolver.py tests/unit/agents/test_agent_manager.py:61 passed, 2 skipped(新增 _is_host_root / windows_neutralize_host_root 8 个用例 + _backend_spec_for_row Windows 集成用例)。Checklist
CHANGELOG.md(if user-facing)