How to Use the Openclaw Agent Command

Image
Table of contents: [Show]

Quick Start

The openclaw agent command lets you run AI tasks directly from your terminal. Whether you need a quick summary, code review, or status update, this command connects you to your configured agents without opening a chat interface.

Openclaw Agent Command

For more advanced automation, you might also want to explore LLM Task Openclaw for structured task execution. If you're new to Openclaw's command structure, check out our guide on ACP Commands Openclaw for a complete overview.

Required Parameter

Every agent command needs a message:

--message <text>: The prompt or task you want to send to the agent

Session Selection

Control which session context your agent uses:

Target by Destination

--to <dest>: Derives the session key based on the destination. Direct chats collapse to the main session, while group/channel targets preserve their isolation.

Reuse Existing Session

--session-id <id>: Reuses a specific, existing session by its ID.

Target Specific Agent

--agent <id>: Targets a configured agent directly, using that agent's main session key.

Delivery Options

Send agent replies to chat channels instead of just printing to terminal:

  • --deliver: Instructs OpenClaw to send the final reply to the chosen channel
  • --channel <name>: Specifies the delivery channel (whatsapp, telegram, discord, slack, mattermost, signal, imessage, msteams). Defaults to whatsapp
  • --reply-to <dest>: Overrides the delivery target without changing the session context
  • --reply-channel <name>: Overrides the delivery channel without changing the session context
  • --reply-account <id>: Overrides the delivery account ID

Execution & Output Flags

Local Execution

--local: Forces the embedded agent runtime to run locally on your current machine rather than via the Gateway. Requires your model provider API keys to be present in your shell environment.

Thinking Level

--thinking <level>: Persists a thinking level override into the session store. Options: off, minimal, low, medium, high, xhigh.

Output Control

  • --verbose <on|full|off>: Controls the verbosity of the output
  • --json: Prints the structured payload and metadata as JSON instead of plain text
  • --timeout <seconds>: Sets a timeout for the agent run
Openclaw Tool Loop

Practical Examples

Standard Local Run

Run an agent and print output to terminal:

openclaw agent --agent ops --message "Summarize logs"

Target Existing Session with Thinking

Reuse a session and enable medium thinking level:

openclaw agent --session-id 1234 --message "Summarize inbox" --thinking medium

Deliver Reply to WhatsApp

Run agent and send result to a WhatsApp contact:

openclaw agent --to +15555550123 --message "status update" --deliver

Override Delivery to Slack

Send agent output to a Slack channel:

openclaw agent --agent ops --message "Generate report" --deliver --reply-channel slack --reply-to "#reports"

Troubleshooting & Best Practices

  • API Keys Missing: When using --local, ensure your provider API keys are exported in your shell environment
  • Session Not Found: Verify the --session-id exists using openclaw sessions list
  • Delivery Failed: Check that the target channel is properly configured in your Openclaw settings
  • Timeout Issues: Increase --timeout for long-running tasks like code analysis
  • JSON Output: Use --json when piping results to other scripts or tools

The agent command is your direct line to AI assistance from the terminal. Combine it with shell scripts for powerful automation workflows.