Skip to content

OpenClaw 維運篇:疑難排解與診斷

2026年3月28日 1 分鐘
TL;DR openclaw doctor 是一站式診斷工具,openclaw sandbox explain 排查沙箱問題,openclaw channels status --probe 檢查頻道連線。

系統跑起來後總會遇到問題。這篇整理 OpenClaw 的診斷工具和常見問題解法。

一站式診斷:openclaw doctor

openclaw doctor                  # 完整診斷
openclaw doctor --fix            # 嘗試自動修復
openclaw doctor --json           # JSON 輸出

doctor 檢查:

  • 設定檔 schema 驗證
  • 模型認證狀態
  • 頻道連線
  • 沙箱設定
  • Plugin 狀態
  • 權限和路徑

常見問題

模型認證

症狀排查
No credentials foundopenclaw models status,確認 API key 或 token
Token expiredopenclaw models status 查看哪個 profile 過期
Rate limited檢查 API key 輪替設定
openclaw models status           # 查看認證狀態
openclaw models status --check   # 自動化(exit 1 = 過期)
openclaw models status --probe   # 主動探測

頻道連線

openclaw channels status         # 列出頻道狀態
openclaw channels status --probe # 主動探測連線
症狀排查
訊息收不到檢查 policy → allowlist → mention → user restrictions
DM 問題dm.enabled → policy → pairing approvals
群組問題group policy → sender allowlist → mention gating

沙箱

openclaw sandbox explain         # 查看有效設定
openclaw sandbox explain --agent work
openclaw sandbox explain --json
症狀排查
Tool blocked檢查 tools.sandbox.tools.deny
不該被沙箱檢查 sandbox.modenon-main 下群組/頻道都算非 main)
setupCommand 失敗檢查網路(預設 none)、readOnlyRoot、user 權限

Session

openclaw sessions list           # 列出 session
openclaw sessions cleanup --dry-run  # 預覽清理
症狀排查
對話混在一起檢查 session.dmScope(多人 DM 不要用 main
Context 太長手動 /compact 或調整 compaction 設定
Memory 遺失檢查 memory flush 設定

Gateway 網路

openclaw health                  # 檢查 Gateway 健康
openclaw gateway status          # Gateway 狀態
症狀排查
連不到 Gateway檢查 gateway.bind 和 port
WebSocket 斷線檢查 reverse proxy 的 WS 支援
Trusted proxy 失敗檢查 trustedProxies IP

安全審計

openclaw security audit          # 安全配置檢查

檢查:

  • Trusted proxy auth 配置
  • 缺少 trustedProxies
  • 空的 allowUsers
  • 不安全的 safeBins(直譯器/runtime)
  • 缺少的 safeBinProfiles

日誌

OpenClaw 的日誌輸出包含結構化的診斷碼(如 SECRETS_REF_IGNORED_INACTIVE_SURFACESECRETS_GATEWAY_AUTH_SURFACE),可以用來追蹤特定行為。

維護排程

{
  session: {
    maintenance: {
      mode: "enforce",         // warn | enforce
      pruneAfterDays: 30,
      maxEntries: 500,
      rotationThresholdMb: 10
    }
  }
}

正式環境建議 enforce 模式自動清理。

有用的指令速查

指令功能
openclaw doctor全面診斷
openclaw doctor --fix自動修復
openclaw healthGateway 健康
openclaw models status模型認證
openclaw channels status --probe頻道探測
openclaw sandbox explain沙箱設定
openclaw security audit安全審計
openclaw sessions cleanup --dry-run預覽清理
openclaw config validate設定驗證
/context detailContext 大小明細
/tools verbose可用工具詳細

整體來說

OpenClaw 的維運工具很完整——doctor 一站式診斷、sandbox explain 查沙箱、channels status --probe 查連線、security audit 查安全。遇到問題時,先跑 doctor,再根據症狀深入排查。

參考資料

本篇整理自以下 OpenClaw 原始文件: