openclaw调用skill的机制

先把机制讲清楚,否则你会一直误以为 装了 skill 就会自动生效

OpenClaw 里,skill 的调用逻辑其实是 LLM Function Calling / Tool Calling 的一层封装。

核心流程是这样的:

复制代码
用户问题
   ↓
Agent Prompt
   ↓
LLM 判断是否需要调用 Tool
   ↓
OpenClaw 执行 Skill
   ↓
Skill 返回结果
   ↓
LLM 根据结果生成最终回答

也就是说:

Skill 是被模型"决策调用"的,不是 UI 直接调用。


1 Skill 的本质

在 OpenClaw 里,skill 实际上就是一个 tool/function

典型结构:

复制代码
skill
 ├─ manifest.json
 ├─ schema.json
 └─ handler (python/js/http)

关键是 schema,它告诉模型:

复制代码
这个工具能做什么
参数是什么
什么时候用

例如 OCR skill:

json 复制代码
{
  "name": "paddleocr",
  "description": "识别图片中的文字",
  "parameters": {
    "image_url": {
      "type": "string"
    }
  }
}

模型看到描述后才可能调用。


2 Agent 如何决定调用 skill

OpenClaw 会把 skill schema 注入到模型 prompt

复制代码
You can use the following tools:

1. paddleocr
   - 用于识别图片文字
   - 参数 image_url

然后模型在回答时可能返回:

json 复制代码
{
  "tool_call": {
    "name": "paddleocr",
    "arguments": {
      "image_url": "xxx"
    }
  }
}

OpenClaw 捕获这个调用。


3 OpenClaw 执行 skill

执行流程:

复制代码
LLM tool_call
   ↓
OpenClaw gateway
   ↓
skill handler
   ↓
返回结果

例如:

复制代码
图片 → OCR skill → 文本

返回:

json 复制代码
{
  "text": "合同编号 2024-001"
}

4 再次交给模型

OpenClaw 会把结果再喂回模型:

复制代码
tool_result
↓
LLM
↓
最终回答

例如:

复制代码
识别结果:合同编号 2024-001

5 Skill 不会触发的常见原因

很多人装了 skill 但 永远不会被调用,原因通常是:

1 agent 没绑定 skill

配置缺:

复制代码
agents.defaults.skills

2 skill description 写得太差

模型不知道什么时候用。

例如:

复制代码
description: OCR

这种基本不会触发。

正确:

复制代码
description: 识别图片中的中文或英文文字

3 模型不支持 tool calling

有些模型不支持:

复制代码
function calling
tool calling

例如某些基础模型。


4 prompt 没提示

生产系统通常会加规则:

复制代码
当用户上传图片时,优先调用 OCR skill

否则模型可能直接瞎猜。


6 完整调用流程(真实运行)

复制代码
用户:识别图片文字
      ↓
Agent Prompt
      ↓
LLM
      ↓
tool_call(paddleocr)
      ↓
OpenClaw
      ↓
OCR skill
      ↓
识别文本
      ↓
LLM
      ↓
最终回答

7 一个很多人不知道的关键点

OpenClaw 的 skill 不是 deterministic 调用

意思是:

复制代码
同一个问题
有时会调用 skill
有时不会

因为是 模型决策

生产系统通常会加一层:

复制代码
Rule Engine
↓
强制调用 skill

否则稳定性很差。


下面给你一张 OpenClaw Skill 调用架构图(实际运行逻辑)

很多人误以为 UI 直接调用 skill,但在 OpenClaw 里其实是 Agent + LLM 决策调用工具


OpenClaw Skill 调用架构

复制代码
┌──────────────────────────────┐
│           Chat UI            │
│ http://127.0.0.1:18789/chat │
└──────────────┬───────────────┘
               │ 用户输入 / 上传图片
               ▼
