Repository navigation
fix(run_code): run a script inside a Windows computer - #545
Merged
Merged
Conversation
run_code reached inside a computer with pkill, rm -rf and wc -c, and its runner registered SIGHUP and ended a timed-out script's process group, none of which Windows has. On a computer whose card says Windows, the step ends a leftover runner through PowerShell's process list, removes its folder and sizes the result with Python, and the runner ends the script's process tree with taskkill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A shell started in the user's session reads as the agent leaving the GUI, and the disarm step's PowerShell did during a bench trial. The leftover runner is now ended by a stdlib Python program that reads each process's command line through NtQueryInformationProcess. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tarted TerminateProcess ended only the processes whose command line held the runner's path, so a script's children outlived them. Each match's process tree is now ended with taskkill, and the program's Windows values are named. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the step needs no OS Inside a computer, run_code now runs only the runner: `--clear` ends the supervisor that holds the run folder's lock, with all it started, and removes the folder, and `--size` sizes the result. The supervisor holds that lock while it runs. The step no longer reads the computer's OS, sends pkill, rm or wc, or carries Windows programs; the runner's lock and process ending are the only OS-specific code, fcntl and signals on POSIX, msvcrt and taskkill on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part of FD-5315.
run_codecouldn't run a script inside a Windows computer, so every bench trial on Windows failed at its arm step:cannot run 'pkill': The system cannot find the file specified.The step worked inside a computer with POSIX tools:
pkill -fended a runner a dropped call left going,rm -rfremoved the run folder, andwc -csized the result. Its runner registeredSIGHUPand ended a timed-out script's process group withos.killpg. Windows has none of these.What changes
Inside a computer,
run_coderuns only its runner, so the step itself doesn't know or ask what OS the computer runs:pkill -f <escaped path>, thenrm -rf <folder>python3 -I -c <runner> --clear <folder>rm -rf <folder>after the run--clearwc -c <result>python3 -I -c <runner> --size <result>python3 <folder>/runner.py ...The runner locks its folder. While it supervises a script, it holds an exclusive lock on
runner.lockin the run folder and writes its pid torunner.pid.--cleartries that lock:--clearends it, with all it started, waits for the lock to free, then removes the folder.This replaces matching command lines, so it can't end the wrong process, and it needs neither
pkillnor a Windows process list. Clearing after the run now also ends a runner a dropped call left going, rather than waiting for the step's next run.The OS-specific code is two small pieces of the runner, both stdlib:
fcntl.flockmsvcrt.lockingtaskkill /T /FThe runner also registers only the signals the OS has, and on Windows ends a timed-out script's tree with
taskkill, as Windows has no process groups.Why
-I:--clearand--sizerun with the home as their working directory, which the agent can write. Isolated mode keeps ashutil.pyplanted there from running.No shell in the user's session. trycua's GUI-only guard counts any shell started in the session against the agent, and the disarm step runs while the sentinel is armed.
python3andtaskkillaren't side doors to it. A first version of this PR used PowerShell and failed a trial on exactly that.Hosts and containers are POSIX by construction and keep their commands.
runner.lockandrunner.pidjoin the member names a script universe may not use.Tests
Unit (box 1,
tst/unit/task_step/: 2447 passed; ruff clean):--clear, the run,--size,--clear, and nothing else;--clearends a live supervisor and the child its script started (128 + SIGTERM), then removes the folder;taskkill.On a Windows 11 guest, the runner itself:
-c.Chaos, the same harness on a deployed Windows computer (
notes-desk) and a Linux one (the app bundle'sdesk), every check passing on both:shutil.py,subprocess.pyand others planted in the home never runIntegration:
windows_test.py's notes task gains arun_codestep that runs inside the computer, in the session user's home, reaching the driver on loopback. It passed (inside done in 1.3s;passed (before: 1, session: 1, after: 1)).computer_app_test.py's three tests that runrun_codeinside a computer passed (alone, the two composed apps, the data plane).Bench trials (cua-driver, Sonnet 5.5): IR-01 r1 in the foreground passed on Windows (88.5 s) and on Linux (45.4 s), GUI-only 1 and grade 1 each. Earlier on this branch, all 12 Windows r1 trials of the seven BenchLab tasks armed, ran, disarmed and were graded.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was found.Summary
The PR lets
run_coderun inside Windows computers without POSIX tools.run_coderuns scripts inside Windows computers.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Clear previous run] --> B[Stage script and input] B --> C[Supervisor holds lock] C --> D[Run script with timeout] D --> E[Size and read result] E --> F[Clear run folder] A --> G{Lock held?} G -->|Yes| H[Stop supervisor and script] H --> BReviews (8) · Last reviewed commit: "refactor(run_code): the runner clears an..." · Reviewed by Greptile