openclaw agent runs a single agent turn from the command line without an
inbound chat message. Use it for scripted workflows, testing, and
programmatic delivery. Full flag and behavior reference:
Agent CLI reference.
For strict, ephemeral CI or coding automation that should own setup, cleanup,
output projection, and process status, use openclaw agent exec.
Quick start
1
Run a simple agent turn
2
Send a multiline prompt from a file
3
Target a specific agent or session
4
Deliver the reply to a channel
Flags
Behavior
- By default, the CLI goes through the Gateway. Add
--localto force the embedded runtime on the current machine. - Pass exactly one of
--messageor--message-file. File messages preserve multiline content after removing an optional UTF-8 BOM. Files larger than 4 MiB are rejected before dispatch. - After transient handshake retries, a Gateway timeout or closed connection
fails the command with a stderr hint; the CLI never silently reruns the turn
embedded. The Gateway may still finish an accepted turn, so verify Gateway
and session state before retrying or rerunning with
--local. - Session selection:
--toderives the session key (group/channel targets preserve isolation; direct chats collapse tomain). With--agent,--channel, and--totogether, routing follows the channel’s canonical recipient andsession.dmScope. Stable outbound-only identities use a provider-owned session isolated from the agent’s main session. --session-keyselects an explicit key. Agent-prefixed keys must useagent:<agent-id>:<session-key>, and--agentmust match that agent id when both are supplied. Bare non-sentinel keys are scoped to--agentwhen supplied; for example,--agent ops --session-key incident-42routes toagent:ops:incident-42. Without--agent, bare non-sentinel keys are scoped to the configured default agent. Literalglobalandunknownremain unscoped only when no--agentis supplied.--reply-channeland--reply-accountaffect delivery only.- Thinking and verbose flags persist into the session store.
- Output: plain text by default, or
--jsonfor structured payload + metadata. - With
--json --deliver, the JSON includes delivery status for sent, suppressed, partial, and failed sends. See JSON delivery status.
Examples
Related
Agent CLI reference
Full
openclaw agent flag and option reference.Sub-agents
Background sub-agent spawning.
Sessions
How session keys work and how
--to, --agent, and --session-id resolve them.Slash commands
Native command catalog used inside agent sessions.