Background Exec + Process Tool
OpenClaw runs shell commands through theexec tool and keeps long‑running tasks in memory. The process tool manages those background sessions.
exec tool
Key parameters:command(required)yieldMs(default 10000): auto‑background after this delaybackground(bool): background immediatelytimeout(seconds, default 1800): kill the process after this timeoutelevated(bool): run outside the sandbox if elevated mode is enabled/allowed (gatewayby default, ornodewhen the exec target isnode)- Need a real TTY? Set
pty: true. workdir,env
- Foreground runs return output directly.
- When backgrounded (explicit or timeout), the tool returns
status: "running"+sessionIdand a short tail. - Output is kept in memory until the session is polled or cleared.
- If the
processtool is disallowed,execruns synchronously and ignoresyieldMs/background. - Spawned exec commands receive
OPENCLAW_SHELL=execfor context-aware shell/profile rules. - For long-running work that starts now, start it once and rely on automatic completion wake when it is enabled and the command emits output or fails.
- If automatic completion wake is unavailable, or you need quiet-success
confirmation for a command that exited cleanly without output, use
processto confirm completion. - Do not emulate reminders or delayed follow-ups with
sleeploops or repeated polling; use cron for future work.
Child process bridging
When spawning long-running child processes outside the exec/process tools (for example, CLI respawns or gateway helpers), attach the child-process bridge helper so termination signals are forwarded and listeners are detached on exit/error. This avoids orphaned processes on systemd and keeps shutdown behavior consistent across platforms. Environment overrides:PI_BASH_YIELD_MS: default yield (ms)PI_BASH_MAX_OUTPUT_CHARS: in‑memory output cap (chars)OPENCLAW_BASH_PENDING_MAX_OUTPUT_CHARS: pending stdout/stderr cap per stream (chars)PI_BASH_JOB_TTL_MS: TTL for finished sessions (ms, bounded to 1m–3h)
tools.exec.backgroundMs(default 10000)tools.exec.timeoutSec(default 1800)tools.exec.cleanupMs(default 1800000)tools.exec.notifyOnExit(default true): enqueue a system event + request heartbeat when a backgrounded exec exits.tools.exec.notifyOnExitEmptySuccess(default false): when true, also enqueue completion events for successful backgrounded runs that produced no output.
process tool
Actions:list: running + finished sessionspoll: drain new output for a session (also reports exit status)log: read the aggregated output (supportsoffset+limit)write: send stdin (data, optionaleof)send-keys: send explicit key tokens or bytes to a PTY-backed sessionsubmit: send Enter / carriage return to a PTY-backed sessionpaste: send literal text, optionally wrapped in bracketed paste modekill: terminate a background sessionclear: remove a finished session from memoryremove: kill if running, otherwise clear if finished
- Only backgrounded sessions are listed/persisted in memory.
- Sessions are lost on process restart (no disk persistence).
- Session logs are only saved to chat history if you run
process poll/logand the tool result is recorded. processis scoped per agent; it only sees sessions started by that agent.- Use
poll/logfor status, logs, quiet-success confirmation, or completion confirmation when automatic completion wake is unavailable. - Use
write/send-keys/submit/paste/killwhen you need input or intervention. process listincludes a derivedname(command verb + target) for quick scans.process loguses line-basedoffset/limit.- When both
offsetandlimitare omitted, it returns the last 200 lines and includes a paging hint. - When
offsetis provided andlimitis omitted, it returns fromoffsetto the end (not capped to 200). - Polling is for on-demand status, not wait-loop scheduling. If the work should happen later, use cron instead.