查询智能体调用说明

读取 Agent Card,确认目标智能体支持的 A2A 协议版本、输入输出类型和能力。

GET https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agents/{agent_id}/.well-known/agent-card.json

调用前准备

先查询智能体列表,选择活动智能体并记录其所属工作区。

准备可访问目标工作区的个人访问令牌和目标工作区 ID。

请求参数

curl --get "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/.well-known/agent-card.json" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Accept: application/json" \
  --data-urlencode "agent_workspace_id=$AGENT_WORKSPACE_ID"

$AGENT_ID 与 $AGENT_WORKSPACE_ID 分别来自智能体列表中同一项的 id 和 workspace_id。$WORKSPACE_ID 是本次调用所在工作区,$AI_STUDIO_API_KEY 是调用凭据。

参数

类型

是否必填

说明

workspace_id

string

是

本次调用所在工作区 ID,须与工作区请求头一致。

agent_id

string

是

智能体列表返回的目标智能体 ID。

查询参数

当前工作区未找到定义时会回退系统目录,显式指定当前工作区也相同。系统定义的 Card 技能还可能叠加当前工作区的绑定配置。读取 Card 不代表已获准执行智能体。

参数

类型

是否必填

说明

agent_workspace_id

string

否

智能体所属工作区。只能指定当前工作区或 system,省略时使用当前工作区。

选择系统助手时,将 system 填入查询参数,路径仍使用实际目标工作区。

通用入口 GET /v5/agents/card?agent_id=...&agent_workspace_id=... 也可用于读取 Card。本文示例使用工作区级入口。通用入口返回错误时,可按本页路径核对同一智能体的能力。

成功响应

{
  "name": "Matrixflow 工作流助手",
  "description": "根据自然语言和已注册工作项创建 Matrixflow 工作流。",
  "version": "1",
  "protocolVersion": "0.3.0",
  "capabilities": {
    "streaming": true,
    "stateTransitionHistory": true
  },
  "defaultInputModes": [
    "text/plain",
    "application/octet-stream"
  ],
  "defaultOutputModes": [
    "text/plain"
  ],
  "url": "https://api.moi.matrixorigin.cn/v5/workspaces/ws_01/agents/agent_01/a2a",
  "metadata": {
    "moi": {
      "version": 1,
      "dataParts": [
        {
          "type": "moi.feedback.submit",
          "version": 1,
          "direction": "client_to_runtime",
          "methods": [
            "message/send"
          ],
          "metadata": {
            "intent": [
              "record_only"
            ],
            "targetRequired": [
              "messageId"
            ]
          }
        },
        {
          "type": "moi.feedback.received",
          "version": 1,
          "direction": "runtime_to_client",
          "methods": [
            "message/send"
          ]
        },
        {
          "type": "moi.tool.call",
          "version": 1,
          "direction": "runtime_to_client",
          "methods": [
            "message/send",
            "message/stream",
            "tasks/resubscribe",
            "tasks/get"
          ]
        },
        {
          "type": "moi.tool.result",
          "version": 1,
          "direction": "runtime_to_client",
          "methods": [
            "message/send",
            "message/stream",
            "tasks/resubscribe",
            "tasks/get"
          ]
        },
        {
          "type": "moi.progress",
          "version": 1,
          "direction": "runtime_to_client",
          "methods": [
            "message/send",
            "message/stream",
            "tasks/resubscribe",
            "tasks/get"
          ]
        },
        {
          "type": "moi.run.control",
          "version": 1,
          "direction": "client_to_runtime",
          "methods": [
            "message/send"
          ],
          "metadata": {
            "rerunMode": [
              "same_manifest"
            ],
            "conversationMode": [
              "replace_view"
            ]
          }
        },
        {
          "type": "moi.run.control.result",
          "version": 1,
          "direction": "runtime_to_client",
          "methods": [
            "message/send"
          ]
        }
      ]
    }
  }
}

字段

类型

说明

name

string

智能体显示名称。

description

string

智能体说明。

url

string

Card 声明的 A2A 地址,根据服务配置的公开基础地址生成。

version

string

智能体版本。

protocolVersion

string

A2A 协议版本。

capabilities

object

能力声明。

capabilities.streaming

boolean

是否支持流式调用。

capabilities.pushNotifications

boolean

是否支持推送通知。有值时返回。

capabilities.stateTransitionHistory

boolean

是否支持状态变更历史。

defaultInputModes

string(字符串数组)

默认输入媒体类型。

defaultOutputModes

string(字符串数组)

默认输出媒体类型。

skills

object(对象数组)

智能体声明的技能。有值时返回。

metadata

object

数据分段协议元数据。moi.version 和 moi.dataParts。

metadata.moi

object

MOI 数据分段协议声明。

metadata.moi.version

integer

协议版本。当前为 1。

metadata.moi.dataParts

object(对象数组)

支持的数据分段类型及方向。七种分段声明。

metadata.moi.dataParts[].type

string

分段类型。取值见响应示例,发送分段时使用对应类型。

metadata.moi.dataParts[].version

integer

此类型的数据分段版本。当前为 1。

metadata.moi.dataParts[].direction

string

client_to_runtime 表示客户端发送,runtime_to_client 表示运行时返回。

metadata.moi.dataParts[].methods

string(字符串数组)

能够承载该分段的 JSON-RPC 方法。

metadata.moi.dataParts[].metadata

object

按分段类型返回的约束。没有额外约束时省略。

metadata.moi.dataParts[].metadata.intent

string(字符串数组)

反馈提交支持的意图。当前为 record_only。

metadata.moi.dataParts[].metadata.targetRequired

string(字符串数组)

反馈提交所需的目标字段。当前为 messageId。

metadata.moi.dataParts[].metadata.rerunMode

string(字符串数组)

重跑控制支持的模式。当前为 same_manifest。

metadata.moi.dataParts[].metadata.conversationMode

string(字符串数组)

会话视图控制支持的模式。当前为 replace_view。

只调用 Card 声明的能力,并兼容未知扩展字段。发送凭据前确认 url 属于预期服务。工作区级调用方式参阅通过 A2A 调用智能体。

根据 capabilities,使用工作区级公开路径通过 A2A 调用智能体。仅在 Card 声明支持时使用流式调用或其他扩展能力。

错误响应

工作区 Card 入口的参数、权限、缺失及构造错误使用 JSON-RPC 错误信封,分别可能返回 400、403、404、500。身份认证层仍有独立的 code / msg 错误。

{
  "jsonrpc": "2.0",
  "id": null,
  "error": {
    "code": -32008,
    "message": "agent not found"
  }
}

HTTP 状态码

JSON-RPC 错误代码

常见原因。

400

-32600

请求或工作区参数无效。

403

-32005

当前身份无访问权限。

404

-32008

智能体未找到。

500

-32603

Card 地址或内容构造失败。

最后更新于