You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
senior-dev: a service it starts in the background is killed when the run ends #2901
When a task asks senior-dev to start a service and leave it running (for example "start a Flask API on port 5000 in the background"), senior-dev starts it, checks it, and reports success. Then the run ends and the service is gone. Anything that talks to the service after the run gets Connection refused.
Steps to reproduce:
In a plain folder, run codeaf senior-dev run --in-place -- "Write a small HTTP server in server.py and start it in the background on port 5000 so it keeps serving after you finish."
Senior-dev starts the server (for example nohup python3 server.py &), curls it successfully, and submits with status pass.
After the command exits, curl localhost:5000 is refused and the process no longer exists.
Why
Closing the run's runtime kills every process group the bash tool started:
internal/seniordev/tool/bash.go: CloseShellProcesses() sends SIGKILL to each registered group (syscall.Kill(-pid, SIGKILL)). After closed is set, registerShellGroup kills any group it is handed.
A nohup … & job stays in the bash tool's process group, so it is killed. Only a process that leaves the group (for example with setsid) survives. The model is not told this, and it has no reason to expect it.
Cleaning up stray jobs is right for builds, watchers and test servers the agent used for itself. When the deliverable is a running process, though, the cleanup undoes the work after senior-dev has reported success:
services, daemons and dev servers the person asked to be left up
background workers or schedulers the task sets running
The run says it passed, but what the person asked for is not there.
Or, at least, tell the model in the tool description that background jobs are killed when the run ends and that setsid detaches one on purpose, and say in the ending which processes were stopped.
Correction to the description above: setsid does not let a process escape either. There are two more sweeps behind the bash tool's group kill:
internal/seniordev/app/run.go makes the engine a child subreaper (processgroup.EnableSubreaper) and defers processgroup.CleanupDescendants(), which SIGKILLs every process descended from the engine, detached or not.
processgroup.CleanupRun(marker) kills every process carrying CODEAF_DELEGATE_RUN after the engine itself is SIGKILLed.
So any fix needs to account for all three (CloseShellProcesses, CleanupDescendants, CleanupRun), and the "tell the model to use setsid" direction does not work as written.
Activity
santoshkumarradha commentedon Nov 24, 2026
Correction to the description above:
setsiddoes not let a process escape either. There are two more sweeps behind the bash tool's group kill:internal/seniordev/app/run.gomakes the engine a child subreaper (processgroup.EnableSubreaper) and defersprocessgroup.CleanupDescendants(), which SIGKILLs every process descended from the engine, detached or not.processgroup.CleanupRun(marker)kills every process carryingCODEAF_DELEGATE_RUNafter the engine itself is SIGKILLed.So any fix needs to account for all three (
CloseShellProcesses,CleanupDescendants,CleanupRun), and the "tell the model to use setsid" direction does not work as written.