sessions_spawn 工作区错位修复:恢复真实 workspace handoff(PR #44307)
问题/场景:子代理执行时若拿到错误工作目录,会导致读写路径偏移、构建失败或误改文件。前置条件:使用 sessions_spawn 进行多步骤任务分发。实施步骤:1) 升级到含 PR #44307;2) 触发一个会写文件的子代理任务;3) 校验子代理输出路径在预期 workspace;4) 构建/测试确认无路径污染。关键命令:openclaw status、git status、npm run build。验证方法:子代理读写落在目标仓库且主流程可复现通过。风险与边界:跨仓库任务仍需显式声明 cwd,不要依赖隐式推断。来源归因:GitHub PR #44307。
GITHUBDiscovered 2026-03-13Author openclaw contributors
Prerequisites
- You use sessions_spawn for background/sub-agent workflows.
- Target workspace has a deterministic build/test command.
Steps
- Upgrade to build containing PR #44307.
- Spawn a sub-agent task that creates/edits files in the intended repo.
- Check resulting file paths and confirm they are under expected workspace root.
- Run build/tests to ensure downstream steps consume the same workspace state.
Commands
openclaw statusgit statusnpm run buildVerify
Sub-agent writes appear in correct repository and follow-up build succeeds without path-related errors.
Caveats
- Relative paths inside custom scripts can still escape expected dirs if script logic is unsafe(需验证).
- When spawning across multiple repos, always pin explicit repo root in task prompt.
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