跳到內容

OpenClaw Agents 管理指南:快速建立、設定與自訂身分

在開發 AI 應用的過程中,管理多個不同的 Agent 往往會變得非常混亂。你可能需要為不同的專案隔離 Workspace,或者為特定的通訊頻道設定專屬的路由與身分,但又不希望這些設定全部擠在一起。

openclaw agents 指令就是為了簡化這些工作而設計的,讓你能夠輕鬆管理隔離的 Agent 環境,包含它們的 Workspace、驗證資訊以及路由規則。

管理隔離的 Agent(包含 Workspace、驗證與路由設定)。

相關連結:

Terminal window
openclaw agents list
openclaw agents list --bindings
openclaw agents add work --workspace ~/.openclaw/workspace-work
openclaw agents add ops --workspace ~/.openclaw/workspace-ops --bind telegram:ops --non-interactive
openclaw agents bindings
openclaw agents bind --agent work --bind telegram:ops
openclaw agents unbind --agent work --bind telegram:ops
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity
openclaw agents set-identity --agent main --avatar avatars/openclaw.png
openclaw agents delete work

使用路由綁定(Routing bindings)將特定頻道的流量固定到某個 Agent。

如果你希望每個 Agent 擁有不同的可見 Skill,請在 openclaw.json 中配置 agents.defaults.skills 和 agents.list[].skills。參考 Skills config 與 Configuration Reference。

列出綁定:

Terminal window
openclaw agents bindings
openclaw agents bindings --agent work
openclaw agents bindings --json

新增綁定:

Terminal window
openclaw agents bind --agent work --bind telegram:ops --bind discord:guild-a

如果你省略了 accountId(例如 --bind <channel>),OpenClaw 會從頻道預設值和插件設定 Hook 中解析它(如果可用)。

如果在執行 bind 或 unbind 時省略了 --agent,OpenClaw 會以目前的預設 Agent 為目標。

  • 沒有 accountId 的綁定僅會匹配頻道的預設帳號。
  • accountId: "*" 是頻道範圍的備選方案(所有帳號),其優先級低於明確的帳號綁定。
  • 如果同一個 Agent 已經有一個不帶 accountId 的匹配頻道綁定,而你稍後使用明確或解析出的 accountId 進行綁定,OpenClaw 會直接更新該現有綁定,而不是新增一個重複項。

範例:

Terminal window
# initial channel-only binding
openclaw agents bind --agent work --bind telegram
# later upgrade to account-scoped binding
openclaw agents bind --agent work --bind telegram:ops

升級後,該綁定的路由將被限定在 telegram:ops。如果你也需要預設帳號的路由,請明確地新增它(例如 --bind telegram:default)。

移除綁定:

Terminal window
openclaw agents unbind --agent work --bind telegram:ops
openclaw agents unbind --agent work --all

unbind 僅接受 --all 或一個以上的 --bind 值,不能同時使用兩者。

執行 openclaw agents 而不帶任何子指令,等同於執行 openclaw agents list。

選項:

  • --json
  • --bindings:包含完整的路由規則,而不僅是每個 Agent 的計數或摘要。

選項:

  • --workspace <dir>
  • --model <id>
  • --agent-dir <dir>
  • --bind <channel[:accountId]>(可重複使用)
  • --non-interactive
  • --json

備註:

  • 傳入任何明確的新增旗標(flags)都會將指令切換到非互動模式。
  • 非互動模式需要同時提供 Agent 名稱與 --workspace。
  • main 是保留字,不能用作新的 Agent ID。

選項:

  • --agent <id>
  • --json

選項:

  • --agent <id>(預設為目前的預設 Agent)
  • --bind <channel[:accountId]>(可重複使用)
  • --json

選項:

  • --agent <id>(預設為目前的預設 Agent)
  • --bind <channel[:accountId]>(可重複使用)
  • --all
  • --json

選項:

  • --force
  • --json

備註:

  • main 無法被刪除。
  • 若未使用 --force,則需要進行互動式確認。
  • Workspace、Agent 狀態和 Session 紀錄目錄會被移至垃圾桶,而非直接刪除。

每個 Agent Workspace 的根目錄都可以包含一個 IDENTITY.md 檔案:

  • 範例路徑:~/.openclaw/workspace/IDENTITY.md
  • set-identity --from-identity 會從 Workspace 根目錄(或明確指定的 --identity-file)讀取內容。

Avatar(頭像)路徑會相對於 Workspace 根目錄進行解析。

set-identity 會將欄位寫入 agents.list[].identity:

  • name
  • theme
  • emoji
  • avatar(Workspace 相對路徑、http(s) URL 或 data URI)

選項:

  • --agent <id>
  • --workspace <dir>
  • --identity-file <path>
  • --from-identity
  • --name <name>
  • --theme <theme>
  • --emoji <emoji>
  • --avatar <value>
  • --json

備註:

  • 可以使用 --agent 或 --workspace 來選擇目標 Agent。
  • 如果你依賴 --workspace 且有多個 Agent 共用該 Workspace,指令會失敗並要求你傳入 --agent。
  • 當沒有提供明確的身分欄位時,指令會從 IDENTITY.md 讀取身分資料。

從 IDENTITY.md 載入:

Terminal window
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity

明確覆蓋欄位:

Terminal window
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",
},
},
],
},
}

AI Setup Assistant

OpenClaw

OpenClaw Expert

還是卡住了?

如果這篇文件沒有解決你的情境,直接問 OpenClaw Expert,拿到可執行步驟。