| name | openclaw-agent-run |
| description | Direct agent CLI invocations in OpenClaw. Use when running the `openclaw agent` command to trigger agent turns, targeting sessions or agents programmatically, delivering replies to channels, using --json output for automation, overriding thinking/verbose levels, or understanding session selection logic. Triggers for: "openclaw agent", "direct agent run", "send a message to agent", "--deliver", "--session-id", "agent turn", "CLI agent", "thinking level", "verbose mode", "--json output". |
Direct Agent Runs (openclaw agent)
Basic Usage
openclaw agent --agent main --message "Summarize the latest logs"
openclaw agent --to +15555550123 --message "Status update please"
openclaw agent --session-id {sessionId} --message "Continue from where we left off"
Session Selection Rules
--agent {id} → targets that agent's main session key
--to {dest} → derives session from destination (group chats keep isolation; direct → main)
--session-id {id} → reuses exact session by ID (stable, OpenClaw-chosen IDs)
- No flags → defaults to
main agent on default session
Output Modes
openclaw agent --agent main --message "Hello"
openclaw agent --agent main --message "Hello" --json
JSON output shape:
{
"text": "...",
"media": [],
"sessionId": "...",
"runId": "...",
"agentId": "main",
"model": "anthropic/claude-sonnet-4-5"
}
Delivery to Channel
openclaw agent --to +15555550123 --message "Check the server" --deliver
openclaw agent --agent ops --message "Generate report" \
--deliver \
--reply-channel slack \
--reply-to "#reports"
Thinking & Verbose Flags
Both persist into the session store (affect future turns too):
openclaw agent --agent main --message "Debug this" --thinking high
openclaw agent --agent main --message "Trace logs" --verbose full
Note: --thinking levels only work with models that support extended thinking (GPT-5.2, Codex, Claude 3.7+).
Timeout Override
openclaw agent --agent main --message "Long analysis" --timeout 900
Default: 600s (10 min). Override for tasks known to be slow.
Local vs Gateway
openclaw agent --local --agent main --message "Hello"
See references/automation-recipes.md for common automation patterns using openclaw agent in scripts.