快速开始

配置 — 工具和自定义提供商

tools.* 配置键和自定义提供商 / 基础 URL 设置。对于智能体、渠道和其他顶层配置键,请参阅 配置参考

工具

工具配置档

tools.profile 会在 tools.allow/tools.deny 之前设置一个基础允许列表:

配置档 包含
minimal session_status
coding group:fs, group:runtime, group:web, group:sessions, group:memory, cron, image, image_generate, video_generate
messaging group:messaging, sessions_list, sessions_history, sessions_send, session_status
full 无限制(与未设置相同)

工具组

工具
group:runtime exec, process, code_executionbash 可作为 exec 的别名)
group:fs read, write, edit, apply_patch
group:sessions sessions_list, sessions_history, sessions_send, sessions_spawn, sessions_yield, subagents, session_status
group:memory memory_search, memory_get
group:web web_search, x_search, web_fetch
group:ui browser, canvas
group:automation heartbeat_respond, cron, gateway
group:messaging message
group:nodes nodes
group:agents agents_list, update_plan
group:media image, image_generate, music_generate, video_generate, tts
group:openclaw 所有内置工具(不包括提供商插件)

tools.allow / tools.deny

全局工具允许/拒绝策略(拒绝优先)。大小写不敏感,支持 * 通配符。即使 Docker 沙箱关闭时也会应用。

{
  tools: { deny: ["browser", "canvas"] },
}

writeapply_patch 是独立的工具 ID。allow: ["write"] 也会为兼容模型启用 apply_patch,但 deny: ["write"] 不会拒绝 apply_patch。要阻止所有文件变更,请拒绝 group:fs,或显式列出每个会变更文件的工具:

{
  tools: { deny: ["write", "edit", "apply_patch"] },
}

tools.byProvider

进一步限制特定提供商或模型的工具。顺序:基础配置档 → 提供商配置档 → 允许/拒绝。

{
  tools: {
    profile: "coding",
    byProvider: {
      "google-antigravity": { profile: "minimal" },
      "openai/gpt-5.4": { allow: ["group:fs", "sessions_list"] },
    },
  },
}

tools.elevated

控制沙箱外的提升权限 exec 访问:

{
  tools: {
    elevated: {
      enabled: true,
      allowFrom: {
        whatsapp: ["+15555550123"],
        discord: ["1234567890123", "987654321098765432"],
      },
    },
  },
}
  • 智能体级覆盖(agents.list[].tools.elevated)只能进一步收紧限制。
  • /elevated on|off|ask|full 会按会话存储状态;内联指令只应用于单条消息。
  • 提升权限的 exec 会绕过沙箱隔离,并使用配置的逃逸路径(默认是 gateway,当 exec 目标是 node 时为 node)。

tools.exec

{
  tools: {
    exec: {
      backgroundMs: 10000,
      timeoutSec: 1800,
      cleanupMs: 1800000,
      notifyOnExit: true,
      notifyOnExitEmptySuccess: false,
      applyPatch: {
        enabled: false,
        allowModels: ["gpt-5.5"],
      },
    },
  },
}

tools.loopDetection

工具循环安全检查默认禁用。设置 enabled: true 可启用检测。设置可以在 tools.loopDetection 中全局定义,并在每个智能体的 agents.list[].tools.loopDetection 处覆盖。

{
  tools: {
    loopDetection: {
      enabled: true,
      historySize: 30,
      warningThreshold: 10,
      criticalThreshold: 20,
      globalCircuitBreakerThreshold: 30,
      detectors: {
        genericRepeat: true,
        knownPollNoProgress: true,
        pingPong: true,
      },
    },
  },
}
historySizenumber

为循环分析保留的最大工具调用历史记录。

warningThresholdnumber

发出警告的重复无进展模式阈值。

criticalThresholdnumber

阻止关键循环的更高重复阈值。

globalCircuitBreakerThresholdnumber

任何无进展运行的硬停止阈值。

detectors.genericRepeatboolean

对重复的同工具/同参数调用发出警告。

detectors.knownPollNoProgressboolean

对已知轮询工具(process.pollcommand_status 等)的无进展情况发出警告/阻止。

detectors.pingPongboolean

对交替出现的无进展成对模式发出警告/阻止。

tools.web

