Background jobs
Run long shell commands without blocking the conversation, watch their logs, and handle results that arrive later.
Some commands should keep running while you keep talking: a dev server, a file watcher, or a slow test suite. Jouzu’s bg_task tool runs shell commands as background tasks without blocking the conversation, instead of nohup, &, or foreground polling. Tasks write persistent logs, can wake the agent on output, and can be stopped from the session.
You can start jobs yourself with slash commands, or ask Jouzu to start and watch one:
Run the unit tests in the background. Tell me the pass/fail counts when they finish; if anything fails, list the failing test names only./bg opens the background task dashboard; Alt+Shift+H opens it too. Subcommands:
| Command | Effect |
|---|---|
/bg run <command> | Start a shell command as a background task in the current directory. |
/bg list | Show tracked tasks. With none, prints No background tasks. |
/bg log <id> | Show a task’s log tail and log file path. |
/bg watch <id> | Open the dashboard focused on a task. |
/bg stop <id> | Terminate a running task. |
/bg clear | Remove finished tasks from the list. |
/bg next | Move the next bash command the agent runs to a background task. |
/bg run npm run devExpected reply: a line such as Started bg-1 (pid 4312) in the background. The task keeps running across turns, and its log stays available after it exits.
- Completion results arrive in batches after the current reply and any queued messages finish. A result already read through the log does not wake the agent again.
- A task can wake the agent when new output matches a substring or pattern, so the agent can react without polling.
- Stopping a task terminates its process group, the same as
/bg stop. - Pending completion records survive a restart; restoring the session reconciles what was already delivered.
- A foreground monitoring loop the agent starts is diverted into a background task instead of blocking the turn.
When remaining work depends on a background job, the agent can declare a wait. Jouzu then waits for completion, failure, or the deadline before scheduling the next reply. A reply in progress finishes first, and queued user messages run before the wait outcome, so you can keep steering.
- Once the outcome has been delivered, it does not trigger another response by itself.
- Your messages are never blocked by a wait; they are delivered as usual.
- Single-shot runs (
jz -pand JSON mode) wait for accepted waits and their continuation replies before closing, so the final answer reflects the job’s outcome.
Flow control coordinates jobs, tasks, and automatic replies. If a background result seems held up, run /flow: it shows held inputs and work and offers recovery actions in an interactive terminal.
| Command | Effect |
|---|---|
/flow pause | Pause automatic replies. Background jobs keep running. |
/flow resume | Allow automatic replies again. |
/flow clear | Release saved request holds and a stuck reservation without resending. Run while Jouzu is idle. |
/flow reset confirm | Destructive fallback while idle: discards queued messages, receipts, and waits. Jobs keep running. |
Set JOUZU_FLOW_CONTROL=0 before starting Jouzu to disable flow control for that process. Pausing or clearing flow state does not stop background jobs.
- Start the server as a background task:
/bg run npm run dev. Note the task id in the reply. - Ask Jouzu to check it: "Read the dev server log and tell me which port it bound."
- Keep working. If you asked Jouzu to watch the output, it is woken when the server prints a matching line.
- When done, stop it:
/bg stop <id>, and confirm with/bg list.
- Goals and iteration — let long objectives iterate while you supervise.
- Agents and roles — hand a whole task to a child agent.
- Commands — the command reference.
- Troubleshooting — diagnose an unhealthy session.