cd /news/developer-tools/i-stopped-spawning-a-second-pi-just-… · home topics developer-tools article
[ARTICLE · art-107845] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=· neutral

I stopped spawning a second Pi just to switch sessions

A developer created pisesh, a Node-based session picker for the Pi coding agent, to address the problem of managing many similar sessions. The tool adds favorites, search, custom names, and a current-project view. In version 0.3.0, the developer integrated it with Pi's ctx.switchSession() extension API, allowing the picker to switch sessions within the same Pi process instead of spawning a nested Pi process, fixing runtime lifecycle issues.

read2 min views2 publishedAug 23, 2026

I use the Pi coding agent from several project folders. After a while, pi --resume

became a long list of sessions with similar first prompts. I kept reopening the wrong one.

I made pisesh to add the things I wanted in that list: favorites, search, custom names, a current-project view, and optional title generation. It is a single Node script with no runtime dependencies.

/sesh

implementation The first version took a direct route. It d Pi's TUI, opened the pisesh picker, then started another Pi process for the selected session.

That was useful because leaving the child process returned me to the original session. It also meant the process tree looked like this:

Pi session A
  pisesh
    Pi session B

The nested process eventually became the problem. Tools were running in session B, but anything watching the outer Pi process could still see session A as idle. The terminal looked right while the runtime lifecycle was wrong.

Pi already exposes ctx.switchSession()

to extensions. In pisesh 0.3.0, the picker no longer starts Pi when it was opened through /sesh

.

The picker writes one small JSON selection to a private file descriptor. It includes the absolute session path and the selected model behavior. The extension reads that result and asks Pi to switch the current runtime:

Pi session A
  /sesh picker
  ctx.switchSession(sessionB)
Pi session B

Standalone pisesh

still starts pi --session

, so the shell command keeps its old behavior. Only the extension path changed.

There were two details I did not want to lose. Enter

still resumes with the current default model and thinking level, while o

restores the values recorded in the selected session. Interrupted tool calls are also repaired before the handoff when Pi would otherwise load an incomplete transcript.

pi install npm:pisesh

Then run /sesh

inside Pi. The package is MIT licensed and works on Node 18 or newer.

── more in #developer-tools 4 stories · sorted by recency
── more on @pi 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-stopped-spawning-a…] indexed:0 read:2min 2026-08-23 ·