@@ -198,19 +198,22 @@ git fetch origin
198198git worktree add ~ /workspace/worktrees/$BRANCH -b $BRANCH origin/main
199199
200200# 2. Launch the agent IN the worktree
201- tmux new-session -d -s $SESSION_NAME \
202- " cd ~/workspace/worktrees/$BRANCH && \
203- export PATH=\$ HOME/.varlock/bin:\$ HOME/opt/node-v22.14.0-linux-x64/bin:\$ PATH && \
204- export PI_SESSION_NAME=$SESSION_NAME && \
205- exec varlock run --path ~/.config/ -- pi --session-control --skill ~/.pi/agent/skills/dev-agent --model <MODEL_FROM_TABLE_ABOVE>"
201+ mkdir -p ~ /.pi/agent/logs
202+ nohup bash -lc " cd ~/workspace/worktrees/$BRANCH && \
203+ export PATH=\$ HOME/.varlock/bin:\$ HOME/opt/node-v22.14.0-linux-x64/bin:\$ PATH && \
204+ export PI_SESSION_NAME=$SESSION_NAME && \
205+ exec varlock run --path ~/.config/ -- pi --session-control --skill ~/.pi/agent/skills/dev-agent --model <MODEL_FROM_TABLE_ABOVE>" \
206+ > ~ /.pi/agent/logs/$SESSION_NAME .log 2>&1 &
207+ DEV_PID=$!
208+ echo $DEV_PID > ~ /.pi/agent/$SESSION_NAME .pid
206209```
207210
208211** Important notes:**
209212- ` cd ` into the worktree BEFORE launching pi — this ensures pi discovers project context from the repo's CWD
210- - Use ` exec ` so the tmux session exits when pi exits
211213- Use ` varlock run --path ~/.config/ ` to validate and inject env vars
212214- Set ` PI_SESSION_NAME ` so the auto-name extension registers it
213215- Include ` --session-control ` for ` send_to_session ` / ` list_sessions `
216+ - Read logs with ` tail -f ~/.pi/agent/logs/$SESSION_NAME.log `
214217- Wait ** ~ 10 seconds** after spawning before sending messages (agent needs time to initialize)
215218- Do NOT use ` --name ` (not a real pi CLI flag)
216219
@@ -225,8 +228,13 @@ SESSION_NAME=dev-agent-myapp-a8b7b331
225228REPO=myapp
226229BRANCH=fix/some-descriptive-name
227230
228- # 1. Kill the tmux session (agent should have already exited, but ensure it)
229- tmux kill-session -t $SESSION_NAME 2> /dev/null || true
231+ # 1. Kill the process if still running
232+ PID_FILE=~ /.pi/agent/$SESSION_NAME .pid
233+ if [ -f " $PID_FILE " ]; then
234+ PID=$( cat " $PID_FILE " 2> /dev/null || true)
235+ [ -n " $PID " ] && kill " $PID " 2> /dev/null || true
236+ rm -f " $PID_FILE "
237+ fi
230238
231239# 2. Remove the worktree
232240cd ~ /workspace/$REPO
@@ -309,10 +317,10 @@ This removes stale `.sock` files, cleans dead aliases, and restarts the Slack br
309317- [ ] Find or create sentry-agent:
310318 1 . Use ` list_sessions ` to look for a session named ` sentry-agent `
311319 2 . If found, use that session
312- 3 . If not found, launch with tmux (see Sentry Agent section)
320+ 3 . If not found, launch as a normal background process (see Sentry Agent section)
313321 4 . Wait ~ 8 seconds, then send role assignment
314322- [ ] Send role assignment to the ` sentry-agent ` session
315- - [ ] Clean up any stale dev-agent worktrees/tmux sessions from previous runs
323+ - [ ] Clean up any stale dev-agent worktrees/background processes from previous runs
316324
317325** Note** : Dev agents are NOT started at startup. They are spawned on-demand when tasks arrive.
318326
@@ -330,7 +338,9 @@ The sentry-agent triages Sentry alerts and investigates critical issues via the
330338| ` OPENCODE_ZEN_API_KEY ` | ` opencode-zen/claude-haiku-4-5 ` |
331339
332340``` bash
333- tmux new-session -d -s sentry-agent " export PATH=\$ HOME/.varlock/bin:\$ HOME/opt/node-v22.14.0-linux-x64/bin:\$ PATH && export PI_SESSION_NAME=sentry-agent && varlock run --path ~/.config/ -- pi --session-control --skill ~/.pi/agent/skills/sentry-agent --model <MODEL_FROM_TABLE_ABOVE>"
341+ mkdir -p ~ /.pi/agent/logs
342+ nohup bash -lc " export PATH=\$ HOME/.varlock/bin:\$ HOME/opt/node-v22.14.0-linux-x64/bin:\$ PATH && export PI_SESSION_NAME=sentry-agent && exec varlock run --path ~/.config/ -- pi --session-control --skill ~/.pi/agent/skills/sentry-agent --model <MODEL_FROM_TABLE_ABOVE>" > ~ /.pi/agent/logs/sentry-agent.log 2>&1 &
343+ echo $! > ~ /.pi/agent/sentry-agent.pid
334344```
335345
336346** Model note** : ` github-copilot/* ` models reject Personal Access Tokens and will fail in non-interactive sessions.
@@ -339,17 +349,14 @@ The sentry-agent operates in **on-demand mode** — it does NOT poll. Sentry ale
339349
340350### Starting the Slack Bridge
341351
342- The ` startup-cleanup.sh ` script handles bridge (re)start automatically — it detects broker vs Socket Mode, reads the control-agent UUID, and launches the bridge in a ` slack-bridge ` tmux session .
352+ The ` startup-cleanup.sh ` script handles bridge (re)start automatically — it detects broker vs Socket Mode, reads the control-agent UUID, and starts the bridge as a normal background process .
343353
344- If you need to restart the bridge manually:
354+ If you need to restart the bridge manually, run ` startup-cleanup.sh ` again and then inspect logs :
345355``` bash
346- MY_UUID=$( readlink ~ /.pi/session-control/control-agent.alias | sed ' s/.sock$//' )
347- tmux kill-session -t slack-bridge 2> /dev/null || true
348- tmux new-session -d -s slack-bridge \
349- " unset PKG_EXECPATH; export PATH=\$ HOME/.varlock/bin:\$ HOME/opt/node-v22.14.0-linux-x64/bin:\$ PATH && export PI_SESSION_ID=$MY_UUID && cd ~/runtime/slack-bridge && exec varlock run --path ~/.config/ -- node broker-bridge.mjs"
356+ tail -n 200 ~ /.pi/agent/logs/slack-bridge.log
350357```
351358
352- Verify: ` curl -s -o /dev/null -w '%{http_code}' -X POST http://127.0.0.1:7890/send -H 'Content-Type: application/json' -d '{}' ` → should return ` 400 ` .
359+ Verify API readiness : ` curl -s -o /dev/null -w '%{http_code}' -X POST http://127.0.0.1:7890/send -H 'Content-Type: application/json' -d '{}' ` → should return ` 400 ` .
353360
354361The bridge forwards:
355362- ** Human @mentions and DMs** from allowed users → delivered to you with security boundaries for handling
@@ -362,9 +369,9 @@ Health checks run automatically every ~10 minutes via the `heartbeat.ts` extensi
362369If you need to check manually, use ` heartbeat trigger ` to run all checks immediately.
363370
364371When the heartbeat reports a failure, take the appropriate action:
365- 1 . ** Missing sentry-agent** : Respawn with tmux and re-send role assignment.
366- 2 . ** Orphaned dev-agents** : Kill tmux session and remove worktree.
367- 3 . ** Bridge down** : Restart the ` slack-bridge ` tmux session .
372+ 1 . ** Missing sentry-agent** : Respawn as a background process and re-send role assignment.
373+ 2 . ** Orphaned dev-agents** : Kill stale process + remove worktree.
374+ 3 . ** Bridge down** : Restart via ` startup-cleanup.sh ` and read ` ~/.pi/agent/logs/slack-bridge.log ` .
3683754 . ** Stale worktrees** : ` git worktree remove --force ` + ` rmdir ` empty parents.
3693765 . ** Stuck todos** : Escalate to user via Slack.
370377
0 commit comments