Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
155 lines
6.6 KiB
Markdown
155 lines
6.6 KiB
Markdown
---
|
|
summary: "Run agent turns from the CLI and optionally deliver replies to channels"
|
|
read_when:
|
|
- You want to trigger agent runs from scripts or the command line
|
|
- You need to deliver agent replies to a chat channel programmatically
|
|
title: "Agent send"
|
|
---
|
|
|
|
`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](/cli/agent).
|
|
|
|
## Quick start
|
|
|
|
<Steps>
|
|
<Step title="Run a simple agent turn">
|
|
```bash
|
|
openclaw agent --agent main --message "What is the weather today?"
|
|
```
|
|
|
|
Sends the message through the Gateway and prints the reply.
|
|
|
|
</Step>
|
|
|
|
<Step title="Send a multiline prompt from a file">
|
|
```bash
|
|
openclaw agent --agent ops --message-file ./task.md
|
|
```
|
|
|
|
Reads a valid UTF-8 file as the agent message body.
|
|
|
|
</Step>
|
|
|
|
<Step title="Target a specific agent or session">
|
|
```bash
|
|
# Target a specific agent
|
|
openclaw agent --agent ops --message "Summarize logs"
|
|
|
|
# Target a phone number (derives session key)
|
|
openclaw agent --to +15555550123 --message "Status update"
|
|
|
|
# Reuse an existing session
|
|
openclaw agent --session-id abc123 --message "Continue the task"
|
|
|
|
# Target an exact session key
|
|
openclaw agent --session-key agent:ops:incident-42 --message "Summarize status"
|
|
```
|
|
|
|
</Step>
|
|
|
|
<Step title="Deliver the reply to a channel">
|
|
```bash
|
|
# Deliver to WhatsApp (default channel)
|
|
openclaw agent --to +15555550123 --message "Report ready" --deliver
|
|
|
|
# Deliver to Slack
|
|
openclaw agent --agent ops --message "Generate report" \
|
|
--deliver --reply-channel slack --reply-to "#reports"
|
|
```
|
|
|
|
</Step>
|
|
</Steps>
|
|
|
|
## Flags
|
|
|
|
| Flag | Description |
|
|
| --------------------------- | -------------------------------------------------------------------- |
|
|
| `--message <text>` | Inline message to send |
|
|
| `--message-file <path>` | Read the message from a valid UTF-8 file |
|
|
| `--to <dest>` | Derive session key from a target (phone, chat id) |
|
|
| `--session-key <key>` | Use an explicit session key |
|
|
| `--agent <id>` | Target a configured agent (uses its `main` session) |
|
|
| `--session-id <id>` | Reuse an existing session by id |
|
|
| `--model <id>` | Model override for this run (`provider/model` or model id) |
|
|
| `--local` | Force local embedded runtime (skip Gateway) |
|
|
| `--deliver` | Send the reply to a chat channel |
|
|
| `--channel <name>` | Delivery channel (discord, slack, telegram, whatsapp, etc.) |
|
|
| `--reply-to <target>` | Delivery target override |
|
|
| `--reply-channel <name>` | Delivery channel override |
|
|
| `--reply-account <id>` | Delivery account id override |
|
|
| `--thinking <level>` | Set thinking level for the selected model profile |
|
|
| `--verbose <on\|full\|off>` | Persist verbose level for the session (`full` also logs tool output) |
|
|
| `--timeout <seconds>` | Override agent timeout (default 600, or config value) |
|
|
| `--json` | Output structured JSON |
|
|
|
|
## Behavior
|
|
|
|
- By default, the CLI goes **through the Gateway**. Add `--local` to force the
|
|
embedded runtime on the current machine.
|
|
- Pass exactly one of `--message` or `--message-file`. File messages preserve
|
|
multiline content after removing an optional UTF-8 BOM.
|
|
- If the Gateway request fails, the CLI **falls back** to the local embedded
|
|
run; a Gateway timeout falls back with a fresh session instead of racing the
|
|
original transcript.
|
|
- Session selection: `--to` derives the session key (group/channel targets
|
|
preserve isolation; direct chats collapse to `main`).
|
|
- `--session-key` selects an explicit key. Agent-prefixed keys must use
|
|
`agent:<agent-id>:<session-key>`, and `--agent` must match that agent id when
|
|
both are supplied. Bare non-sentinel keys are scoped to `--agent` when
|
|
supplied; for example, `--agent ops --session-key incident-42` routes to
|
|
`agent:ops:incident-42`. Without `--agent`, bare non-sentinel keys are scoped
|
|
to the configured default agent. Literal `global` and `unknown` remain
|
|
unscoped only when no `--agent` is supplied; the embedded fallback path
|
|
resolves those sentinel sessions to the configured default agent.
|
|
- `--channel`, `--reply-channel`, and `--reply-account` affect reply delivery,
|
|
not session routing.
|
|
- Thinking and verbose flags persist into the session store.
|
|
- Output: plain text by default, or `--json` for structured payload + metadata.
|
|
- With `--json --deliver`, the JSON includes delivery status for sent,
|
|
suppressed, partial, and failed sends. See
|
|
[JSON delivery status](/cli/agent#json-delivery-status).
|
|
|
|
## Examples
|
|
|
|
```bash
|
|
# Simple turn with JSON output
|
|
openclaw agent --to +15555550123 --message "Trace logs" --verbose on --json
|
|
|
|
# Turn with a model override
|
|
openclaw agent --agent ops --model openai/gpt-5.4 --message "Summarize logs"
|
|
|
|
# Turn with thinking level
|
|
openclaw agent --session-id 1234 --message "Summarize inbox" --thinking medium
|
|
|
|
# Multiline prompt from a file
|
|
openclaw agent --agent ops --message-file ./task.md
|
|
|
|
# Exact session key
|
|
openclaw agent --session-key agent:ops:incident-42 --message "Summarize status"
|
|
|
|
# Legacy key scoped to an agent
|
|
openclaw agent --agent ops --session-key incident-42 --message "Summarize status"
|
|
|
|
# Deliver to a different channel than the session
|
|
openclaw agent --agent ops --message "Alert" --deliver --reply-channel telegram --reply-to "@admin"
|
|
```
|
|
|
|
## Related
|
|
|
|
<CardGroup cols={2}>
|
|
<Card title="Agent CLI reference" href="/cli/agent" icon="terminal">
|
|
Full `openclaw agent` flag and option reference.
|
|
</Card>
|
|
<Card title="Sub-agents" href="/tools/subagents" icon="users">
|
|
Background sub-agent spawning.
|
|
</Card>
|
|
<Card title="Sessions" href="/concepts/session" icon="comments">
|
|
How session keys work and how `--to`, `--agent`, and `--session-id` resolve them.
|
|
</Card>
|
|
<Card title="Slash commands" href="/tools/slash-commands" icon="slash">
|
|
Native command catalog used inside agent sessions.
|
|
</Card>
|
|
</CardGroup>
|