exec tool and keeps long-running tasks in memory. The process tool manages those background sessions.
exec tool
Parameters:
Behavior:
- Foreground runs return retained output directly and disclose when earlier output exceeded the aggregate cap.
- When backgrounded (explicit or via
yieldMstimeout), the tool returnsstatus: "running"+sessionIdand a short output tail. - Backgrounded and
yieldMsruns inherittools.exec.timeoutSecondsunless the call passes an explicittimeoutSeconds. - Output stays in memory up to the per-session aggregate cap until the session is polled or cleared.
- Finished sessions expire after their configured TTL. The registry also retains at most 50 finished sessions and 2,000,000 total retained output characters, evicting the oldest records first. The newest completed session retains its capped per-session aggregate even when that record alone exceeds the global limit.
- 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 enabled) once the command emits output or fails.
- If automatic completion wake is unavailable, or you need quiet-success confirmation for a command that exits cleanly with no output, poll with
process. - Don’t emulate reminders or delayed follow-ups with
sleeploops or repeated polling — use cron for future work.
Env overrides
Config (preferred over env overrides)
Worker environments
On a paired-node or node-backed cloud worker, background processes belong to the session’s environment. Finishing or cancelling a turn leaves already-backgrounded commands running. A later turn in the same environment can useprocess to poll,
send input, or stop them; foreground commands still stop when their turn is cancelled.
The retained worker occupies one node worker slot. Reusing it needs no additional
slot. If a command finishes between turns, its retained output remains available
to the next turn, subject to the normal process output limits and TTL. Once a turn
finishes with no live background commands, the worker exits. Moving or retiring
the environment, replacing its ownership, or stopping the node also stops its
processes. Process handles do not survive a worker or node restart.
If the node’s pairing is revoked or its provider no longer recognizes the lease,
the session placement fails. Physical cleanup can remain pending until OpenClaw
confirms that the exact worker has stopped; an unconfirmed stop does not release
its ownership record.
Worker completion does not currently wake the Gateway session automatically;
use process poll in a later turn to inspect the result. Closing a portal closes
its proxy, not the development server: stop the server with process kill.
Child process bridging
When spawning long-running child processes outside the exec/process tools (CLI respawns, gateway helpers), attach the child-process bridge helper so termination signals forward and listeners detach on exit/close. This avoids orphaned processes on systemd and keeps shutdown consistent across platforms. A supervised command’s timeout also covers startup, including blocked private-input delivery. The timeout result can return while cleanup continues. Scope retirement and Gateway shutdown wait for the cleanup owner separately; when that owner reports uncertainty, they report failure instead of treating the timeout as proof that the command has stopped.process tool
Actions:
Notes:
- Only backgrounded sessions are listed/persisted — in memory only, not on disk. Sessions are lost on process restart.
- Resetting or deleting a session clears only its completed background processes; other sessions, explicit shared scopes, and running processes remain unaffected.
- A live background session blocks cooperative host suspension and safe Gateway restart until the process owner confirms its actual exit.
process removecan hide a running session immediately after requesting termination; suspension and restart remain blocked until exit confirmation.- 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, or completion confirmation when automatic completion wake is unavailable. - Use
logbefore recovering an interactive CLI, so the current transcript, stdin state, and input-wait hint are visible together. - Use
write/send-keys/submit/paste/killwhen you need input or intervention. process listincludes a derivedname(command verb + target) for quick scans.process list,poll, andlogreportwaitingForInputonly when the session still has writable stdin and has been idle longer than the input-wait threshold (default 15000 ms,OPENCLAW_PROCESS_INPUT_WAIT_IDLE_MS).process loguses line-basedoffset/limit. When both are omitted, it returns the last 200 lines with a paging hint. Whenoffsetis set andlimitisn’t, it returns fromoffsetto the end (not capped to 200).process pollandprocess logdistinguish output discarded at the aggregate retention cap from output merely omitted by the pending buffer or retained tail. Discarded output cannot be recovered; paged logs can inspect only the retained portion.poll’stimeoutwaits up to that many milliseconds before returning; values above 30000 are clamped to 30000.- Polling is for on-demand status, not wait-loop scheduling. If the work should happen later, use cron.