Structured Tool Output(结构化工具输出)

📅 2026-06-14 | 🏷️ AI术语 | ✍️ 妙趣AI

你去餐厅点菜,你希望菜单上有菜名、价格、配料表,而不是服务员说「那个……就是挺好吃的那个……你懂的」。Structured Tool Output就是让工具返回「正经菜单」而不是「你懂的」——有明确的字段、类型和格式,Agent一看就知道怎么用。

🏗️ 为什么需要结构化输出?

// 非结构化输出 (不友好)
"搜索结果:找到了3篇文章,第一篇是关于MCP的,
 发表在2026年6月,作者是张三,链接是https://..."

// 结构化输出 (友好)
{
  "results": [
    {
      "title": "MCP协议详解",
      "author": "张三",
      "date": "2026-06-10",
      "url": "https://example.com/mcp",
      "summary": "本文详细介绍了MCP协议..."
    }
  ],
  "total": 3,
  "page": 1
}

结构化输出的优势

🔧 OpenClaw 中的结构化输出

# MCP协议定义了标准的工具输出格式
{
  "content": [
    {"type": "text", "text": "结果文本"},
    {"type": "image", "data": "base64...", "mimeType": "image/png"}
  ],
  "isError": false
}

# 在SKILL.md中定义工具输出Schema
{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "title": {"type": "string"},
          "url": {"type": "string"},
          "snippet": {"type": "string"}
        }
      }
    },
    "total": {"type": "integer"}
  }
}
💡 妙趣说: 理解这个概念,是成为AI Agent高手的关键一步。理论结合实践,在OpenClaw中动手试试吧!