{
  tools: {
    web: {
      search: {
        enabled: true,
        apiKey: "brave_api_key", // or BRAVE_API_KEY env
        maxResults: 5,
        timeoutSeconds: 30,
        cacheTtlMinutes: 15,
      },
      fetch: {
        enabled: true,
        provider: "firecrawl", // optional; omit for auto-detect
        maxChars: 50000,
        maxCharsCap: 50000,
        maxResponseBytes: 2000000,
        timeoutSeconds: 30,
        cacheTtlMinutes: 15,
        maxRedirects: 3,
        readability: true,
        userAgent: "custom-ua",
      },
    },
  },
}

tools.media

配置入站媒体理解(图片/音频/视频):

{
  tools: {
    media: {
      concurrency: 2,
      asyncCompletion: {
        directSend: false, // deprecated: completions stay agent-mediated
      },
      audio: {
        enabled: true,
        maxBytes: 20971520,
        scope: {
          default: "deny",
          rules: [{ action: "allow", match: { chatType: "direct" } }],
        },
        models: [
          { provider: "openai", model: "gpt-4o-mini-transcribe" },
          { type: "cli", command: "whisper", args: ["--model", "base", "{{MediaPath}}"] },
        ],
      },
      image: {
        enabled: true,
        timeoutSeconds: 180,
        models: [{ provider: "ollama", model: "gemma4:26b", timeoutSeconds: 300 }],
      },
      video: {
        enabled: true,
        maxBytes: 52428800,
        models: [{ provider: "google", model: "gemini-3-flash-preview" }],
      },
    },
  },
}
Media model entry fields

提供商条目type: "provider" 或省略):

  • provider:API 提供商 ID(openaianthropicgoogle/geminigroq 等)
  • model:模型 ID 覆盖
  • profile / preferredProfileauth-profiles.json 配置文件选择