┌──────────────────────────────┐
│        OpenClaw Gateway      │
│ (会话管理 / Agent 路由)      │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│            Agent             │
│                              │
│  • system prompt             │
│  • memory / session          │
│  • skills list               │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│             LLM              │
│ 例如:                        │
│  • :contentReference[oaicite:1]{index=1}  │
│  • :contentReference[oaicite:2]{index=2}         │
│                              │
│ 决策是否调用 tool            │
└──────────────┬───────────────┘
               │ tool_call
               ▼
┌──────────────────────────────┐
│        Skill Dispatcher      │
│ (OpenClaw Tool Runtime)      │
└──────────────┬───────────────┘
               │
               ▼
        ┌───────────────┐
        │     Skill     │
        │               │
        │ OCR Skill     │
        │ WebSearch     │
        │ Database      │
        │ Filesystem    │
        └──────┬────────┘
               │
               ▼
┌──────────────────────────────┐
│        Skill Result           │
│ (JSON / text / data)          │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│             LLM              │
│ 结合结果生成最终回答          │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│           Chat UI            │
│        返回最终回复           │
└──────────────────────────────┘

Skill 在系统中的真实位置

复制代码
User
 ↓
Chat UI
 ↓
Agent
 ↓
LLM
 ↓
Tool Call
 ↓
Skill
 ↓
Tool Result
 ↓
LLM
 ↓
Answer

关键点:

  • skill 不是 UI 调用
  • skill 是 LLM 通过 tool_call 触发

Skill 的三个核心组件

一个 skill 通常包含:

复制代码
skill/
 ├─ manifest.json     (描述)
 ├─ schema.json       (参数定义)
 └─ handler           (执行逻辑)

作用:

复制代码
manifest → 告诉模型这个工具做什么
schema   → 告诉模型参数
handler  → 真正执行代码

为什么很多 skill 不会被调用

常见原因:

1️⃣ agent 没绑定 skill

复制代码
agents.defaults.skills

2️⃣ skill 描述太差

复制代码
description: OCR

模型不知道什么时候用。

3️⃣ 模型不支持 tool calling

例如一些基础模型。


一个很多人不知道的设计

在真实生产系统里,很多团队不会完全依赖 LLM 决策 skill,而是:

复制代码
User
 ↓
Rule Engine
 ↓
强制调用 Skill
 ↓
LLM 总结结果

原因很简单:

LLM 的 tool decision 不稳定。


下面这张是 完整层级的 OpenClaw 系统架构图

如果你理解了这张图,基本就不会再混淆 agent / model / skill / pluginOpenClaw 里的关系。


OpenClaw 完整系统架构

id="p2l4p9" 复制代码
                        ┌─────────────────────────────┐
                        │           Client            │
                        │                             │
                        │  Web UI  / API / IDE插件    │
                        │  http://127.0.0.1:18789     │
                        └──────────────┬──────────────┘
                                       │
                                       ▼
                       ┌────────────────────────────────┐
                       │        OpenClaw Gateway        │
                       │                                │
                       │ • API入口                      │
                       │ • Session管理                  │
                       │ • Agent路由                    │
                       │ • Tool调用调度                 │
                       └──────────────┬─────────────────┘
                                      │
                                      ▼
                       ┌────────────────────────────────┐
                       │            Agent Layer         │
                       │                                │
                       │ • System Prompt                │
                       │ • Memory / Session             │
                       │ • Skill列表                    │
                       │ • Tool使用策略                 │
                       └──────────────┬─────────────────┘
                                      │
                                      ▼
                       ┌────────────────────────────────┐
                       │            LLM Layer           │
                       │                                │
                       │ 决策是否调用 Tool              │
                       │                                │
                       │ 例如:                         │
                       │  • :contentReference[oaicite:1]{index=1}            │
                       │  • :contentReference[oaicite:2]{index=2}                   │
                       │  • :contentReference[oaicite:3]{index=3}               │
                       └──────────────┬─────────────────┘
                                      │ tool_call
                                      ▼
                       ┌────────────────────────────────┐
                       │        Tool / Skill Runtime    │
                       │                                │
                       │ Skill调度执行                   │
                       │                                │
                       │ 例如:                         │
                       │  • OCR                         │
                       │  • WebSearch                   │
                       │  • Database Query              │
                       │  • Filesystem                  │
                       └──────────────┬─────────────────┘
                                      │
                                      ▼
                     ┌───────────────────────────────────┐
                     │          Skill / Plugin           │
                     │                                   │
                     │ 本地或远程工具                    │
                     │                                   │
                     │ 例如:                            │
                     │  • :contentReference[oaicite:4]{index=4}        │
                     │  • :contentReference[oaicite:5]{index=5}     │
                     │  • Web API                        │
                     │  • Python Script                  │
                     └──────────────┬────────────────────┘
                                    │
                                    ▼
                        ┌───────────────────────────┐
                        │        Tool Result        │
                        │   JSON / Text / Data      │
                        └──────────────┬────────────┘
                                       │
                                       ▼
                              ┌─────────────────┐
                              │       LLM       │
                              │  生成最终回答    │
                              └────────┬────────┘
                                       │
                                       ▼
                               ┌───────────────┐
                               │   Client UI   │
                               │   返回结果     │
                               └───────────────┘

