Skip to content

The Host Daemon

ps-bash -c "<command>" does not start PowerShell from scratch each time. A cold PowerShell runspace takes a second or more, which is too slow when an AI agent runs hundreds of commands. So the ps-bash launcher hands each command to a long-lived background process, ps-bash-host, and exits once the command finishes.

This page covers what that process is, how many you should expect to see, and how to change its behaviour.


The first ps-bash -c in a session starts a ps-bash-host. Every later -c from the same session reuses it, so only the first command pays the startup cost.

Each command still gets a clean PowerShell session. The host keeps a small pool of pre-warmed runspaces, hands each command its own runspace, and throws that runspace away when the command ends. Variables, functions and cd from one -c don’t leak into the next.

What counts as a session. The launcher walks up its process tree to the nearest long-lived shell or agent: pwsh, powershell, cmd, bash, zsh, fish, node, bun, deno, python, claude, opencode. That process is the session anchor. Every ps-bash -c under the same anchor shares one host. Two terminal windows or two agents get separate hosts, so one busy agent never queues behind another.

SituationHost exits
The session anchor (your terminal, your agent) exitsAbout 5 s after its last command finishes
No command for PSBASH_HOST_IDLE_SECS (default 600 s)When the idle time runs out
PSBASH_PER_INVOCATION=1With the launcher, after every command
ps-bash host shutdownRight away (graceful)

The anchor rule means a host never outlives its session by more than a few seconds. Closing the terminal or ending the agent cleans up its host.

Set these in the environment of the shell or agent that runs ps-bash. For an agent, that means setting them before you start it.

VariableDefaultEffect
PSBASH_SESSION(automatic)Fixed session name. Every ps-bash -c with the same value shares one host, whatever process tree it runs in. The host then exits only on idle (PSBASH_HOST_IDLE_SECS), because no single process stands for the session.
PSBASH_PER_INVOCATION01 gives every ps-bash -c its own private host that exits with it. No process is left behind, but every command pays a cold start.
PSBASH_HOST_IDLE_SECS600Seconds a host with no running command waits before exiting.
PSBASH_POOL_WARM2Pre-warmed runspaces the host keeps ready. 0 builds each runspace on demand.
PSBASH_POOL_MAXCPU count, clamped to 2–8Most commands one host runs at once.
PSBASH_STARTUP_TIMEOUT60Seconds a launcher waits for a new host to come up.
PSBASH_IPC_ENDPOINT(automatic)Explicit unix:<path> or pipe:<name> endpoint. Mostly for tests. Like PSBASH_SESSION, the host exits only on idle.

An agent launched from PowerShell: one warm host for the whole session

Terminal window
$env:PSBASH_SESSION = "claude"
claude

Nothing left running between commands (slower)

Terminal window
$env:PSBASH_PER_INVOCATION = "1"

Shorter idle time

Terminal window
$env:PSBASH_HOST_IDLE_SECS = "60"
Terminal window
ps-bash host status # is this session's host up, and which endpoint is it on?
ps-bash host start # warm it now so the next command is fast (alias: warm)
ps-bash host restart # replace it, e.g. after upgrading ps-bash
ps-bash host shutdown # stop it

These act on the current session’s host, the one a ps-bash -c from this shell would use.