fix(agents): stop copilot autoreview cleanup crash on Windows - #97901
vincentkoc merged 1 commit into
Conversation
…r cleanup 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>
|
Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 2:47 PM ET / 18:47 UTC. Summary PR surface: Other +4. Total +4 across 1 file. Reproducibility: yes. source-backed: on Windows, run Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land the focused cleanup fix after ordinary maintainer and CI gates, while leaving the separate copilot parser behavior to #97902. Do we have a high-confidence way to reproduce the issue? Yes, source-backed: on Windows, run Is this the best way to solve the issue? Yes. Passing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 82dfd8910743. Label changesLabel justifications:
Evidence reviewedPR surface: Other +4. Total +4 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
…r cleanup (openclaw#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>
…r cleanup (openclaw#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>
What Problem This Solves
Fixes an issue where running the
autoreviewskill with--engine copiloton Windows could crash with a Python traceback (PermissionError: [WinError 32] The process cannot access the file because it is being used by another process) even though the code review itself completed successfully. The structured review result was discarded and the command exited non-zero for that run.Why This Change Was Made
run_copilotruns inside atempfile.TemporaryDirectory(...)context manager whose__exit__deletes the directory. The spawnedcopilot -C <tempdir>process (and its MCP subprocesses) keep that directory as their working directory for a brief moment after exit, so on Windows the lingering directory handle makesrmtreeraiseWinError 32. Because the review had already finished, the cleanup race should never fail the run. Passingignore_cleanup_errors=Truemakes the temp-dir cleanup best-effort, matching how the other engines already tolerate post-run temp-file cleanup. This is the only engine that usedTemporaryDirectory; no other behavior changes.User Impact
The
autoreviewcopilot engine no longer fails a completed review because Windows has not released the temporary directory handle yet. No intended behavior change on macOS/Linux.Evidence
test-review-harness.ps1 -Fixture benign -Engine copilotaborted with theWinError 32traceback fromTemporaryDirectory.__exit__(shutil.rmtree), exit code 1.WinError 32cleanup traceback; the separate prose-wrapped JSON parser failure is handled in the companion copilot parser PR.%TEMP%\autoreview-copilot.*leftovers confirmed cleanup can fail without deleting the prompt directory; this change makes that cleanup best-effort instead of turning the finished review into a failure.autoreview --mode commit --commit HEAD --engine claude):autoreview clean: no accepted/actionable findings reported, patch is correct (0.9).ignore_cleanup_errorsrequires Python 3.10+; the script already targets 3.10+ (verified, runtime 3.14) and declares no older floor.