CLI 命令
智能体
openclaw agents
管理相互隔离的智能体(工作区 + 身份验证 + 路由)。不带子命令运行 openclaw agents 等同于运行 openclaw agents list。
相关内容:
示例
openclaw agents listopenclaw agents list --bindingsopenclaw agents add work --workspace ~/.openclaw/workspace-workopenclaw agents add work --workspace ~/.openclaw/workspace-work --bind telegram:*openclaw agents add ops --workspace ~/.openclaw/workspace-ops --bind telegram:ops --non-interactiveopenclaw agents bindingsopenclaw agents bind --agent work --bind telegram:opsopenclaw agents unbind --agent work --bind telegram:opsopenclaw agents set-identity --workspace ~/.openclaw/workspace --from-identityopenclaw agents set-identity --agent main --avatar avatars/openclaw.pngopenclaw agents delete work命令界面
agents list
选项:--json、--bindings(包含完整路由规则,而不仅是每个智能体的数量/摘要)。
agents add [name]
选项:--workspace <dir>、--model <id>、--agent-dir <dir>、--bind <channel[:accountId]>(可重复使用)、--non-interactive、--json。
- 传入任何显式的添加选项都会将命令切换到非交互式路径。
- 非交互模式同时需要智能体名称和
--workspace。 main是保留标识符,不能用作新智能体 ID。- 交互模式仅通过复制可移植的静态凭据(
api_key和静态token配置文件)来初始化身份验证,除非某项凭据通过copyToAgents: false明确禁止复制;OAuth 刷新令牌配置文件不会被复制,除非提供商通过copyToAgents: true明确启用复制。如果未复制,OAuth 只能通过从真实main智能体存储中读取继承来使用。如果配置的默认智能体不是main,请在新智能体上为 OAuth 配置文件单独登录。
agents bindings
选项:--agent <id>、--json。
agents bind
选项:--agent <id>(默认为当前默认智能体)、--bind <channel[:accountId]>(可重复使用)、--json。
agents unbind
选项:--agent <id>(默认为当前默认智能体)、--bind <channel[:accountId]>(可重复使用)、--all、--json。可接受 --all 或一个或多个 --bind 值,但不能同时使用两者。
agents set-identity
选项:--agent <id>、--workspace <dir>、--identity-file <path>、--from-identity、--name <name>、--theme <theme>、--emoji <emoji>、--avatar <value>、--json。请参阅下文的设置身份。
agents delete <id>
选项:--force、--json。
- 无法删除
main。 - 不使用
--force时,需要交互式确认(在非 TTY 会话中会失败;请使用--force重新运行)。 - 工作区、智能体状态和会话转录目录会移至废纸篓,而不是被永久删除。
- 当 Gateway 网关可访问时,删除操作会通过 Gateway 网关执行,使配置和会话存储清理与运行时流量使用同一写入方。如果 Gateway 网关不可访问,CLI 会回退到离线本地路径。
- 如果另一个智能体的工作区与此工作区路径相同、位于此工作区内或包含此工作区,则会保留该工作区,并且
--json会报告workspaceRetained、workspaceRetainedReason和workspaceSharedWith。
路由绑定
使用路由绑定将入站渠道流量固定到特定智能体。
如果还希望每个智能体显示不同的技能,请在 openclaw.json 中配置 agents.defaults.skills 和 agents.list[].skills。请参阅 Skills 配置和配置参考。
列出绑定:
openclaw agents bindingsopenclaw agents bindings --agent workopenclaw agents bindings --json添加绑定:
openclaw agents bind --agent work --bind telegram:ops --bind discord:guild-a你也可以在创建智能体时添加绑定:
openclaw agents add work --workspace ~/.openclaw/workspace-work --bind telegram:* --bind discord:*如果省略 accountId(--bind <channel>),OpenClaw 会从插件设置钩子、强制账户绑定或该渠道配置的账户数量中解析它。
如果为 bind 或 unbind 省略 --agent,OpenClaw 会以当前默认智能体为目标。
--bind 格式
| 格式 | 含义 |
|---|---|
--bind <channel>:* |
匹配该渠道上的所有账户。 |
--bind <channel>:<account> |
匹配一个账户。 |
--bind <channel> |
仅匹配默认账户,除非 CLI 可以安全地解析插件特定的账户范围。 |
绑定范围行为
- 存储的不含
accountId的绑定仅匹配渠道默认账户。 accountId: "*"是渠道范围的回退项(所有账户),其具体程度低于显式账户绑定。- 如果同一智能体已有不含
accountId的匹配渠道绑定,而你随后使用显式或解析得到的accountId进行绑定,OpenClaw 会就地升级该现有绑定,而不是添加重复项。
示例:
# 匹配该渠道上的所有账户openclaw agents bind --agent work --bind telegram:* # 匹配特定账户openclaw agents bind --agent work --bind telegram:ops # 初始的仅渠道绑定openclaw agents bind --agent work --bind telegram # 稍后升级为账户范围绑定openclaw agents bind --agent work --bind telegram:alerts升级后,该绑定的路由范围限定为 telegram:alerts。如果还需要默认账户路由,请显式添加它(例如 --bind telegram:default)。
移除绑定:
openclaw agents unbind --agent work --bind telegram:opsopenclaw agents unbind --agent work --all身份文件
每个智能体工作区都可以在工作区根目录中包含一个 IDENTITY.md:
- 示例路径:
~/.openclaw/workspace/IDENTITY.md set-identity --from-identity从工作区根目录(或显式指定的--identity-file)读取。
头像路径相对于工作区根目录解析,即使通过符号链接也不能逸出工作区。
设置身份
set-identity 将字段写入 agents.list[].identity:name、theme、emoji、avatar(工作区相对路径、HTTP(S) URL 或数据 URI)。
--agent或--workspace用于选择目标智能体。如果--workspace匹配多个智能体,命令会失败并要求你传入--agent。- 本地工作区相对头像图像文件的大小上限为 2 MB。HTTP(S) URL 和
data:URI 不受本地文件大小限制检查。 - 未提供显式身份字段时,该命令会从
IDENTITY.md读取身份数据。
从 IDENTITY.md 加载:
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity显式覆盖字段:
openclaw agents set-identity --agent main --name "OpenClaw" --emoji "🦞" --avatar avatars/openclaw.png配置示例:
{ agents: { list: [ { id: "main", identity: { name: "OpenClaw", theme: "space lobster", emoji: "🦞", avatar: "avatars/openclaw.png", }, }, ], },}