系统核心层级(简化理解)

可以把 OpenClaw 看成 5 层

id="7xk0gb" 复制代码
Client
↓
Gateway
↓
Agent
↓
Model
↓
Skill

作用分别是:

作用
Client UI / API / IDE
Gateway 请求入口、路由
Agent prompt + memory
Model LLM推理
Skill 执行工具

Skill / Plugin / Tool 的区别(很多人搞混)

在 OpenClaw 里:

id="7d27tf" 复制代码
Tool   = 模型可调用的函数
Skill  = Tool 的封装包
Plugin = 一组 Skill

结构类似:

id="0bh1he" 复制代码
plugin
 ├─ skill A
 ├─ skill B
 └─ skill C

一个很多人忽略的关键

OpenClaw 的 智能并不在 skill

真正的智能在:

id="gqgq52" 复制代码
Agent Prompt
+
LLM Tool Decision

skill 只是 执行器


真实生产架构(很多团队这样做)

大部分生产系统会在 OpenClaw 前再加一层:

id="tw6fd1" 复制代码
User
 ↓
API Gateway
 ↓
Rule Engine
 ↓
OpenClaw
 ↓
LLM
 ↓
Skill

原因:

让某些 skill 必须被调用,而不是让模型决定。

否则稳定性很差。


如果你愿意,我可以再给你一张 OpenClaw 内部调用时序图(Sequence Diagram)

相关推荐
xixixi777773 小时前
拥抱AI大模型时代:开发者如何利用智能编程工具提升效率
人工智能·python·ai·大模型·aigc·代码
特别关注外国供应商3 小时前
2025 年-2026 年,Claroty 在 Gartner® CPS 保护平台魔力象限™ 中被评为领导者
ai·工控安全·gartner·合规审计·claroty·cps安全·物联网设备安全
LucianaiB3 小时前
从基础配置到架构设计:JiuwenClaw 日报生成器开发实践
人工智能·ai·腾讯云·保姆级·opencalw
心疼你的一切3 小时前
【Unity-MCP完全指南:从零开始构建AI游戏开发助手】
人工智能·unity·ai·游戏引擎·aigc·mcp
算.子3 小时前
使用OpenClaw飞书插件玩转飞书
ai·飞书·openclaw
岁岁种桃花儿4 小时前
AI超级智能开发系列从入门到上天第一篇:Prompt工程
ai·prompt
TLY-101-0104 小时前
工作日记:在win11上开启WSL安装ubuntu,使用VLLM运行ASR模型
linux·ubuntu·ai·vllm
csdn_aspnet4 小时前
使用 C# 和 Microsoft Agent Framework 构建 AI 代理
人工智能·microsoft·ai·c#·.net·agent·ai agent
YmaxU5 小时前
SpringAIAlibaba学习使用 ---核心API、RAG、Tool Calling
java·学习·spring·ai