Skip to content

fix: track Windows agent process trees - #73

Closed
Eskibear wants to merge 1 commit into
formulahendry:mainfrom
Eskibear:eskibear-fix-windows-agent-cleanup
Closed

Eskibear wants to merge 1 commit into
formulahendry:mainfrom
Eskibear:eskibear-fix-windows-agent-cleanup

Conversation

@Eskibear

Copy link
Copy Markdown
Contributor

Summary

  • Track Windows agent processes in a Job Object so cleanup reaches descendants after the shell wrapper exits.
  • Wait for the tracked process tree to empty before releasing session capacity.
  • Add a Windows regression test and CI job.

Closes #71

Assign each Windows agent process to a Job Object so cleanup can terminate descendants after a shell wrapper exits. Wait for the job to empty before releasing the session.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 14, 2026 03:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Windows Job Object tracking so agent descendants remain manageable after shell-wrapper exit.

Changes:

  • Adds native Windows process-tree tracking and cleanup.
  • Updates session lifecycle to await tracked descendants.
  • Adds Windows regression coverage, CI, and Koffi dependency.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/acp/windows-job.ts Implements Windows Job Object bindings.
src/acp/agent-manager.ts Tracks and terminates Windows agent trees.
src/acp/session.ts Delays session release until tree exit.
tests/windows-job.test.ts Adds descendant-cleanup regression test.
.github/workflows/ci.yml Adds Windows CI coverage.
package.json Adds Koffi dependency.
package-lock.json Locks Koffi platform packages.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/acp/session.ts
Comment on lines 979 to +980
agentInfo.process.on("exit", () => {
this.handleAgentExit(userId, agentInfo.process);
void waitForAgentExit(agentInfo.process).then(
Comment thread tests/windows-job.test.ts
Comment on lines +9 to +15
import { createWindowsJob } from "../src/acp/windows-job.js";

test(
"Windows job terminates a descendant after its wrapper exits",
{ skip: process.platform !== "win32" },
async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "wechat-acp-job-"));
Comment thread src/acp/agent-manager.ts
Comment on lines +97 to +101
const { createWindowsJob } = await import("./windows-job.js");
if (proc.pid === undefined) {
throw new Error("Cannot track Windows agent process without a process ID");
}
windowsJobs.set(proc, createWindowsJob(proc.pid));
@Eskibear Eskibear closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Track Windows agent processes after shell wrapper exit

2 participants