#我想要和agent bot 对话

1 messages · Page 1 of 1 (latest)

quiet bladeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

frank forumBOT
#

你现在这段配置里最关键的问题是:tools.allow 一旦设置,就会进入“白名单模式”(只剩 allow 里的工具)。你贴的片段是:

tools: {
  profile: "full",
  allow: ["group:runtime"]
}

这会导致只剩下 exec/bash/processgroup:runtime),反而把 messageweb_fetchsessions_spawn 等全禁掉。所以你感觉“只有 message / 或工具很少”基本都和这里有关。

下面给你两套“可落地”的多智能体方案(都 step-by-step,包含要改的文件/命令/聊天里该发什么)。


方案 A(推荐起步):多智能体 = 多个 agent + Discord 不同频道路由(最稳)

#

Step 0:先确认版本/状态(方便排错)

在 Gateway 机器上跑:

openclaw --version
openclaw status
openclaw models status

(如果后面有问题,把输出脱敏贴出来就能继续推进)

Step 1:把全局工具策略改正确(先别用 tools.allow

目标:先让系统恢复“默认可用”,再按 agent 去收紧权限。

执行:

#
openclaw config unset tools.allow
openclaw config unset tools.deny
openclaw config set tools.profile "messaging"
openclaw gateway restart

解释:

  • messaging profile 会给你最安全的一套:message + 基本会话工具(sessions_list/history/sendsession_status
  • 先别上 allow,否则很容易误伤把工具全禁了
    工具文档(中文):https://docs.openclaw.ai/zh-CN/tools

Step 2:创建两个独立 agent(工作区隔离)

例如一个“日常聊天”、一个“coding/执行”:

#
openclaw agents add chat
openclaw agents add coding

创建后你可以检查:

openclaw agents list --bindings

多智能体路由文档(中文):https://docs.openclaw.ai/zh-CN/concepts/multi-agent

Step 3:给 coding agent 更高的工具权限(只给它,不给全局)

编辑 ~/.openclaw/openclaw.json(JSON5)里 agents.list,给 coding 单独设置工具 profile:

#
{
  tools: { profile: "messaging" }, // 全局默认:只消息 + 会话状态(安全)

  agents: {
    list: [
      { id: "chat", default: true, workspace: "~/.openclaw/workspace-chat" },

      {
        id: "coding",
        workspace: "~/.openclaw/workspace-coding",
        tools: { profile: "coding" } // coding:fs + runtime + sessions + memory + image
      }
    ]
  }
}
#

改完重启:

openclaw gateway restart

注意:新增 agent 后,如果它报“没找到凭证/No API key…”,原因是auth profiles 是每个 agent 独立的。最简单做法是把 main/chat 的 auth profiles 复制给 coding(路径见文档)。多智能体文档里有明确说明:~/.openclaw/agents/<agentId>/agent/auth-profiles.json

Step 4:Discord 路由:用不同频道绑定到不同 agent

你需要两个 Discord 频道(比如 #chat#coding),拿到各自 channel ID(Discord 开启 Developer Mode,右键频道 Copy ID)。

openclaw.json 加 bindings(示例):

{
  bindings: [
#
    {
      agentId: "coding",
      match: { channel: "discord", peer: { kind: "channel", id: "CODING_CHANNEL_ID" } }
    },
    {
      agentId: "chat",
      match: { channel: "discord", peer: { kind: "channel", id: "CHAT_CHANNEL_ID" } }
    }
  ]
}

重启 Gateway:

#
openclaw gateway restart

Step 5:你在 Discord 里怎么“用多智能体”(prompt 怎么发)

  • #chat 里发:日常对话/需求描述
  • #coding 里发:明确执行指令(写代码/跑命令/改文件)

建议你固定这类 prompt 模板(直接复制就能用):

#chat:让它先拆解任务

“把这个需求拆成 1) 调研/澄清问题 2) 可执行步骤 3) 验收标准。需要写代码的部分我会发到 #coding。”

#coding:给明确目标 + 验收方式

“目标:xxx。约束:只能在 workspace 里改动。输出:1) 修改了哪些文件 2) 如何运行/验证 3) 如果失败怎么回滚。”


#

方案 B:多智能体 = 子智能体(Subagents)并行干活(适合一个频道里开“分身”)

如果你不想搞多个频道,这个更像“在同一个对话里并行开几个工人”。

Step 1:直接在 Discord 里用命令(不需要你手动写 tool call)

在聊天里发(独立一条消息):

/subagents spawn coding 把我这段需求变成可执行的实现步骤,并列出需要改的文件

然后查看进度:

/subagents list
/subagents log 1 200 tools
#

子智能体文档(中文):https://docs.openclaw.ai/zh-CN/tools/subagents
斜杠命令文档(中文):https://docs.openclaw.ai/zh-CN/tools/slash-commands

Step 2(可选但很爽):开启 Discord thread 绑定,让每个子智能体在一个 thread 里持续对话

openclaw.json 里加(然后重启):

{
  session: { threadBindings: { enabled: true, idleHours: 24, maxAgeHours: 0 } },
  channels: {
    discord: {
      threadBindings: {
        enabled: true,
        idleHours: 24,
        maxAgeHours: 0,
        spawnSubagentSessions: true
#
      }
    }
  }
}

Discord thread 绑定说明在 FAQ/Discord 文档里也有提到(你之后如果需要我可以帮你对照你当前配置逐行校验)。


你现在最该贴出来的 3 个信息(脱敏即可)

为了把方案落到你当前这台 Mac + Qwen Portal 的实际配置上,建议你补充:

  1. openclaw --version
  2. openclaw models status(看 provider/model 是否真的可用)
  3. 你想要的“多智能体形态”是哪种:
#
  • 选 A:多个频道/多个 agent(最稳定)
  • 选 B:一个频道里大量用 /subagents spawn 并行(最方便)

你回复我:你更想选 A 还是 B,以及你现在 Discord 里准备怎么分频道/线程,我就按你的实际 channel id 给你一份“可直接粘贴进 openclaw.json 的完整 bindings + agents.list 示例”。

#

你这段 openclaw.json 里,**真正影响“我只有 message / 工具很少”**的点基本就在这句:

tools: { profile: "full", allow: ["group:runtime"] }

只要你设置了 tools.allow,就会进入白名单模式:最后只剩 allow 里的工具。group:runtime 只包含 exec/bash/process,会把 messageweb_fetchsessions_spawn 等全部排除掉(除非你也把它们加进 allow)。

另外,楼上那条“Ask here”的奇怪链接看起来非常可疑(像是钓鱼/注入),建议别点;以官方文档和你本机 CLI 输出为准。


你要的“具体 step-by-step”(从你现在的配置直接改)

Step 1:先把 tools 白名单关掉,恢复正常(推荐)

在 Gateway 机器上执行:

#
openclaw config unset tools.allow
openclaw config set tools.profile "messaging"
openclaw gateway restart

解释:

如果你希望“全工具都能用”(不推荐一上来就开),那就:

openclaw config unset tools.allow
openclaw config set tools.profile "full"
openclaw gateway restart
#

Step 2:创建两个 agent(多智能体的“隔离工作区”)

openclaw agents add chat
openclaw agents add coding

检查是否创建成功:

openclaw agents list --bindings

多智能体路由文档(中文):https://docs.openclaw.ai/zh-CN/concepts/multi-agent

Step 3:给 coding agent 更高权限(只给它,不给全局)

编辑 ~/.openclaw/openclaw.json,把全局保持“messaging”,coding 单独用 “coding”:

#
{
  tools: { profile: "messaging" },

  agents: {
    list: [
      { id: "chat", default: true, workspace: "~/.openclaw/workspace-chat" },
      { id: "coding", workspace: "~/.openclaw/workspace-coding", tools: { profile: "coding" } }
    ]
  }
}

改完:

#
openclaw gateway restart

注意:新增 agent 后,如果 coding agent 提示没凭证/登录信息,原因是 auth profiles 是按 agent 隔离的。需要对 coding 单独登录,或把 auth-profiles.jsonchat/main 复制过去(multi-agent 文档里有路径说明)。

Step 4:在 Discord 里怎么“用多智能体”

你有两种最常用方式:

方式 A(最稳):两个频道分别绑定不同 agent

  • #chat 只聊天
  • #coding 专门执行/写代码
    然后在 bindings 里用 peer.kind:"channel" 绑定到对应频道 ID(见 multi-agent 文档示例)。

方式 B(一个频道也能并行):用子智能体
直接在 Discord 里发(独立一条消息):

#
/subagents spawn coding 把需求拆成可执行步骤,并输出要改的文件清单
/subagents list

子智能体文档(中文):https://docs.openclaw.ai/zh-CN/tools/subagents
斜杠命令文档(中文):https://docs.openclaw.ai/zh-CN/tools/slash-commands


你现在补 2 个信息,我就能把“bindings/频道ID/模型选择”给你写成可直接粘贴的完整样例

  1. 你希望用 方式 A(两个频道) 还是 方式 B(/subagents 并行)
  2. 贴一下这两个命令输出(脱敏即可):
openclaw --version
#
openclaw models status
sonic flicker
#

我现在 配置了一个本地的大模型 provider 我想要给我的 openclaw 添加一个本地的 provider.acBook-Pro  ~  openclaw models status

🦞 OpenClaw 2026.3.8 (3caab92) — I'll do the boring stuff while you dramatically stare at the logs like it's cinema.

Config : ~/.openclaw/openclaw.json
Agent dir : ~/.openclaw/agents/main/agent
Default : custom-127-0-0-1-8317/gpt-5.3-codex
Fallbacks (0) : -
Image model : -
Image fallbacks (0): -
Aliases (2) : qwen -> qwen-portal/coder-model, opus46 -> terminal-anthropic/claude-opus-4-6
Configured models (4): qwen-portal/coder-model, qwen-portal/vision-model, custom-127-0-0-1-8317/gpt-5.3-codex, terminal-anthropic/claude-opus-4-6

Auth overview
Auth store : ~/.openclaw/agents/main/agent/auth-profiles.json
Shell env : off
Providers w/ OAuth/tokens (1): qwen-portal (1)

  • custom-127-0-0-1-8317 effective=models.json:sk-g6SdL...QSltjp8i | models.json=sk-g6SdL...QSltjp8i | source=models.json: ~/.openclaw/agents/main/agent/models.json
  • qwen-portal effective=profiles:~/.openclaw/agents/main/agent/auth-profiles.json | profiles=1 (oauth=1, token=0, api_key=0) | qwen-portal:default=OAuth | models.json=marker(qwen-oauth) | source=models.json: ~/.openclaw/agents/main/agent/models.json
  • terminal-anthropic effective=models.json:sk-RMnZq...2lQdkWhq | models.json=sk-RMnZq...2lQdkWhq | source=models.json: ~/.openclaw/agents/main/agent/models.json

OAuth/token status

  • qwen-portal
    • qwen-portal:default ok expires in 0m
      mumong@mumongdeMacBook-Pro  ~ 

比如custom-127-0-0-1-8317/ 下还有一个claude-opus-4-6的模型我想要添加并且切换他

frank forumBOT
#

你现在这个输出里其实已经有两个“Opus”概念,需要先分清楚,不然会越配越乱:

  1. 真实的 Anthropic Opus 4.6(云端)
    你已经配置好了:terminal-anthropic/claude-opus-4-6,而且还有别名 opus46

  2. 你本地 OpenAI 兼容服务里某个模型的 id 刚好叫 claude-opus-4-6(本地)
    这个只是“名字/id”,不等于真的 Anthropic Opus。只要你的本地 /v1/models 里确实返回了这个 id,OpenClaw 就可以把它当作一个本地模型来切换。

下面按这两种分别给你 step-by-step。


A) 你要切换到“真实 Opus 4.6”(你已经配好了,直接切)

方式 1:CLI 切默认模型

openclaw models set opus46
#
openclaw models status

方式 2:在聊天里切(Discord/Telegram 都行)

发送一条独立消息:

/model opus46

B) 你要在本地 provider custom-127-0-0-1-8317 下新增一个模型 claude-opus-4-6 并切换

Step 1:先确认你的本地服务“真的有这个 model id”

(把端口按你的实际 8317 来)

#
curl -s http://127.0.0.1:8317/v1/models

你要在返回里看到类似(不同服务格式可能不一样,但核心是 id):

  • gpt-5.3-codex
  • claude-opus-4-6

如果这里根本没有 claude-opus-4-6,那 OpenClaw 当然也没法切过去——你得先在本地模型服务(LM Studio / vLLM / llama.cpp server / LiteLLM)里把它暴露成这个 id。

Step 2:让 OpenClaw 重新扫描并把这个模型加入“Configured models”

你贴的 CLI 索引里 models scan 支持按 provider 扫描(官方 CLI 参考里有参数)。先用交互式(更安全):

openclaw models scan --provider custom-127-0-0-1-8317
#

扫完后检查是否出现:

openclaw models list | grep "custom-127-0-0-1-8317"

如果你想它扫描后自动写入并直接设为默认(更激进一点),再用:

openclaw models scan --provider custom-127-0-0-1-8317 --yes --set-default

Step 3:切换到你本地这个“同名模型”

openclaw models set custom-127-0-0-1-8317/claude-opus-4-6
openclaw models status
#

(聊天里同理:)

/model custom-127-0-0-1-8317/claude-opus-4-6

Step 4(可选):给它加个更好记的别名

openclaw models aliases add opus-local custom-127-0-0-1-8317/claude-opus-4-6

之后切换就用:

openclaw models set opus-local

或聊天:

#
/model opus-local

官方文档(你现在这个问题最相关的 2 篇)


我需要你确认 1 件事,才能给你“最准的一步到位命令”

你的本地服务 127.0.0.1:8317 是哪一种?

  • LM Studio?
  • vLLM?
  • llama.cpp llama-server
#
  • LiteLLM?

以及你跑一下把 curl http://127.0.0.1:8317/v1/models 的输出(脱敏)贴一小段(至少包含 id 列表),我就能判断你应该用 openai-completions 还是 openai-responses,以及为什么现在 OpenClaw 只识别到 gpt-5.3-codex 没识别到你说的那个模型。

sonic flicker
#

command 'provider'
✘ mumong@mumongdeMacBook-Pro  ~  openclaw models scan --provider custom-127-0-0-1-8317

🦞 OpenClaw 2026.3.8 (3caab92) — I'll butter your workflow like a lobster roll: messy, delicious, effective.



Error: Missing OpenRouter API key. Set OPENROUTER_API_KEY to run models scan.
✘ mumong@mumongdeMacBook-Pro  ~ 
✘ mumong@mumongdeMacBook-Pro  ~ 
✘ mumong@mumongdeMacBook-Pro  ~ 
✘ mumong@mumongdeMacBook-Pro  ~  openclaw models list | grep "custom-127-0-0-1-8317"
custom-127-0-0-1-8317/gpt-5.3-codex text 16k yes yes default,configured
mumong@mumongdeMacBook-Pro  ~  ro  ~  openclaw models scan --provider custom-127-0-0-1-8317