CLI 条目type: "cli"):

  • command:要运行的可执行文件
  • args:模板化参数(支持 {{MediaPath}}{{Prompt}}{{MaxChars}} 等;openclaw doctor --fix 会将已弃用的 {input} 占位符迁移到 {{MediaPath}}

通用字段:

  • capabilities:可选列表(imageaudiovideo)。默认值:openai/anthropic/minimax → image,google → image+audio+video,groq → audio。
  • promptmaxCharsmaxBytestimeoutSecondslanguage:按条目覆盖。
  • 当智能体调用显式 image 工具时,tools.media.image.timeoutSeconds 和匹配图片模型的 timeoutSeconds 条目也会适用。
  • 失败会回退到下一个条目。

提供商凭证遵循标准顺序:auth-profiles.json → 环境变量 → models.providers.*.apiKey

异步完成字段:

  • asyncCompletion.directSend:已弃用的兼容性标志。完成的异步媒体任务仍由请求者会话中介,因此智能体会收到结果、决定如何告知用户,并在源投递需要时使用消息工具。

tools.agentToAgent

{
  tools: {
    agentToAgent: {
      enabled: false,
      allow: ["home", "work"],
    },
  },
}

tools.sessions

控制哪些会话可被会话工具(sessions_listsessions_historysessions_send)作为目标。

默认值:tree(当前会话 + 由它生成的会话,例如子智能体)。

{
  tools: {
    sessions: {
      // "self" | "tree" | "agent" | "all"
      visibility: "tree",
    },
  },
}
Visibility scopes
  • self:仅当前会话键。
  • tree:当前会话 + 由当前会话生成的会话(子智能体)。
  • agent:属于当前智能体 ID 的任何会话(如果你在同一个智能体 ID 下按发送者运行会话,则可能包括其他用户)。
  • all:任何会话。跨智能体定向仍然需要 tools.agentToAgent
  • 沙箱限制:当当前会话处于沙箱隔离状态且 agents.defaults.sandbox.sessionToolsVisibility="spawned" 时,即使 tools.sessions.visibility="all",可见性也会被强制为 tree

tools.sessions_spawn

控制 sessions_spawn 的内联附件支持。

{
  tools: {
    sessions_spawn: {
      attachments: {
        enabled: false, // opt-in: set true to allow inline file attachments
        maxTotalBytes: 5242880, // 5 MB total across all files
        maxFiles: 50,
        maxFileBytes: 1048576, // 1 MB per file
        retainOnSessionKeep: false, // keep attachments when cleanup="keep"
      },
    },
  },
}
附件说明
  • 附件仅支持 runtime: "subagent"。ACP 运行时会拒绝它们。
  • 文件会被物化到子工作区的 .openclaw/attachments/<uuid>/,并带有 .manifest.json
  • 附件内容会自动从转录持久化中脱敏。
  • Base64 输入会通过严格的字母表/填充检查和解码前大小保护进行验证。
  • 目录权限为 0700,文件权限为 0600
  • 清理遵循 cleanup 策略:delete 始终移除附件;keep 仅在 retainOnSessionKeep: true 时保留附件。

tools.experimental

实验性内置工具标志。默认关闭,除非适用严格智能体化 GPT-5 自动启用规则。

{
  tools: {
    experimental: {
      planTool: true, // enable experimental update_plan
    },
  },
}
  • planTool:为非平凡的多步骤工作跟踪启用结构化 update_plan 工具。
  • 默认值:false,除非 agents.defaults.embeddedPi.executionContract(或每个智能体的覆盖项)为 OpenAI 或 OpenAI Codex GPT-5 系列运行设置为 "strict-agentic"。设置为 true 可在该范围外强制启用此工具,或设置为 false 可即使在严格智能体化 GPT-5 运行中也保持关闭。
  • 启用后,系统提示还会添加使用指南,使模型仅将其用于实质性工作,并最多保持一个步骤为 in_progress

agents.defaults.subagents

{
  agents: {
    defaults: {
      subagents: {
        allowAgents: ["research"],
        model: "minimax/MiniMax-M2.7",
        maxConcurrent: 8,
        runTimeoutSeconds: 900,
        archiveAfterMinutes: 60,
      },
    },
  },
}
  • model:生成的子智能体的默认模型。如果省略,子智能体会继承调用方的模型。
  • allowAgents:当请求方智能体未设置自己的 subagents.allowAgents 时,sessions_spawn 的目标智能体 ID 默认允许列表(["*"] = 任意;默认:仅同一智能体)。
  • runTimeoutSeconds:当工具调用省略 runTimeoutSeconds 时,sessions_spawn 的默认超时(秒)。0 表示无超时。
  • 每个子智能体工具策略:tools.subagents.tools.allow / tools.subagents.tools.deny

自定义提供商和基础 URL

OpenClaw 使用内置模型目录。通过配置中的 models.providers~/.openclaw/agents/<agentId>/agent/models.json 添加自定义提供商。

{
  models: {
    mode: "merge", // merge (default) | replace
    providers: {
      "custom-proxy": {
        baseUrl: "http://localhost:4000/v1",
        apiKey: "LITELLM_KEY",
        api: "openai-completions", // openai-completions | openai-responses | anthropic-messages | google-generative-ai
        models: [
          {
            id: "llama-3.1-8b",
            name: "Llama 3.1 8B",
            reasoning: false,
            input: ["text"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 128000,
            contextTokens: 96000,
            maxTokens: 32000,
          },
        ],
      },
    },
  },
}
认证和合并优先级
  • 对于自定义认证需求,使用 authHeader: true + headers
  • 使用 OPENCLAW_AGENT_DIR(或旧版环境变量别名 PI_CODING_AGENT_DIR)覆盖智能体配置根目录。
  • 匹配提供商 ID 的合并优先级:
    • 非空的智能体 models.json baseUrl 值优先。
    • 非空的智能体 apiKey 值仅在该提供商未由当前配置/认证档案上下文中的 SecretRef 管理时优先。
    • SecretRef 管理的提供商 apiKey 值会从源标记(环境变量引用为 ENV_VAR_NAME,文件/执行引用为 secretref-managed)刷新,而不是持久化解析后的密钥。
    • SecretRef 管理的提供商标头值会从源标记(环境变量引用为 secretref-env:ENV_VAR_NAME,文件/执行引用为 secretref-managed)刷新。
    • 空或缺失的智能体 apiKey/baseUrl 会回退到配置中的 models.providers
    • 匹配模型的 contextWindow/maxTokens 使用显式配置和隐式目录值之间的较高值。
    • 匹配模型的 contextTokens 会在存在时保留显式运行时上限;使用它限制有效上下文,而无需更改原生模型元数据。
    • 当你希望配置完全重写 models.json 时,使用 models.mode: "replace"
    • 标记持久化以源为准:标记从活动源配置快照(解析前)写入,而不是从解析后的运行时密钥值写入。

提供商字段详情

顶层目录
  • models.mode:提供商目录行为(mergereplace)。
  • models.providers:以提供商 ID 为键的自定义提供商映射。
    • 安全编辑:使用 openclaw config set models.providers.<id> '<json>' --strict-json --mergeopenclaw config set models.providers.<id>.models '<json-array>' --strict-json --merge 进行增量更新。除非传入 --replace,否则 config set 会拒绝破坏性替换。
提供商连接和认证
  • models.providers.*.api:请求适配器(openai-completionsopenai-responsesanthropic-messagesgoogle-generative-ai 等)。对于自托管的 /v1/chat/completions 后端,例如 MLX、vLLM、SGLang 和大多数兼容 OpenAI 的本地服务器,请使用 openai-completions。带有 baseUrl 但没有 api 的自定义提供商默认使用 openai-completions;仅当后端支持 /v1/responses 时设置 openai-responses
  • models.providers.*.apiKey:提供商凭据(优先使用 SecretRef/环境变量替换)。
  • models.providers.*.auth:认证策略(api-keytokenoauthaws-sdk)。
  • models.providers.*.contextWindow:当模型条目未设置 contextWindow 时,该提供商下模型的默认原生上下文窗口。
  • models.providers.*.contextTokens:当模型条目未设置 contextTokens 时,该提供商下模型的默认有效运行时上下文上限。
  • models.providers.*.maxTokens:当模型条目未设置 maxTokens 时,该提供商下模型的默认输出词元上限。
  • models.providers.*.timeoutSeconds:可选的每提供商模型 HTTP 请求超时(秒),包括连接、标头、正文和总请求中止处理。
  • models.providers.*.injectNumCtxForOpenAICompat:对于 Ollama + openai-completions,向请求注入 options.num_ctx(默认值:true)。
  • models.providers.*.authHeader:在需要时强制通过 Authorization 标头传输凭据。
  • models.providers.*.baseUrl:上游 API 基础 URL。
  • models.providers.*.headers:用于代理/租户路由的额外静态标头。
请求传输覆盖

models.providers.*.request:模型提供商 HTTP 请求的传输覆盖。

  • request.headers:额外标头(与提供商默认值合并)。值接受 SecretRef。
  • request.auth:认证策略覆盖。模式:"provider-default"(使用提供商的内置认证)、"authorization-bearer"(带 token)、"header"(带 headerNamevalue、可选 prefix)。
  • request.proxy:HTTP 代理覆盖。模式:"env-proxy"(使用 HTTP_PROXY/HTTPS_PROXY 环境变量)、"explicit-proxy"(带 url)。两种模式都接受可选的 tls 子对象。
  • request.tls:直接连接的 TLS 覆盖。字段:cacertkeypassphrase(都接受 SecretRef)、serverNameinsecureSkipVerify
  • request.allowPrivateNetwork:当为 true 时,如果 DNS 解析到私有、CGNAT 或类似范围,则通过提供商 HTTP 获取保护允许对 baseUrl 使用 HTTPS(操作员为可信自托管 OpenAI 兼容端点选择加入)。local loopback 模型提供商流 URL(例如 localhost127.0.0.1[::1])会自动允许,除非此项显式设置为 false;LAN、tailnet 和私有 DNS 主机仍需选择加入。WebSocket 对标头/TLS 使用同一 request,但不使用该获取 SSRF 门禁。默认值 false
模型目录条目
  • models.providers.*.models:显式提供商模型目录条目。
  • models.providers.*.models.*.input:模型输入模态。文本模型使用 ["text"],原生图像/视觉模型使用 ["text", "image"]。只有在所选模型标记为支持图像时,图像附件才会注入到智能体轮次中。
  • models.providers.*.models.*.contextWindow:原生模型上下文窗口元数据。这会覆盖该模型的提供商级 contextWindow
  • models.providers.*.models.*.contextTokens:可选运行时上下文上限。这会覆盖提供商级 contextTokens;当你希望有效上下文预算小于模型原生 contextWindow 时使用它;openclaw models list 会在两者不同时显示这两个值。
  • models.providers.*.models.*.compat.supportsDeveloperRole:可选兼容性提示。对于带有非空非原生 baseUrl(主机不是 api.openai.com)的 api: "openai-completions",OpenClaw 会在运行时将其强制为 false。空/省略的 baseUrl 保持默认 OpenAI 行为。
  • models.providers.*.models.*.compat.requiresStringContent:字符串专用 OpenAI 兼容聊天端点的可选兼容性提示。当为 true 时,OpenClaw 会在发送请求前将纯文本 messages[].content 数组展平为普通字符串。
Amazon Bedrock 发现
  • plugins.entries.amazon-bedrock.config.discovery:Bedrock 自动发现设置根。
  • plugins.entries.amazon-bedrock.config.discovery.enabled:开启/关闭隐式发现。
  • plugins.entries.amazon-bedrock.config.discovery.region:用于发现的 AWS 区域。
  • plugins.entries.amazon-bedrock.config.discovery.providerFilter:用于定向发现的可选提供商 ID 过滤器。
  • plugins.entries.amazon-bedrock.config.discovery.refreshInterval:发现刷新的轮询间隔。
  • plugins.entries.amazon-bedrock.config.discovery.defaultContextWindow:发现模型的回退上下文窗口。
  • plugins.entries.amazon-bedrock.config.discovery.defaultMaxTokens:发现模型的回退最大输出词元数。

交互式自定义提供商新手引导会为 GPT-4o、Claude、Gemini、Qwen-VL、LLaVA、Pixtral、InternVL、Mllama、MiniCPM-V 和 GLM-4V 等常见视觉模型 ID 推断图像输入,并为已知的纯文本模型系列跳过额外问题。未知模型 ID 仍会提示确认图像支持。非交互式新手引导使用相同推断;传入 --custom-image-input 可强制写入支持图像的元数据,或传入 --custom-text-input 可强制写入纯文本元数据。

提供商示例

Cerebras(GLM 4.7 / GPT OSS)

内置的 cerebras provider 插件可通过 openclaw onboard --auth-choice cerebras-api-key 配置此项。仅在覆盖默认值时使用显式提供商配置。

{
  env: { CEREBRAS_API_KEY: "sk-..." },
  agents: {
    defaults: {
      model: {
        primary: "cerebras/zai-glm-4.7",
        fallbacks: ["cerebras/gpt-oss-120b"],
      },
      models: {
        "cerebras/zai-glm-4.7": { alias: "GLM 4.7 (Cerebras)" },
        "cerebras/gpt-oss-120b": { alias: "GPT OSS 120B (Cerebras)" },
      },
    },
  },
  models: {
    mode: "merge",
    providers: {
      cerebras: {
        baseUrl: "https://api.cerebras.ai/v1",
        apiKey: "${CEREBRAS_API_KEY}",
        api: "openai-completions",
        models: [
          { id: "zai-glm-4.7", name: "GLM 4.7 (Cerebras)" },
          { id: "gpt-oss-120b", name: "GPT OSS 120B (Cerebras)" },
        ],
      },
    },
  },
}

Cerebras 使用 cerebras/zai-glm-4.7Z.AI 直连使用 zai/glm-4.7

Kimi Coding
{
  env: { KIMI_API_KEY: "sk-..." },
  agents: {
    defaults: {
      model: { primary: "kimi/kimi-code" },
      models: { "kimi/kimi-code": { alias: "Kimi Code" } },
    },
  },
}

Anthropic 兼容的内置提供商。快捷方式:openclaw onboard --auth-choice kimi-code-api-key

Local models (LM Studio)

参见本地模型。简而言之:在高性能硬件上通过 LM Studio Responses API 运行大型本地模型;保留托管模型合并以便回退。

MiniMax M2.7 (direct)
{
  agents: {
    defaults: {
      model: { primary: "minimax/MiniMax-M2.7" },
      models: {
        "minimax/MiniMax-M2.7": { alias: "Minimax" },
      },
    },
  },
  models: {
    mode: "merge",
    providers: {
      minimax: {
        baseUrl: "https://api.minimax.io/anthropic",
        apiKey: "${MINIMAX_API_KEY}",
        api: "anthropic-messages",
        models: [
          {
            id: "MiniMax-M2.7",
            name: "MiniMax M2.7",
            reasoning: true,
            input: ["text"],
            cost: { input: 0.3, output: 1.2, cacheRead: 0.06, cacheWrite: 0.375 },
            contextWindow: 204800,
            maxTokens: 131072,
          },
        ],
      },
    },
  },
}

设置 MINIMAX_API_KEY。快捷方式:openclaw onboard --auth-choice minimax-global-apiopenclaw onboard --auth-choice minimax-cn-api。模型目录默认仅包含 M2.7。在 Anthropic 兼容的流式传输路径上,除非你显式自行设置 thinking,否则 OpenClaw 默认会禁用 MiniMax 的思考功能。/fast onparams.fastMode: true 会将 MiniMax-M2.7 重写为 MiniMax-M2.7-highspeed

Moonshot AI (Kimi)
{
  env: { MOONSHOT_API_KEY: "sk-..." },
  agents: {
    defaults: {
      model: { primary: "moonshot/kimi-k2.6" },
      models: { "moonshot/kimi-k2.6": { alias: "Kimi K2.6" } },
    },
  },
  models: {
    mode: "merge",
    providers: {
      moonshot: {
        baseUrl: "https://api.moonshot.ai/v1",
        apiKey: "${MOONSHOT_API_KEY}",
        api: "openai-completions",
        models: [
          {
            id: "kimi-k2.6",
            name: "Kimi K2.6",
            reasoning: false,
            input: ["text", "image"],
            cost: { input: 0.95, output: 4, cacheRead: 0.16, cacheWrite: 0 },
            contextWindow: 262144,
            maxTokens: 262144,
          },
        ],
      },
    },
  },
}

中国端点:baseUrl: "https://api.moonshot.cn/v1"openclaw onboard --auth-choice moonshot-api-key-cn

原生 Moonshot 端点会在共享的 openai-completions 传输协议上声明流式用量兼容性,OpenClaw 会依据端点能力判断,而不只看内置提供商 id。

OpenCode
{
  agents: {
    defaults: {
      model: { primary: "opencode/claude-opus-4-6" },
      models: { "opencode/claude-opus-4-6": { alias: "Opus" } },
    },
  },
}

设置 OPENCODE_API_KEY(或 OPENCODE_ZEN_API_KEY)。Zen 目录使用 opencode/... 引用,Go 目录使用 opencode-go/... 引用。快捷方式:openclaw onboard --auth-choice opencode-zenopenclaw onboard --auth-choice opencode-go

Synthetic (Anthropic-compatible)
{
  env: { SYNTHETIC_API_KEY: "sk-..." },
  agents: {
    defaults: {
      model: { primary: "synthetic/hf:MiniMaxAI/MiniMax-M2.5" },
      models: { "synthetic/hf:MiniMaxAI/MiniMax-M2.5": { alias: "MiniMax M2.5" } },
    },
  },
  models: {
    mode: "merge",
    providers: {
      synthetic: {
        baseUrl: "https://api.synthetic.new/anthropic",
        apiKey: "${SYNTHETIC_API_KEY}",
        api: "anthropic-messages",
        models: [
          {
            id: "hf:MiniMaxAI/MiniMax-M2.5",
            name: "MiniMax M2.5",
            reasoning: true,
            input: ["text"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 192000,
            maxTokens: 65536,
          },
        ],
      },
    },
  },
}

基础 URL 应省略 /v1(Anthropic 客户端会追加它)。快捷方式:openclaw onboard --auth-choice synthetic-api-key

Z.AI (GLM-4.7)
{
  agents: {
    defaults: {
      model: { primary: "zai/glm-4.7" },
      models: { "zai/glm-4.7": {} },
    },
  },
}

设置 ZAI_API_KEYz.ai/*z-ai/* 是可接受的别名。快捷方式:openclaw onboard --auth-choice zai-api-key

  • 通用端点:https://api.z.ai/api/paas/v4
  • 编码端点(默认):https://api.z.ai/api/coding/paas/v4
  • 对于通用端点,请定义一个带基础 URL 覆盖的自定义提供商。

相关