fix: harden agent process lifecycle handling#16
Conversation
- run app-server and legacy agent processes detached on non-Windows platforms - kill process groups when interrupting or shutting down, with child.kill fallback - remove cached thread id in app-server mode so each turn starts a fresh thread - forward frontend websocket frames directly to Claude SDK and restart session after each turn - add test coverage for detached process-group interrupt behavior
Summary of ChangesHello @axeldelafosse, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness and reliability of child process management within the agent system. By ensuring that child processes are properly detached and terminated, it prevents issues like orphaned processes and stale state bleeding across turns. The changes streamline the lifecycle of both the Codex app-server and the Claude SDK, leading to more predictable and stable agent behavior. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively hardens the agent process lifecycle management. The introduction of detached process groups on non-Windows platforms and the logic to kill process groups are significant improvements for ensuring that child processes and their descendants are properly terminated. The changes to restart the Claude SDK process after each turn and to stop caching app-server thread IDs are good measures to prevent stale state and improve the reliability of the system. The added test coverage for the new process group killing logic is also a valuable addition.
I have one suggestion regarding code duplication that would further improve the maintainability of the new process killing logic.
Summary
process.kill(-pid, signal)and safely falls back tochild.kill(...)thread/startis called per turnWhy
Testing
bun run checkbun test tests/loop/codex-app-server.test.ts