<0001f99e> OpenClaw 2026.3.8 (3caab92) — I'm not AI-powered, I'm AI-possessed. Big difference.



Error: Missing OpenRouter API key. Set OPENROUTER_API_KEY to run models scan.
✘ mumong@mumongdeMacBook-Pro  ~ 
zsh: command not found: ro
zsh: unknown file attribute: 3
zsh: command not found: │
zsh: command not found: ◇
zsh: command not found: Error:
zsh: command not found: ✘
✘ mumong@mumongdeMacBook-Pro  ~ 
✘ mumong@mumongdeMacBook-Pro  ~ 
✘ mumong@mumongdeMacBook-Pro  ~  curl http://127.0.0.1:8317/v1/models
{"error":"Missing API key"}% mumong@mumongdeMacBook-Pro  ~ 

解决我的问题为什么我 scan 的时候 u需要这个东西

frank forumBOT
#

openclaw models scan 这条命令不是“去扫你本地 http://127.0.0.1:8317/v1/models 然后把模型加进来”的功能。

它是用来“扫描/挑选”一批候选模型(主要走 OpenRouter 的目录/探测 流程),所以它会强依赖 OPENROUTER_API_KEY。你现在没配 OpenRouter key,就会报:

Missing OpenRouter API key. Set OPENROUTER_API_KEY to run models scan.

即使你传了 --provider custom-127-0-0-1-8317,当前实现里也仍然会走到需要 OpenRouter key 的路径(这点我同意很迷惑,甚至可能算个小 bug/UX 问题)。


你真正想做的事:给本地 provider 增加一个“模型条目”并切换

这件事不需要 models scan,而是要把模型加到 models.providers.<providerId>.models[] 里(OpenClaw 启动时会 merge 到 ~/.openclaw/agents/main/agent/models.json)。

官方文档在这里(你这题对应的段落):

#

Step 1:先解释你 curl 为什么失败

你执行:

curl http://127.0.0.1:8317/v1/models

返回 {"error":"Missing API key"},说明你这个本地服务要求 Authorization: Bearer ...

你可以用“随便一个 key”先验证它是不是只检查“有没有 header”(不要把真实 key 发出来):

curl -s \
  -H "Authorization: Bearer test" \
  http://127.0.0.1:8317/v1/models

如果这样就能看到 models 列表,说明 key 不敏感、只是必须带 header。

#

Step 2:把你想要的模型加进配置(推荐改 ~/.openclaw/openclaw.json

openclaw.json 里补上这个 provider(或在已有 provider 下补 models 数组),重点是把 claude-opus-4-6 作为一个 model id 加进去:

{
  models: {
    mode: "merge",
    providers: {
      "custom-127-0-0-1-8317": {
        // 如果你本地服务只要求“有 key”就行,这里填任意字符串即可:
        baseUrl: "http://127.0.0.1:8317/v1",
        apiKey: "test",
        api: "openai-completions",

        models: [
          {
#
            id: "claude-opus-4-6",
            name: "Local (id: claude-opus-4-6)",
            reasoning: false,
            input: ["text"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 128000,
            maxTokens: 8192
          }
        ]
      }
    }
  }
}

然后重启:

#
openclaw gateway restart

Step 3:确认它已经变成“Configured models”

openclaw models list | grep "custom-127-0-0-1-8317"

你期望看到两条:.../gpt-5.3-codex.../claude-opus-4-6

Step 4:切换到它

openclaw models set custom-127-0-0-1-8317/claude-opus-4-6
openclaw models status
#

(在聊天里也可以:/model custom-127-0-0-1-8317/claude-opus-4-6


重要提醒(避免误会)

你本地 provider 下面出现的 claude-opus-4-6 只是你本地服务暴露的 model id 名字,不等于真的 Anthropic Opus。

你现在其实已经有真的 Opus 4.6 可切(云端):

openclaw models set opus46

如果你想把 “models scan 要 OpenRouter key” 当成问题继续追

我建议你把下面两条输出(脱敏)贴一下,我可以判断这是“预期行为”还是确实值得提 issue:

#
openclaw models scan --help
openclaw --version

如果确认 --provider 理应不触发 OpenRouter 依赖,那就可以去 GitHub 提个 issue(把报错和版本贴上去)。

sonic flicker
#

geiwo yige 给我一个完整的 启动和关闭 openclaw 的完整流程包括本体和 gateway 我用的是 mac

frank forumBOT
#

在 mac 上你其实有 3 个“东西”,要先分清楚谁需要启动/关闭:

  1. Gateway(网关进程):真正一直跑着的服务(launchd 后台服务 或 你手动前台跑)。
  2. OpenClaw CLI(openclaw ... 命令):不是常驻进程,不需要“启动”;你每敲一次命令它就执行一次。
  3. OpenClaw.app(mac 菜单栏本体/伴侣应用):UI + 权限 + 节点能力;可以开/关,但它不一定等于 Gateway(本地模式会帮你管理 Gateway 服务,远程模式不会启动本地 Gateway)。

下面给你一套“完整的启动/关闭流程”(含推荐方式 + 备用方式)。


0) 先确认你现在 Gateway 是不是后台服务在跑

openclaw gateway status
openclaw status

#

1) 推荐的日常方式:用 launchd 后台服务运行 Gateway(最稳)

1.1(一次性)安装/注册后台服务

如果你已经跑过 onboarding,通常已经装好了;没装过就跑:

openclaw gateway install

1.2 启动 Gateway(后台)

openclaw gateway start

1.3 验证它真的起来了(并且 RPC 可连)

openclaw gateway status
#
openclaw status

1.4 关闭 Gateway(后台服务停止)

openclaw gateway stop
openclaw gateway status

1.5 重启 Gateway(最常用)

openclaw gateway restart
openclaw gateway status

#

2) 备用方式:前台运行 Gateway(调试/临时跑)

适合你要看实时日志、或者不想装后台服务的时候。

2.1 启动(前台)

openclaw gateway run
# 或:openclaw gateway

想更详细日志:

openclaw gateway run --verbose

2.2 关闭(前台)

在运行的那个终端里按:

  • Ctrl+C(SIGINT)
#

注意:如果你后台服务已经在占用端口(默认 18789),前台启动可能会提示端口占用。那就先 openclaw gateway stop,再前台 openclaw gateway run


3) “本体”OpenClaw.app(mac 菜单栏应用)怎么开/关

3.1 启动 OpenClaw.app

  • Finder → Applications → OpenClaw 打开
    或命令行:
open -a OpenClaw

3.2 关闭 OpenClaw.app

  • 在应用里 Cmd+Q 退出
    或命令行:
#
osascript -e 'quit app "OpenClaw"'

关键点:

  • OpenClaw.app 退出后,Gateway 后台服务不一定会自动停止(取决于你是本地模式还是远程模式、以及你是否安装了 launchd 服务)。
  • 你要“确保 Gateway 也停了”,用这一条最准:
    openclaw gateway stop
    

4) 更底层(可选):用 launchctl 直接踢/卸载服务

如果你想完全绕过 openclaw gateway start/stop,可以用 launchctl(文档里也写了):

#
# 强制重启服务
launchctl kickstart -k gui/$UID/ai.openclaw.gateway

# 卸载/停止服务
launchctl bootout gui/$UID/ai.openclaw.gateway

(如果你用了 profile,label 会变成 ai.openclaw.<profile>


5) 常用的“我到底开没开”的检查命令

