Skip to content

消息类型速查

客户端 → 服务端

类型值说明何时发送
append_message追加用户消息/工具响应用户发送消息、回复工具提问
request_completion请求 AI 生成回复发送消息后触发补全
stop_completion中断 AI 回复用户点击"停止"
tool_confirmation_response确认/拒绝工具调用用户回应工具确认弹窗

服务端 → 客户端

文本与补全

类型值字段说明
llm_text_chunkchunk: string单个 token 级别的文本片段
llm_text_sentencesentence: string, index: int完整句子(按标点符号切分)
llm_thinking_chunkchunk: string推理过程的 token 片段(仅 reasoning 模式)
llm_thinking_sentencesentence: string, index: int推理过程的完整句子
text_echotext: string完整文本回显

工具调用

类型值字段说明
tool_call_chunkindex, id, function, confirmation_state工具调用流式片段
tool_callid, result, show_result工具执行结果
tool_confirmation_processedtool_call_id, action确认响应已处理
system_notificationmessage: string系统通知(工具执行产生的提示)

补全流程控制

类型值字段说明
completion_initconversation_id, user_character_config_id补全开始
assistant_message_completecontent, tool_calls, thinking, finish_reason完整的 AI 回复
completion_donefinish_reason单轮补全结束
stop_completionpartial_text补全被用户中断

对话管理

类型值字段说明
message_appendedappend_message 确认
conversation_title_updateconversation_id, title标题自动生成/更新

音频

类型值说明
audio_playback_start音频播放开始
audio_playback_end音频播放结束

错误与生命周期

类型值字段说明
errormessage, code错误消息
user_disconnect用户断开连接

详细结构

tool_call_chunk

工具调用以流式方式推送,参数逐步累积:

json
// 第一个 chunk:包含 id 和函数名
{
  "type": "tool_call_chunk",
  "index": 0,
  "id": "call_abc123",
  "function": {
    "name": "WebSearchFunction",
    "arguments": ""
  },
  "show_name": true,
  "show_arguments": true,
  "show_result": true,
  "confirmation_state": "none"
}

// 后续 chunk:只包含参数增量
{
  "type": "tool_call_chunk",
  "index": 0,
  "id": null,
  "function": {
    "name": null,
    "arguments": "{\"query\": \"搜索"
  },
  "show_name": true,
  "show_arguments": true,
  "show_result": true,
  "confirmation_state": "none"
}

累积规则:客户端需要将所有 chunk 的 function.arguments 字符串拼接起来,得到完整的 JSON 参数。

可见性字段

字段说明
show_name是否在 UI 中显示工具名称
show_arguments是否显示工具参数
show_result后续 tool_call 消息是否显示结果

确认状态

说明
none无需确认,直接执行
pending需要用户确认后才执行
awaiting_input已执行,等待用户输入

assistant_message_complete

每轮补全结束时推送完整的 AI 回复:

json
{
  "type": "assistant_message_complete",
  "content": "根据搜索结果,我找到了以下信息...",
  "thinking": "用户想要了解...(仅 reasoning 模式)",
  "tool_calls": [
    {
      "id": "call_abc123",
      "type": "function",
      "function": {
        "name": "WebSearchFunction",
        "arguments": "{\"query\": \"搜索关键词\"}"
      },
      "show_name": true,
      "show_arguments": true,
      "show_result": true,
      "confirmation_state": "none"
    }
  ],
  "finish_reason": "stop",
  "source_message_id": null
}

finish_reason

说明
stop正常完成
length达到最大 Token 限制
tool_calls有工具调用(可能需要确认或后续处理)
content_filter内容被安全过滤
error发生错误

error

json
{
  "type": "error",
  "message": "用户友好的错误描述",
  "code": "error_code_string",
  "request_id": "关联的请求ID"
}

错误码列表详见 错误码与状态码

狐线 AI Pro 外部测试文档