非流式对话
更新时间:2026-10-23
接口描述
向指定 Agent 发起同步对话,等待 Agent 完成全部推理后一次性返回最终结果。适用于不需要实时反馈的场景。
请求结构
Plain Text
1POST /v2/workspaces/{workspaceId}/dataagent/agents/{agentId}/query
路径参数
| 参数名 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
workspaceId |
string | 是 | 工作空间 ID |
agentId |
string | 是 | Agent ID |
请求 Body
| 参数名 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
query |
string | 是 | 用户问题 |
session_id |
string | 否 | 会话 ID;建议使用“创建 Agent”接口返回值,格式如 session_1735000000000_a3f2b9 |
timeout_sec |
int | 否 | 超时秒数,默认 120,最大 300 |
mode |
string | 否 | 分析模式:auto(默认)/ analysis / ide |
model_override |
string | 是 | 覆盖 Agent 默认模型,仅对本次对话生效 |
temperature_override |
float | 否 | 覆盖 Agent 默认温度,仅对本次对话生效 |
reasoning_effort |
string | 否 | 推理强度覆盖:off / low / medium / high |
selected_ontology |
string[] | 否 | 本次对话额外指定的本体类型列表 |
selected_functions |
string[] | 否 | 本次对话额外指定的 Logic Function 列表 |
selected_datasearches |
string[] | 否 | 本次对话额外指定的 DataSearch 列表 |
selected_skills |
SelectedSkillRef[] | 否 | 本次对话允许 Agent 使用的 Skill 发布版本列表 |
invoked_skills |
SelectedSkillRef[] | 否 | 本次对话由用户显式调用的 Skill 发布版本列表 |
tools_runtime |
object[] | 否 | 工具运行时配置 |
config |
object | 否 | Agent 运行配置 |
notepad_content |
string | 否 | 对话上下文便签内容 |
请求示例
Bash
1curl -X POST \
2 'https://{host}/databuilder/api/databuilder/v2/workspaces/workspace_9862_0763f283d58a/dataagent/agents/default/query' \
3 -H 'Content-Type: application/json' \
4 -H 'X-App-Id: dataagent-service' \
5 -H 'Authorization: <签名串>' \
6 -d '{
7 "query": "最近30天各省份订单量排行",
8 "session_id": "session_1735000000000_a3f2b9",
9 "timeout_sec": 120,
10 "selected_ontology": ["User", "Order"]
11 }'
响应
成功(HTTP 200)
JSON
1{
2 "session_id": "session_1735000000000_a3f2b9",
3 "final_answer": "## 最近30天各省份订单量排行\n\n| 排名 | 省份 | 订单量 |\n|---|---|---|\n| 1 | 广东 | 15,432 | 18.2% |\n| 2 | 浙江 | 12,891 | 15.2% |...",
4 "trace": {
5 "steps": [
6 {
7 "step_id": "step_1",
8 "tool_call_id": "call_abc123",
9 "thought": "需要按省份统计订单量",
10 "tool_name": "OntologyAggregation",
11 "tool_input": "{\"object_type\":\"Order\",\"group_by\":\"province\",\"metric\":\"count\"}",
12 "observation": "{\"result\":[{\"province\":\"广东\",\"count\":15432},...]}"
13 }
14 ]
15 },
16 "elapsed_ms": 8756,
17 "turn_usage": {
18 "total_input_tokens": 12450,
19 "total_output_tokens": 892,
20 "tool_input_tokens": 380,
21 "observation_tokens": 7823,
22 "thought_tokens": 245,
23 "elapsed_ms": 8756,
24 "step_count": 3
25 },
26 "lineage_graph": {
27 "session_id": "session_1735000000000_a3f2b9",
28 "nodes": [
29 {"id": "node_datasource_Order", "type": "datasource", "label": "Order", "turn_id": "turn_1"},
30 {"id": "node_op_step_1", "type": "operation", "label": "OntologyAggregation", "turn_id": "turn_1"},
31 {"id": "node_result_turn_1", "type": "result", "label": "省份订单排行", "turn_id": "turn_1"}
32 ],
33 "edges": [
34 {"from": "node_datasource_Order", "to": "node_op_step_1"},
35 {"from": "node_op_step_1", "to": "node_result_turn_1"}
36 ],
37 "outline": [
38 {"type": "question", "text": "最近30天各省份订单量排行", "node_id": "node_result_turn_1"}
39 ]
40 }
41}
| 字段 | 类型 | 说明 |
|---|---|---|
session_id |
string | 会话 ID |
final_answer |
string | Agent 最终回答,Markdown 格式 |
trace.steps |
StepTrace[] | 推理过程步骤列表,结构同流式接口 StepTrace |
elapsed_ms |
int | 总耗时(毫秒) |
turn_usage |
object | Token 用量统计,结构同流式接口 turn_usage |
lineage_graph |
object | 数据血缘图,结构同流式接口 lineage_graph |
错误码
| HTTP 状态码 | 错误码 | 说明 |
|---|---|---|
| 400 | BadRequest |
query 为空或请求参数不合法 |
| 400 | DataAgentResourceNotBound |
工作空间资源未绑定 |
| 404 | NotFound |
Agent 不存在 |
| 500 | InternalServerError |
服务内部错误或超时 |
评价此篇文章