openclaw gateway status
openclaw status
#
openclaw logs --follow

如果你告诉我你现在主要是:

  • 只用 CLI(不用 OpenClaw.app),还是
  • 主要用 OpenClaw.app(本地模式 / 远程模式)

我可以把上面的流程精简成你专属的“每天只用 3 条命令版本”。

sonic flicker
#

mumong@mumongdeMacBook-Pro  ~  openclaw gateway start

🦞 OpenClaw 2026.3.8 (3caab92) — I'm the assistant your terminal demanded, not the one your sleep schedule requested.

Restarted LaunchAgent: gui/501/ai.openclaw.gateway
mumong@mumongdeMacBook-Pro  ~  openclaw gateway status

🦞 OpenClaw 2026.3.8 (3caab92) — Powered by open source, sustained by spite and good documentation.


gateway connect failed: Error: device signature invalid

Service: LaunchAgent (loaded)
File logs: /tmp/openclaw/openclaw-2026-03-12.log
Command: /opt/homebrew/opt/node/bin/node /opt/homebrew/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Service file: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
Service env: OPENCLAW_GATEWAY_PORT=18789

Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: running (pid 64203, state active)
Warm-up: launch agents can take a few seconds. Try again shortly.
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1008): device signature invalid
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /Users/mumong/.openclaw/openclaw.json

Port 18789 is already in use.

  • pid 59046 mumong: openclaw-gateway (127.0.0.1:18789)
  • Gateway already running locally. Stop it (openclaw gateway stop) or use a different port.
    Listening: 127.0.0.1:18789
    Troubles: run openclaw status
    Troubleshooting: https://docs.openclaw.ai/troubleshooting
    mumong@mumongdeMacBook-Pro  ~ 
frank forumBOT
#

你这个输出里其实把原因写得很清楚了:你现在同时跑了两个 Gateway,而且端口 18789 被“旧的/另一个”进程占着,所以 CLI 探测连上的不是你刚启动的那个 LaunchAgent 进程,结果握手协议/签名对不上就报了:

  • device signature invalid
  • 同时又提示:Port 18789 is already in use. - pid 59046 ... openclaw-gateway

这类 device signature invalid 最常见就是:你连到了“不同版本/不同状态”的 gateway(比如旧进程还占着端口)。


解决流程(mac 上一步步来,照做就行)

Step 1:先把 LaunchAgent 关掉(避免它反复重启抢端口)

openclaw gateway stop

确认一下:

#
openclaw gateway status --no-probe

Step 2:找出到底是谁还在占 18789

lsof -nP -iTCP:18789 -sTCP:LISTEN

你大概率会看到类似你日志里那条 pid 59046 ... openclaw-gateway

Step 3:把占端口的“旧 gateway”停掉

先温和关:

kill 59046
#

再查一次端口是否释放:

lsof -nP -iTCP:18789 -sTCP:LISTEN

如果还在(说明没退出),再强制:

kill -9 59046

说明:你这里的目标是“保证 18789 上只剩一个 gateway”。不然你永远不知道 CLI/控制台连到谁。

Step 4:重新启动 LaunchAgent gateway(确保只启动一个)

openclaw gateway start
#

等 2~5 秒(launchd warm-up),然后:

openclaw gateway status
openclaw status

如果按上面做完还是 device signature invalid

那就不是端口冲突了,下一步我建议你做这 2 个检查(都很安全):

  1. 确认你 CLI 和 gateway 版本一致:
openclaw --version
  1. 跑一次 Doctor 修复常见握手/设备状态问题:
#
openclaw doctor

然后再:

openclaw gateway restart
openclaw gateway status

你现在回我两行输出,我就能确认是否已修好

把下面两条输出(脱敏即可)贴一下:

#
lsof -nP -iTCP:18789 -sTCP:LISTEN
openclaw gateway status
sonic flicker
#

mumong@mumongdeMacBook-Pro  ~ 
mumong@mumongdeMacBook-Pro  ~  openclaw gateway status --no-probe

🦞 OpenClaw 2026.3.8 (3caab92) — Finally, a use for that always-on Mac Mini under your desk.

Service: LaunchAgent (not loaded)
File logs: /tmp/openclaw/openclaw-2026-03-12.log
Command: /opt/homebrew/opt/node/bin/node /opt/homebrew/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Service file: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
Service env: OPENCLAW_GATEWAY_PORT=18789

Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: unknown (Bad request.
Could not find service "ai.openclaw.gateway" in domain for user gui: 501)
Service unit not found.
Service not installed. Run: openclaw gateway install
File logs: /tmp/openclaw/openclaw-2026-03-12.log
Port 18789 is already in use.

  • pid 59046 mumong: openclaw-gateway (127.0.0.1:18789)
  • Gateway already running locally. Stop it (openclaw gateway stop) or use a different port.
    Listening: 127.0.0.1:18789
    Troubles: run openclaw status
    Troubleshooting: https://docs.openclaw.ai/troubleshooting
    mumong@mumongdeMacBook-Pro  ~ 
    mumong@mumongdeMacBook-Pro  ~ 
    mumong@mumongdeMacBook-Pro  ~ 
    mumong@mumongdeMacBook-Pro  ~ 
    mumong@mumongdeMacBook-Pro  ~  lsof -nP -iTCP:18789 -sTCP:LISTEN

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 59046 mumong 19u IPv4 0x12c69ffba94842b9 0t0 TCP 127.0.0.1:18789 (LISTEN)
node 59046 mumong 20u IPv6 0x734898ae5dd3785c 0t0 TCP [::1]:18789 (LISTEN)
mumong@mumongdeMacBook-Pro  ~ 

frank forumBOT
#

很好,现在状态非常明确了:

  • launchd 服务没有安装/没有加载Service unit not found / ai.openclaw.gateway 不存在)
  • 端口 18789 确实有一个手动启动的 gateway 在跑pid 59046 (node) 正在 LISTEN

所以你现在的 Gateway 是“手动跑起来的进程”,不是 openclaw gateway start/stop 能管理的服务。


你现在有两条路(二选一)

路线 A(推荐):把它切换成 LaunchAgent 后台服务(可 start/stop 管理)

Step 1:确认 59046 是什么(可选,但建议)

ps -p 59046 -o pid,command
#

Step 2:停掉这个手动进程(因为它占着 18789)

kill 59046

确认端口释放:

lsof -nP -iTCP:18789 -sTCP:LISTEN

这条命令应该 没有输出(才算真的停干净了)。

Step 3:安装 LaunchAgent 服务

openclaw gateway install --force

Step 4:启动服务

#
openclaw gateway start

Step 5:验证服务已加载 + RPC probe OK

openclaw gateway status
openclaw status

路线 B:继续用“手动运行”的方式(不装服务)

那就不要管 gateway start/stop,而是保持你自己 openclaw gateway run 启动它;要停就 Ctrl+C(如果在前台)或 kill <pid>(如果后台跑)。


#

