mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(agents): don't crash autoreview copilot engine on Windows temp-dir cleanup (#97901)
On Windows the spawned copilot process and its MCP subprocesses keep the TemporaryDirectory as their cwd briefly after exit, holding a directory handle. That makes TemporaryDirectory's rmtree raise PermissionError (WinError 32) on __exit__, aborting the run with a traceback even though the review completed successfully. Pass ignore_cleanup_errors=True so cleanup is best-effort and a post-review cleanup race never fails the run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -624,7 +624,11 @@ def run_copilot(args: argparse.Namespace, repo: Path, prompt: str) -> str:
|
||||
raise SystemExit("--thinking is not supported by the copilot engine")
|
||||
if not args.tools:
|
||||
raise SystemExit("--no-tools is not supported by the copilot engine; copilot requires a read-only file view tool to load the review bundle without exposing it in argv")
|
||||
with tempfile.TemporaryDirectory(prefix="autoreview-copilot.") as tempdir:
|
||||
# ignore_cleanup_errors: on Windows the spawned copilot process (and its MCP
|
||||
# subprocesses) keep `tempdir` as their cwd briefly after exit, holding a directory
|
||||
# handle that makes rmtree fail with WinError 32. The review already completed, so a
|
||||
# cleanup race must not abort the run; best-effort delete is correct here.
|
||||
with tempfile.TemporaryDirectory(prefix="autoreview-copilot.", ignore_cleanup_errors=True) as tempdir:
|
||||
prompt_path = Path(tempdir) / "prompt.txt"
|
||||
prompt_path.write_text(prompt)
|
||||
os.chmod(prompt_path, 0o600)
|
||||
|
||||
Reference in New Issue
Block a user