Some checks failed
CI / docs-scope (push) Has been cancelled
CI / secrets (push) Has been cancelled
CI / ios (push) Has been cancelled
Docker Release / validate_manual_backfill (push) Has been cancelled
Install Smoke / docs-scope (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / config-docs-drift (push) Has been cancelled
CI / changed-scope (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / release-check (push) Has been cancelled
CI / checks (pnpm canvas:a2ui:bundle && bunx vitest run --config vitest.unit.config.ts, bun, test) (push) Has been cancelled
CI / checks (pnpm canvas:a2ui:bundle && pnpm test, node, 2, 1, test) (push) Has been cancelled
CI / checks (pnpm canvas:a2ui:bundle && pnpm test, node, 2, 2, test) (push) Has been cancelled
CI / checks (pnpm protocol:check, node, protocol) (push) Has been cancelled
CI / checks (pnpm test:channels, node, channels) (push) Has been cancelled
CI / checks (pnpm test:extensions, node, extensions) (push) Has been cancelled
CI / check (push) Has been cancelled
CI / startup-memory (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / compat-node22 (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 1, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 2, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 3, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 4, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 5, test) (push) Has been cancelled
CI / checks-windows (pnpm test, node, 6, 6, test) (push) Has been cancelled
CI / macos (push) Has been cancelled
CI / android (./gradlew --no-daemon :app:assembleDebug, build) (push) Has been cancelled
CI / android (./gradlew --no-daemon :app:testDebugUnitTest, test) (push) Has been cancelled
Docker Release / approve_manual_backfill (push) Has been cancelled
Docker Release / build-amd64 (push) Has been cancelled
Docker Release / build-arm64 (push) Has been cancelled
Docker Release / create-manifest (push) Has been cancelled
Install Smoke / install-smoke (push) Has been cancelled
3.7 KiB
3.7 KiB
summary, read_when, title
| summary | read_when | title | ||
|---|---|---|---|---|
| Background exec execution and process management |
|
Background Exec and Process Tool |
Background Exec + Process Tool
OpenClaw runs shell commands through the exec 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 on host if elevated mode is enabled/allowed- Need a real TTY? Set
pty: true. workdir,env
Behavior:
- 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.
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)
Config (preferred):
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)kill: terminate a background sessionclear: remove a finished session from memoryremove: kill if running, otherwise clear if finished
Notes:
- 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.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).
Examples
Run a long task and poll later:
{ "tool": "exec", "command": "sleep 5 && echo done", "yieldMs": 1000 }
{ "tool": "process", "action": "poll", "sessionId": "<id>" }
Start immediately in background:
{ "tool": "exec", "command": "npm run build", "background": true }
Send stdin:
{ "tool": "process", "action": "write", "sessionId": "<id>", "data": "y\n" }