额外提醒(你之前的 device signature invalid

这个错误常见原因之一就是:你以为连的是新启动的 gateway,但端口实际连到旧进程/另一个进程
把 18789 上只留一个 gateway(路线 A 的做法)通常就会消失。


你先按“路线 A”做完,然后把下面两条输出贴回来(不用全贴,关键行就行):

openclaw gateway status
openclaw status
sonic flicker
#

Start with: launchctl bootstrap gui/$UID ~/Library/LaunchAgents/ai.openclaw.gateway.plist
mumong@mumongdeMacBook-Pro  ~ 
mumong@mumongdeMacBook-Pro  ~ 
mumong@mumongdeMacBook-Pro  ~  openclaw gateway status

🦞 OpenClaw 2026.3.8 (3caab92) — If you're lost, run doctor; if you're brave, run prod; if you're wise, run tests.



Service: LaunchAgent (not loaded)
File logs: /tmp/openclaw/openclaw-2026-03-12.log
Command: /opt/homebrew/opt/node/bin/node /opt/homebrew/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Service file: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
Service env: OPENCLAW_GATEWAY_PORT=18789

Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json

Gateway: bind=loopback (127.0.0.1), port=18789 (service args)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: unknown (Bad request.
Could not find service "ai.openclaw.gateway" in domain for user gui: 501)
RPC probe: failed
RPC target: ws://127.0.0.1:18789
gateway closed (1006 abnormal closure (no close frame)): no close reason
Gateway target: ws://127.0.0.1:18789
Source: cli --url
Config: /Users/mumong/.openclaw/openclaw.json

Service unit not found.
Service not installed. Run: openclaw gateway install
File logs: /tmp/openclaw/openclaw-2026-03-12.log
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting
mumong@mumongdeMacBook-Pro  ~ 

为什么会有 not install 的问题?我之前是用 npm 安装的

frank forumBOT
#

npm install -g openclaw(或 pnpm add -g openclaw只会安装 CLI 和代码,不会自动把 Gateway 注册成 macOS 的后台服务。

openclaw gateway status 里说的 “Service not installed” 指的是:

  • LaunchAgent(launchd 后台服务)没有被 bootstrap/loaded
  • 也就是 launchctl 里根本没有 ai.openclaw.gateway 这个服务条目
    (跟你有没有用 npm 安装 CLI 是两回事)

你现在的状态基本是:plist 文件在那儿,但 launchd 没加载它,所以才会:

  • Service: LaunchAgent (not loaded)
  • Could not find service "ai.openclaw.gateway"...
  • Service not installed. Run: openclaw gateway install

一步到位修复(推荐照做)

#

Step 1:安装/重装 LaunchAgent(把它真正注册进 launchd)

openclaw gateway install --force

Step 2:启动服务

openclaw gateway start

Step 3:确认已加载 + RPC probe OK

openclaw gateway status
openclaw status

#

如果你想用更底层的方式(等价于 install)

你看到的那句提示就是 launchd 的原生命令(install 本质上就是做这件事):

launchctl bootstrap gui/$UID ~/Library/LaunchAgents/ai.openclaw.gateway.plist
launchctl kickstart -k gui/$UID/ai.openclaw.gateway

但一般不需要手动跑,优先用 openclaw gateway install --force


openclaw gateway install --force 的输出贴一下(脱敏即可),我可以继续帮你确认它到底为什么没 load(常见是旧服务残留、profile 不一致、或 plist 被系统拒绝加载)。

sonic flicker
#

disconnected (1008): unauthorized: device token mismatch (rotate/reissue device token)
Gateway Access
Where the dashboard connects and how it authenticates.
WebSocket URL
ws://127.0.0.1:18789
Gateway Token
5adf72db187266233a6d4102bac6fcb49c1a835cbf5e9104
Password (not stored)
system or shared password
Default Session Key
agent:main:main
Language

简体中文 (Simplified Chinese)
Connect
Refresh
Click Connect to apply connection changes.
Snapshot
Latest gateway handshake information.
Status
Offline
Uptime
n/a
Tick Interval
n/a
Last Channels Refresh
n/a
disconnected (1008): unauthorized: device token mismatch (rotate/reissue device token)
Auth failed. Re-copy a tokenized URL with openclaw dashboard --no-open, or update the token, then click Connect.
Docs: Control UI auth

ok-Pro  ~  openclaw dashboard --no-open

🦞 OpenClaw 2026.3.8 (3caab92) — Automation with claws: minimal fuss, maximal pinch.

Dashboard URL: http://127.0.0.1:18789/#token=5adf72db187266233a6d4102bac6fcb49c1a835cbf5e9104
Copied to clipboard.
Browser launch disabled (--no-open). Use the URL above.
mumong@mumongdeMacBook-Pro  ~ 

使用这个 token 无法链接

frank forumBOT
#

你现在这个报错的关键点不是 “Gateway Token 不对”,而是这一句:

unauthorized: device token mismatch (rotate/reissue device token)

这表示:浏览器(Control UI)里缓存过一个“设备令牌 device token”(不是你手动粘贴的 gateway token),但你当前网关里记录的 device token 已经变了/被重置了,所以握手直接被拒绝。
最常见原因:你之前跑过别的 gateway 进程/重装/换 profile/清过状态,导致 浏览器缓存和网关状态不同步

下面按最稳的方式修(从轻到重)。


方案 1(最快,90% 能好):用“全新浏览器存储”连接

  1. 开一个无痕窗口/隐身窗口(Incognito/Private)
  2. 运行拿到新链接:
openclaw dashboard --no-open
#
  1. 把打印出来的 URL 粘到无痕窗口里打开,然后点 Connect

无痕窗口不会带旧的 device token,所以最容易直接恢复。


方案 2:清掉浏览器里这个站点的本地数据(等价于“重置 device token”)

在你常用浏览器里把 127.0.0.1:18789 的站点数据删掉(Local Storage / IndexedDB / Cache)。

  • Chrome:Settings → Privacy → Site data → 搜索 127.0.0.1 删除
  • 或 DevTools → Application → Storage → Clear site data

清完以后,再跑一次:

openclaw dashboard --no-open

重新打开链接并 Connect。

#

方案 3:用 CLI 把网关里“旧的设备配对”删掉/重新批准

  1. 先看网关当前记录了哪些设备(以及有没有 pending):
openclaw devices list
  1. 如果你看到有 pending request(请求 id),直接批准最新的:
openclaw devices approve --latest
  1. 如果 list 里有明显是 dashboard/browser 的旧 device(有 deviceId),把它删掉再重新连:
openclaw devices remove <deviceId>
#

然后再用 openclaw dashboard --no-open 打开、Connect。

这一步是“在网关侧重置 device token”,配合浏览器侧清缓存/无痕,基本必定能恢复。


先做一个小确认(避免在修 UI 前其实 gateway 没起来)

你先跑一下,看 CLI 能不能正常连上 gateway:

openclaw status
  • 如果 openclaw status 也连不上,那要先把 gateway 服务/端口问题修好(否则 UI 再怎么换 token 也没用)。

#

你回我两条信息我就能精确告诉你该走哪条最短路径:

  1. 你用的浏览器是 Chrome / Safari / Firefox 哪个?
  2. openclaw devices list 的输出(脱敏即可,尤其是有没有 pending requestId / deviceId)
sonic flicker
#

还是不行,我希望一个永久解决的问题,为什么会有残留,需要你彻底清除并且解决我的问题确保以后不会在出现

frank forumBOT
#

你这个问题的“根因”其实就两类(你前面的日志两类都命中过):

  1. 同一台 Mac 上同时跑过多个 gateway 进程/服务(一个手动 openclaw gateway run,一个 launchd),导致 端口/状态漂移
  2. Control UI(浏览器)会缓存一个 device token(用于设备级认证)。当你换了 gateway 实例、清过状态、或换 profile/端口后,浏览器里那个缓存就会变成“残留”,从而报:
    device token mismatch (rotate/reissue device token)

你要“永久解决 + 彻底清除残留”,就得同时把 (A) 机器上多余的 gateway 清干净 + (B) 网关侧 device pairing 清掉 + (C) 浏览器侧站点数据清掉,三件事缺一不可。

下面是一套“清零但不重装 OpenClaw、不删你 workspace/会话”的完整流程。


一次性彻底清理流程(建议照抄执行)

0) 先关掉 launchd 服务(如果存在)

#
openclaw gateway stop || true

1) 确保 18789 端口没有任何残留 gateway 在跑

