Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): agent-browser and Chrome no longer outlive the agent that started them #21299

Mergedjosephv123(GitHub profile, opens in a new tab)merged 12 commits intomain fromrefs/pull/21299/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 16 changed files with 34 additions and 5 deletions (loading 13).

x
0 of 16 viewed, 16 left
15 additions and 3 deletionsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsModified
View file
@@ -323,14 +323,18 @@
* When the CLI exits it stops the MCP servers it started, but not their children: a plugin's
* `bun run start` wrapper dies and its `bun server.ts` keeps running, writing to a pipe nobody
* reads (#3089). Those stay in the CLI's group, so the rest of the group gets SIGKILL once the
- * CLI exits for any reason.
+ * CLI exits for any reason. `onExit` then stops the CLI's agent scope, for daemons a tool
+ * detached from the group with setsid.
* That cleanup needs this server alive, and the CLI finishes its turn after its pipes close. A
* server that crashes or is killed would leave the CLI working next to the session it resumes
* (#23370), so a watcher in the group reads a pipe only this server holds and stops the group at
* its end-of-file.
-export function spawnClaudeProcessGroup(options: ClaudeSpawnOptions): ClaudeSpawnedProcess {
+export function spawnClaudeProcessGroup(
+ options: ClaudeSpawnOptions,
+ onExit?: () => void,
+): ClaudeSpawnedProcess {
const child = NodeChildProcess.spawn(
"/bin/sh",
["-c", CLAUDE_GROUP_WATCH_SCRIPT, "t3-claude", options.command, ...options.args],
@@ -346,6 +350,7 @@
try {
signalProcessGroup(child.pid ?? 0, "SIGKILL");
} catch {}
+ onExit?.();
});
// Node's typings make stdin and stdout nullable once stdio has a fourth entry; both are pipes.
return child as ClaudeSpawnedProcess;