先查:

lsof -nP -iTCP:18789 -sTCP:LISTEN

如果有输出(比如又出现 node <pid> ... LISTEN),把它 kill 掉(把 <pid> 换成你看到的 PID):

kill <pid>
sleep 1
lsof -nP -iTCP:18789 -sTCP:LISTEN
#

如果还没退出,再:

kill -9 <pid>

目标:这条 lsof ...18789 最终必须没有任何输出

2) 彻底重装(重注册)launchd 服务(防止“装了 plist 但没 load”这种残留)

openclaw gateway uninstall || true
openclaw gateway install --force
openclaw gateway start
openclaw gateway status

此时 gateway status 里应该看到 Service: LaunchAgent (loaded),并且 RPC probe: ok(至少不应该再是 service not installed)。

#

3) 清掉网关侧所有已配对的 device token(这是“永久消除 device token mismatch”的关键)

openclaw devices list
openclaw devices clear --yes

说明:这会清掉“所有已配对设备”(包括可能的手机节点/桌面节点)。但它不会删你的会话记录/工作区文件。

4) 清掉浏览器侧残留(否则你还会带着旧 device token)

在浏览器里对 http://127.0.0.1:18789 做一次 Clear site data(或直接用无痕窗口最省事)。

然后重新拿一次链接并打开:

openclaw dashboard --no-open

5) 如果此时需要重新批准设备(有 pending request)

#

开着 Control UI 的同时,在终端跑:

openclaw devices list
openclaw devices approve --latest

然后回到网页点 Connect / Refresh。


以后如何“确保不再出现”(你只要遵守这 3 条基本就稳了)

  1. 只保留一种启动方式
    • 要用 launchd:永远用 openclaw gateway start/stop/restart
    • 不要再同时跑 openclaw gateway run(手动前台)
  2. 不要切换 profile/state dir(除非你明确知道在做多实例)
    • 不要时而带 --profile xxx,时而不带
#
  1. Control UI 出现奇怪认证问题时,第一反应就是:
    • 开无痕窗口 / 清 site data(它就是会缓存 device token)

你执行完上面流程后,把这 2 条输出贴回来(脱敏即可)

我帮你确认已经“彻底干净”:

lsof -nP -iTCP:18789 -sTCP:LISTEN
openclaw gateway status

如果做完仍然报 device token mismatch,那就很可能是 你实际上连到了另一个 state dir/profile 的 gateway(最隐蔽的那种残留),我再带你用 openclaw gateway status --deep / openclaw gateway probe 把它揪出来。

sonic flicker
#

Paired (2)
┌─────────────────────────────────────────────────────┬────────────┬───────────────────────────────────────────────────────────────────────┬────────────┬────────────┐
│ Device │ Roles │ Scopes │ Tokens │ IP │
├─────────────────────────────────────────────────────┼────────────┼───────────────────────────────────────────────────────────────────────┼────────────┼────────────┤
│ 2362c2128e52011f0941b69de32a40870864ce6dcd073d6be01 │ operator │ operator.admin, operator.approvals, operator.pairing │ operator │ │
│ 3c79c0c50e594 │ │ │ │ │
│ 8c7bf58b710e127a68fad79da645bcbd7f4b618d7d3b9877135 │ operator │ operator.read, operator.admin, operator.write, operator.approvals, │ operator │ │
│ 8dbdb849c9b31 │ │ operator.pairing │ │ │
└─────────────────────────────────────────────────────┴────────────┴───────────────────────────────────────────────────────────────────────┴────────────┴────────────┘
mumong@mumongdeMacBook-Pro  ~  openclaw devices clear --yes

🦞 OpenClaw 2026.3.8 (3caab92) — I don't sleep, I just enter low-power mode and dream of clean diffs.


gateway connect failed: Error: device signature invalid

[openclaw] Failed to start CLI: Error: gateway closed (1008): device signature invalid
Gateway target: ws://127.0.0.1:18789
Source: local loopback
Config: /Users/mumong/.openclaw/openclaw.json
Bind: loopback
at Object.onClose (file:///opt/homebrew/lib/node_modules/openclaw/dist/call-BfhGytph.js:3261:10)
at WebSocket.<anonymous> (file:///opt/homebrew/lib/

frank forumBOT
#

你这次的现象很关键:openclaw devices list 刚刚还能跑通,但紧接着 openclaw devices clear --yes 就变成

  • gateway connect failed: device signature invalid
  • CLI 甚至“起不来”(连不上 gateway)

这几乎只能说明一件事:你这两条命令之间,18789 上连到的 gateway 已经不是同一个/不是同一套状态了(最常见:又有残留进程/旧 gateway 抢回了端口,或者服务在反复崩溃重启,你连到的是“另一个实例/旧版本”)。

所以你现在要“永久解决”,先别急着 clear(因为 clear 本身需要稳定连接),我们先把“残留/多实例”彻底钉死。


永久修复(不猜测,按证据一步步做)

Step 1:确认 18789 上到底是谁(必须做)

lsof -nP -iTCP:18789 -sTCP:LISTEN
#

把输出里的 PID 记下来(比如 <PID>),然后看它到底是从哪个 openclaw 路径启动的:

ps -p <PID> -o pid,command

你要看到的理想情况是 command 指向你当前安装的 openclaw(通常类似):
.../lib/node_modules/openclaw/dist/index.js gateway ...

如果看到的是旧路径、旧 node、或你自己手动跑的残留,那就是根因。

Step 2:彻底只留一个 gateway(先手动跑“同版本”,把环境稳定下来)

1)先停 launchd(就算显示没装也没关系):

openclaw gateway stop || true
#

2)把 18789 上的进程 kill 掉(用你 Step1 查到的 PID):

kill <PID>
sleep 1
lsof -nP -iTCP:18789 -sTCP:LISTEN

确保这条 没有任何输出(端口彻底空)。

3)用“你当前 CLI 同版本”的方式前台启动 gateway(保证不会再连错实例):

openclaw gateway run --allow-unconfigured --force --verbose

这一条先别关,让它一直在前台跑着。

Step 3:在另一个终端里清 device pair(这时才做,才会稳定)

#

新开一个终端窗口(不要关掉 Step2 的前台 gateway),运行:

openclaw devices clear --yes

如果你担心太猛,也可以先只删一个 device 验证连通性:

openclaw devices list
openclaw devices remove <deviceId>

Step 4:确认 dashboard 永久恢复(消掉浏览器残留)

  • 无痕窗口打开:
openclaw dashboard --no-open
#
  • 或者把 127.0.0.1:18789 的站点数据(Local Storage/IndexedDB)清掉再连

为什么这能“保证以后不再出现”

因为你现在遇到的残留不是“正常缓存”,而是 多个 gateway/多套状态 造成的 token 漂移。
上面的流程做了两件永久性的事:

  • 强制 18789 上只有一个、且版本一致的 gateway(消灭“连错实例”)
  • 清掉网关侧 paired devices + 浏览器侧缓存(消灭“device token mismatch”)

我需要你贴两条输出来确认“到底是谁在抢端口”

请把下面两条输出贴出来(不要贴 token):

#
lsof -nP -iTCP:18789 -sTCP:LISTEN
ps -p <PID> -o pid,command

只要我看到 <PID> 的 command 路径,就能 100% 判断你现在的“残留”来源(旧版本 openclaw?旧 node?手动启动遗留?mac app 起的?),然后给你一个最终的“以后只用 launchd/只用一种方式启动”的固定方案。

sonic flicker
#

MacBook-Pro  ~ 
✘ mumong@mumongdeMacBook-Pro  ~  lsof -nP -iTCP:18789 -sTCP:LISTEN

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 93065 mumong 19u IPv4 0x3c4588f02dd7905b 0t0 TCP 127.0.0.1:18789 (LISTEN)
node 93065 mumong 20u IPv6 0x20b6e4d30a90e2ce 0t0 TCP [::1]:18789 (LISTEN)
mumong@mumongdeMacBook-Pro  ~ 
mumong@mumongdeMacBook-Pro  ~  ps -p 93065 -o pid,command

PID COMMAND
93065 openclaw-gateway
mumong@mumongdeMacBook-Pro  ~ 

frank forumBOT
#

完美,这两条输出已经把“残留是谁”抓到了:

  • 18789 监听的是 PID 93065
  • 进程名是 openclaw-gateway(不是 node …/openclaw/dist/index.js gateway … 那种 launchd/service 形态)

这基本就解释了你为什么会反复遇到 device signature invalid / device token mismatch:你一直在连这个“残留的 openclaw-gateway 进程”,而不是你期望的那套受控的 LaunchAgent gateway。

下面给你一个一劳永逸的处理:把这个残留进程彻底干掉,然后只用 launchd 服务跑 gateway(以后不会再出现“手动残留抢端口”)。


一次性永久修复(照抄执行)

Step 1:先确认它是不是 launchd 启的(看 parent pid)

ps -p 93065 -o pid,ppid,etime,command
#
  • 如果 PPID 是你的 zsh/终端:就是你曾经手动跑起来的残留
  • 如果 PPID 很小/像 launchd:可能是某个旧 LaunchAgent 在拉它

无论哪种,下一步都一样:先停服务、再杀残留。

Step 2:先停 OpenClaw 的 launchd 服务(避免你 kill 掉后它又立刻被拉起)

openclaw gateway stop || true

(可选更硬一点,直接 bootout 旧 label;不会报错也没关系)

launchctl bootout gui/$UID/ai.openclaw.gateway 2>/dev/null || true

Step 3:杀掉这个占端口的残留 gateway(就是 93065)

#
kill 93065
sleep 1
lsof -nP -iTCP:18789 -sTCP:LISTEN

如果还在(说明没退出):

kill -9 93065
sleep 1
lsof -nP -iTCP:18789 -sTCP:LISTEN

目标:最后这条 lsof ...18789 必须没有任何输出

Step 4:用 OpenClaw 自己安装并启动“唯一的”LaunchAgent gateway

#
openclaw gateway uninstall || true
openclaw gateway install --force
openclaw gateway start
openclaw gateway status

此时 gateway status 里应该看到:

  • Service: LaunchAgent (loaded)
  • 并且 command 更像:node … openclaw/dist/index.js gateway --port 18789
  • RPC probe: ok(至少不应该再是 device signature invalid)

Step 5:这时候再做 device 清理(才不会再漂移)

openclaw devices clear --yes
#

然后浏览器用无痕窗口重新打开:

openclaw dashboard --no-open

为了保证“以后绝不复发”的使用规则(关键)

  • 以后不要再手动运行任何 openclaw-gateway / openclaw gateway run(除非你在调试,而且先 openclaw gateway stop
  • 日常只用:
    • openclaw gateway start|stop|restart|status

你先执行到 Step 4,然后把下面两条输出贴回来(脱敏即可),我就能确认你已经从“残留 openclaw-gateway”切换到“唯一的 launchd gateway”了:

#
lsof -nP -iTCP:18789 -sTCP:LISTEN
openclaw gateway status
sonic flicker
#

现在已经解决了,回到我们之前的问题,我想要给我的本地 给本地的 provider 添加一个 claude 4.6 那个模型 现在只有 codex5.3

frank forumBOT
#

可以,但有个硬前提:OpenClaw 只能“列出/切换”你的 provider 后面真正提供的 model id,它不能凭空把 claude-*-4-6 变成你本地 provider 可用的模型。

所以你现在本地 provider(custom-127-0-0-1-8317)只有 codex5.3 的原因是:你 8317 那个 OpenAI 兼容端点的 /v1/models 里只暴露了 gpt-5.3-codex


先做 1 个确认:你的 8317 端点到底有没有 “claude 4.6” 这个 model id

(你之前 curl 报 Missing API key,所以要带 Authorization header)

curl -s \
  -H "Authorization: Bearer test" \
  http://127.0.0.1:8317/v1/models

看返回的 id 列表里有没有类似:

  • claude-opus-4-6(或你想用的那个名字)
#

情况 A:列表里 没有

那就结论很直接:你当前这个本地 provider 背后的服务不支持 Claude 4.6
你有两个选择:

  1. 直接用你已经有的 Anthropic 模型(最简单)
    你之前 models status 里已经有:terminal-anthropic/claude-opus-4-6(别名 opus46
    切换就一句:
openclaw models set opus46
# 或聊天里:/model opus46
  1. 如果你坚持“都走本地 provider(localhost)”,那你需要一个本地代理(例如 LiteLLM/OpenCode Zen 之类)
    让它在 http://127.0.0.1:xxxx/v1 同时代理 OpenAI + Anthropic,并在 /v1/models 里暴露 claude-opus-4-6 这种 id。
    OpenClaw 才能把它当作 custom-.../claude-opus-4-6 来用。
#

你告诉我:你 8317 跑的到底是什么(LM Studio / LiteLLM / 自己写的代理 / 其他),我可以给你一套“让它暴露 claude-opus-4-6 的具体配置”。

情况 B:列表里 (例如确实出现了 claude-opus-4-6

那就只差把它加入 OpenClaw 的模型目录(Configured models):

Step 1:在 ~/.openclaw/openclaw.json 里加上这个模型条目(merge 模式会写入/合并到 agent 的 models.json)

models.providers 里补一段(注意 provider id 要和你现在的 custom-127-0-0-1-8317 一致):

{
  models: {
    mode: "merge",
    providers: {
      "custom-127-0-0-1-8317": {
        baseUrl: "http://127.0.0.1:8317/v1",
        apiKey: "test", // 这里要填你代理要求的 key(如果只要求“有 header”,随便填即可)
#
        api: "openai-completions",
        models: [
          {
            id: "claude-opus-4-6",
            name: "Claude 4.6 (via local proxy)",
            reasoning: false,
            input: ["text"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 128000,
            maxTokens: 8192
          }
        ]
      }
    }
  }
#
}

Step 2:重启 gateway

openclaw gateway restart

Step 3:确认模型已出现并切换

openclaw models list | grep custom-127-0-0-1-8317
openclaw models set custom-127-0-0-1-8317/claude-opus-4-6

#

你回我一句就能继续推进

你本地 8317 那个服务到底是什么?(LM Studio / LiteLLM / vLLM / llama.cpp / 其他)
以及你 curl .../v1/models 返回的 model id(只贴 id 列表,不要贴 key)。这样我就能告诉你:该走“直接用 opus46”还是“让本地代理暴露 claude-opus-4-6”。

sonic flicker
#

sk-g6SdLqWltQSltjp8i

 curl -s
-H "Authorization: Bearer test"
http://127.0.0.1:8317/v1/models
{"error":"Invalid API key"}% mumong@mumongdeMacBook-Pro  ~ 

zhe这个是访问我服务的密钥

frank forumBOT
#

你刚刚把 真实可用的 API key 贴到 Discord 里了(sk-g6SdLqWltQSltjp8i)。这已经算泄露了——建议你现在立刻做两件事:

  1. 把那条包含 key 的消息删掉(在 Discord 里删除即可)
  2. 立刻旋转/更换这个 key(因为任何看到这条消息的人都能拿它调用你的 127.0.0.1:8317 服务;哪怕你是本地服务,也别赌“没人会用”)

我这边也不会复述/引用你这个 key。


回到你的问题:怎么给本地 provider 加 “claude 4.6”

结论先说:OpenClaw 只能使用你 http://127.0.0.1:8317/v1/models 实际返回的模型 id。
所以第一步永远是:用正确 key 去看你的服务到底暴露了哪些模型。

1) 安全地请求 /v1/models(不要把 key 打到终端输出/也不要贴出来)

在你的终端这样做(把 key 放在环境变量里):

#
export LOCAL_API_KEY='(你的key,别贴到Discord)'
curl -s \
  -H "Authorization: Bearer $LOCAL_API_KEY" \
  http://127.0.0.1:8317/v1/models \
| python3 - <<'PY'
import json,sys
j=json.load(sys.stdin)
for m in j.get("data", []):
  print(m.get("id"))
PY

然后你只把打印出来的 model id 列表贴回 Discord(不要贴 key、不要贴完整 JSON)。

2) 分两种情况处理

情况 A:列表里没有 claude-opus-4-6(或你说的 claude 4.6 id)

#

那就说明:你这个 8317 服务(本地 proxy)目前只提供 codex5.3它本身就不支持 Claude
这种情况下你没法靠“改 OpenClaw 配置”凭空加出 Claude 4.6——你得先让你本地服务支持/代理 Claude(例如跑一个能同时代理 OpenAI+Anthropic 的本地网关,比如 LiteLLM),或者直接用你已经配置好的 terminal-anthropic/claude-opus-4-6

情况 B:列表里确实有 claude-opus-4-6
那就很简单:我再给你一段精确的 openclaw.json/重启/切换命令,把它加入 Configured models 并 /model 切过去。


更实际的建议(不折腾本地 provider 也能实现“codex + claude 4.6”)

你之前 models status 里其实已经有 terminal-anthropic/claude-opus-4-6(别名 opus46)。
如果你的目标是“写代码用 codex,本体推理/规划用 opus 4.6”,用多智能体最稳:

  • coding agent 默认模型 = custom-127-0-0-1-8317/gpt-5.3-codex
  • deepwork agent 默认模型 = opus46

这样不需要把 Claude 硬塞进本地 provider。

#

你先把 key 旋转掉,然后按上面命令跑一下 /v1/models(只贴 id 列表),我就能告诉你下一步该怎么配。

sonic flicker
#

ast login: Thu Mar 12 15:57:08 on ttys001
mumong@mumongdeMacBook-Pro  ~  curl -s
-H "Authorization: Bearer sk-g6SdLqWltQSltjp8i"
http://127.0.0.1:8317/v1/models
{"data":[{"created":1773302205,"id":"claude-opus-4-6","object":"model","owned_by":"terminal"}],"object":"list"}% mumong@mumongdeMacBook-Pro  ~ 

现在我,然后告诉我我应该怎么做去添加我的新的 model

frank forumBOT
#

你这个 http://127.0.0.1:8317/v1/models 已经明确返回了:

  • claude-opus-4-6

所以现在“添加新 model”在 OpenClaw 这边就是:把它写进 provider custom-127-0-0-1-8317 的 models catalog,然后重启 gateway,再切换到它。

先说一句安全的:你又把 key 贴出来了,建议马上把那条消息删掉并旋转 key(至少别再贴了)。


Step-by-step:把 claude-opus-4-6 加进 OpenClaw 并切换

Step 1:把 8317 的 API key 放到 ~/.openclaw/.env(避免写进 json)

编辑/创建文件:

~/.openclaw/.env

#

加入一行(不要贴到 Discord):

CUSTOM_8317_API_KEY=你的key

这个文件会被 gateway 服务读取(launchd 不会继承你 shell 的环境变量,用 .env 最稳)。

Step 2:在 ~/.openclaw/openclaw.json 里补上这个 provider + model

在你现有的 models.providers 里(和 qwen-portal 同级)加一段:

{
  models: {
    mode: "merge",
    providers: {
      "custom-127-0-0-1-8317": {
#
        baseUrl: "http://127.0.0.1:8317/v1",
        apiKey: "${CUSTOM_8317_API_KEY}",
        api: "openai-completions",
        models: [
          {
            id: "claude-opus-4-6",
            name: "Claude Opus 4.6 (via local 8317)",
            reasoning: false,
            input: ["text"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 200000,
            maxTokens: 8192
          }
        ]
      }
#
    }
  }
}

contextWindow/maxTokens 如果你的 8317 代理有明确限制,就按你的代理实际能力改;不确定先用上面这组,后续报 “context too large” 再调小。

Step 3:重启 gateway

openclaw gateway restart

Step 4:确认模型已经进入 “Configured models”

openclaw models list | grep "custom-127-0-0-1-8317"
#

你应该能看到至少这一条:

  • custom-127-0-0-1-8317/claude-opus-4-6

Step 5:切换到新模型

openclaw models set custom-127-0-0-1-8317/claude-opus-4-6
openclaw models status

(可选)加个别名方便切:

openclaw models aliases add opus-local custom-127-0-0-1-8317/claude-opus-4-6
# 以后:openclaw models set opus-local

#

如果你把 Step 4 的 grep 输出贴回来(只包含模型名那行,不要包含 key),我可以确认你的 catalog 合并是否生效;如果没生效,我们再检查是不是被 ~/.openclaw/agents/main/agent/models.json 覆盖了(通常是 merge 顺序/重复 provider 定义导致)。

sonic flicker
#

有什么用命令行的形式添加的吗?

frank forumBOT
#

可以,用 CLI 非交互式地加(本质就是用 openclaw config set …~/.openclaw/openclaw.json 写 JSON5)。

下面给你一套可直接复制的命令(mac/zsh 友好)。

先提醒:API key 别再贴到 Discord;最好放 ~/.openclaw/.env 里,让 gateway 服务读取。


0) 先把 key 放到 ~/.openclaw/.env(手动编辑一次就好)

文件内容加一行(不要发出来):

CUSTOM_8317_API_KEY=你的key

#

1) 用 CLI 添加/更新 provider + 模型目录

openclaw config set 'models.providers["custom-127-0-0-1-8317"].baseUrl' "http://127.0.0.1:8317/v1"
openclaw config set 'models.providers["custom-127-0-0-1-8317"].apiKey' '${CUSTOM_8317_API_KEY}'
openclaw config set 'models.providers["custom-127-0-0-1-8317"].api' "openai-completions"

openclaw config set 'models.providers["custom-127-0-0-1-8317"].models' \
'[
  {
    "id": "claude-opus-4-6",
    "name": "Claude Opus 4.6 (via local 8317)",
    "reasoning": false,
    "input": ["text"],
    "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
    "contextWindow": 200000,
    "maxTokens": 8192
#
  }
]' --json

如果你还想把 gpt-5.3-codex 也显式写进同一个 provider 的 models 列表,就把它也加到这个数组里(否则只写 Opus 也没问题)。


2) 重启 gateway(让它把 config 合并进 agents/*/agent/models.json 并生效)

openclaw gateway restart

3) 验证 + 切换