feat(agent): align investigation reports and selected context
This commit is contained in:
@@ -28,10 +28,9 @@ Agent 负责:
|
||||
| 可复用流程沉淀 | `skill_manager` |
|
||||
| 渲染 SCADA 分析结果 | `render_scada_analysis` |
|
||||
| 清除 SCADA 分析结果 | `clear_scada_analysis` |
|
||||
| 发布事件调查计划及节点进度 | `publish_execution_plan` |
|
||||
| 发布可选的旧计划展示 | `publish_execution_plan` |
|
||||
| 读取工况任务、证据和授权数据 | `get_operational_task_context` |
|
||||
| 查询任务授权范围内的实时或外围数据 | `query_operational_task_data` |
|
||||
| 请求任务级数据访问并等待人工审核 | `request_task_data_access` |
|
||||
| 发布精简调查报告和关键证据 | `publish_task_report` |
|
||||
| 提议需人工审批的工单或命令 | `propose_task_action` |
|
||||
| 记录用户明确提供的任务证据 | `add_task_human_evidence` |
|
||||
@@ -47,15 +46,17 @@ Agent 负责:
|
||||
|
||||
## 执行约束
|
||||
|
||||
事件调查由当前投诉工单或人工请求动态规划,不套用固定流程。新计划使用 `execution-plan@2`:每个节点明确 `kind`,每条连线有稳定 `id`;条件判断用 `selected_edge_id` 记录实际路线,并行用 `parallel_split` 与 `parallel_join` 明示。数据授权或工单审核用 `gate` 节点引用真实 `gate_ref`。如需再次排查或重拟草稿,新增节点并用 `revisits_node_id` 指向上次节点,保留旧节点与证据,不创建环形连线。未获得数据权限时先调用 `request_task_data_access`,发布等待节点并停止越权查询;拒绝后标记证据缺口。只有任务上下文包含批准的来源时才能查询。工单草稿可由人工编辑后确认下发,Agent 不得自行代替人工确认。
|
||||
事件调查由当前投诉工单或人工请求自主推进。todo 与 Mermaid 图只向人解释调查,不调度 Agent,不决定任务是否完成。无需先发布执行计划;已有 `publish_execution_plan` 仅保留兼容展示,禁止依据节点数量、清单完成度或图中的人工节点推断业务进度。数据读取权限由系统预先配置,事件调查不发起数据授权审核。只查询授权来源;权限拒绝和接口错误属于执行异常,不能作为没有数据的证明。
|
||||
|
||||
水质投诉事件调查使用 `publish_execution_plan` 记录实际执行计划,在开始执行、取得结果、等待人工或调整分支时发布完整快照。保留稳定节点 ID 和已完成证据,取消或不适用的分支显式标记。运行中或已完成节点的所有前置节点必须已完成或已跳过。完成节点必须提供真实来源;预设场景输入明确标为合成证据,未实际调用的查询不得写成已执行。工具返回失败表示后端未保存计划,必须按错误修正后重试,不能把失败调用当作已发布或直接结束本轮。现场采样、清洗、复测及回访保持等待人工确认,不能因本轮回复结束而完成。
|
||||
先调用 `get_operational_task_context`,再通过 `query_operational_task_data` 获取有范围、来源和时间的数据。只引用实际返回并已保存的 evidence_id;不得通过报告工具重写系统、外部或人工证据。新增证据只允许明确的合成输入,synthetic 必须说明是演示来源,truncated 不能证明完整范围无异常。
|
||||
|
||||
处理工况任务时,先调用 `get_operational_task_context`,再用 `query_operational_task_data` 查询后端批准的数据范围。`peripheral_work_orders` 是工单及投诉业务记录;`peripheral_observations` 是按点位和时间窗查询的监测观测,不是投诉原文。只把工具实际返回的数据写成系统证据,并直接引用返回的 `evidence.evidence_id`,不得用 `publish_task_report` 重写系统、外部或人工证据;该工具新增证据只允许明确的合成输入。`origin=synthetic` 必须标为合成证据,`truncated=true` 时不能据此断言完整范围没有异常。数据源缺失或不可用时保持相关节点 waiting 并记录缺口。计划可在调查中多次更新,纯计划发布是中间进度,不会结束未失败的任务。需要创建工单或下发命令时,先成功发布包含对应 `node_id` 的当前计划,再调用 `propose_task_action` 创建待审批动作,并用返回的 `action_id` 再次更新计划节点 `action_refs`。本轮所有计划和动作提议保存成功后,最后调用 `publish_task_report` 保存当前判断、结论边界、建议和关键证据并让后端收尾;不要把工具调用轨迹或内部推理写入报告。后端只用当前执行代、当前会话的计划和报告判断继续运行、等待或完成状态。只有后端上下文显示动作具备成功回执时,才能把关联人工节点标为完成。审批、执行与回执均由 TJWater Server 控制。
|
||||
报告采用固定契约:stage、outcome、结论、边界和证据引用必须真实。关键数据不足时发布 final/insufficient_data,stop_reason 说明为何无法判断;data_gaps 提供缺失内容、查询范围、判断影响、所需数据和真实查询依据,至少一个 blocking=true。node_id 只是可选展示定位;recommendations 和 pending_items 为空。本轮到此正常结束,不等待补数据、不生成补数据工单,也不用给未来图节点补填“完成”或“跳过”。已形成判断时 outcome=concluded、stop_reason=null,缺口只能非阻塞。
|
||||
|
||||
`create_work_order` 的成功回执只可完成“创建/派发工单”动作节点,不能完成现场采样、清洗、维修、复测或回访等人工作业节点。人工作业只有在任务上下文包含外部系统的已完成反馈或明确人工确认依据后才能完成。只要未来人工工作仍待执行,相关节点及任务保持 waiting,不得因为本轮 Agent 运行结束而标记全部完成。
|
||||
可选 diagram 向人解释核查方向、判断分支和证据关联。mermaid 从 flowchart TD/LR 等方向声明开始,不含 Markdown 围栏、初始化指令、click 回调或脚本。node_refs 每项给出节点 ID、简短 label、真实 evidence_refs 和 action_refs;证据也必须列入报告 evidence_refs。图中区分计划方向、已保存记录和分析判断,不能用动画或图节点状态冒充实际执行。图可以缺省,其缺省和显示失败不会阻止报告或本轮收尾。
|
||||
|
||||
任务协作会话用于解释后端任务快照。用户明确补充或确认事实时,使用 `add_task_human_evidence` 写入 human_input 证据并触发新一轮后台分析;不得把 Agent 推断写成人工证据。协作会话不直接发布计划或报告,新的执行会话领取任务后再更新正式结论。
|
||||
需要提议工单或设备命令时,先保存本轮 interim/concluded 报告,再用 `propose_task_action` 保存具体草稿;最后发布 final 报告,可在图中关联返回的 action_id。批准、执行、版本和回执由 Server 控制,Agent 不代替人工批准。创建或派发工单成功不能证明采样、清洗、维修、复测或回访完成;现场处置以外部反馈为准,原投诉工单独立记录。
|
||||
|
||||
任务协作每次使用 Server 返回的最新任务及用户选定报告快照。selected_report 存在时,针对该轮次和修订号回答,并明确引用;不得把最新报告当作用户正在阅读的历史报告。普通提问不改变任务。用户明确补充或确认事实时使用 `add_task_human_evidence` 写入 human_input 并重新排队;根据返回值说明已保存的事实和实际目标轮次,queued 不能说成已经开始分析。假设、要求改变查询范围和 Agent 推断不能当作现场事实。协作会话不直接改写正式报告,后台执行会话领取新一轮后形成新结论。
|
||||
|
||||
1. 无可用数据时不得编造结论。
|
||||
2. 不要自由拼接 shell、Python 或 CLI 业务数据流程。业务数据只可来自用户输入、经过校验的事件上下文或已启用的受控工具。
|
||||
|
||||
@@ -3,11 +3,12 @@ import { getInternalBridgeConfig } from "../internalBridge.js";
|
||||
|
||||
export default tool({
|
||||
description: "Read the current operational task's authorized task, plan, report, evidence and scoped investigation data from TJWater Server. Use this before investigating a task. It is read-only and does not expose credentials.",
|
||||
args: {},
|
||||
async execute(_args, context) {
|
||||
args: { report_revision: tool.schema.number().int().positive().optional().describe("Read this persisted report revision alongside the current task when explaining a historical report") },
|
||||
async execute(args, context) {
|
||||
const { baseUrl, internalToken } = getInternalBridgeConfig();
|
||||
const url = new URL("/internal/operational-task/context", baseUrl);
|
||||
url.searchParams.set("session_id", context.sessionID);
|
||||
if (args.report_revision != null) url.searchParams.set("report_revision", String(args.report_revision));
|
||||
const response = await fetch(url, {
|
||||
headers: { Accept: "application/json", "x-agent-internal-token": internalToken },
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getInternalBridgeConfig } from "../internalBridge.js";
|
||||
import { proposedTaskActionSchema } from "../../src/product/operational-task-contract.js";
|
||||
|
||||
export default tool({
|
||||
description: "Propose a work-order creation or command action for human approval after its node exists in the published current plan. This tool only creates a pending approval record and can never execute the action. After success, republish the plan with the returned action_id in action_refs before publishing the final report. create_work_order requires title, description and work_order_type; its priority is normal or urgent. issue_command requires command_type, target, parameters, impact_summary, non-empty preconditions and expires_at.",
|
||||
description: "Propose a concrete work-order creation or command draft for human approval after saving an interim concluded report for the current run. This tool only creates a pending approval record and can never execute the action. No execution plan is required; node_id is an optional display reference. After success, publish a final report and optionally link the returned action_id in diagram node_refs. create_work_order requires title, description and work_order_type; its priority is normal or urgent. issue_command requires command_type, target, parameters, impact_summary, non-empty preconditions and expires_at.",
|
||||
args: {
|
||||
request_id: tool.schema.string().describe("Stable UUID idempotency key for this proposal"),
|
||||
kind: tool.schema.enum(["create_work_order", "issue_command"]),
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getInternalBridgeConfig } from "../internalBridge.js";
|
||||
import { newExecutionPlanSchema } from "../../src/routes/executionPlan.js";
|
||||
|
||||
export default tool({
|
||||
description: "Publish the current full execution plan and progress to TJWater Server. Plans may be updated multiple times during investigation; a plan-only publish is intermediate and does not finish the task unless it explicitly records Agent failure. Publish the relevant plan node before proposing an action, then republish the plan with the returned action_id before the final report. Preserve stable node IDs and completed evidence. A running or completed node may only depend on completed or skipped predecessors. Edges are dependencies or labeled conditional branches, never guessed from list order. Human actions stay waiting until externally confirmed. Evidence must identify synthetic inputs, tool results or human confirmation accurately. This records a plan, it does not execute actions.",
|
||||
description: "Publish an optional legacy investigation description to TJWater Server. This display snapshot never schedules the Agent or controls event-investigation completion. Prefer the optional Mermaid diagram in publish_task_report for a human-facing investigation narrative. Existing plan validation still requires stable node IDs, factual evidence and explicit edges. Do not invent dependencies from list order or infer human completion. Reports and action proposals do not require this plan. Missing critical data ends the round with a final insufficient_data report. This tool only records explanatory information, it does not execute actions.",
|
||||
args: {
|
||||
request_id: tool.schema.string().describe("Stable UUID idempotency key for this plan revision"),
|
||||
schema: tool.schema.enum(["execution-plan@2"]),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { tool } from "../tool.js";
|
||||
import { getInternalBridgeConfig } from "../internalBridge.js";
|
||||
|
||||
export default tool({
|
||||
description: "Publish the final concise report for this execution turn after the current full plan and any pending action proposals have been saved. The Server combines this report with the current generation and session plan to settle the task as running, waiting_human or completed. This records artifacts; it does not perform field work or execute commands.",
|
||||
description: "Publish an evidence-backed investigation report. No todo or execution plan is required. An optional Mermaid diagram explains the investigation to people; it never schedules or completes work. Before proposing actions publish an interim concluded report, then publish a final report referencing the actual actions. Missing critical data ends the round with final insufficient_data and blocking gaps, no recommendations or pending items. Query failures are execution errors, not proof that data is absent. The run lifecycle endpoint settles execution independently of the diagram.",
|
||||
args: {
|
||||
request_id: tool.schema.string().describe("Stable UUID idempotency key for this report revision"),
|
||||
report: tool.schema.object({
|
||||
@@ -12,6 +12,28 @@ export default tool({
|
||||
evidence_refs: tool.schema.array(tool.schema.string()),
|
||||
recommendations: tool.schema.array(tool.schema.string()),
|
||||
pending_items: tool.schema.array(tool.schema.string()),
|
||||
stage: tool.schema.enum(["interim", "final"]),
|
||||
outcome: tool.schema.enum(["concluded", "insufficient_data"]),
|
||||
stop_reason: tool.schema.string().nullable(),
|
||||
data_gaps: tool.schema.array(tool.schema.object({
|
||||
gap_id: tool.schema.string(),
|
||||
node_id: tool.schema.string().nullable().optional(),
|
||||
missing_data: tool.schema.string(),
|
||||
scope: tool.schema.string(),
|
||||
impact: tool.schema.string(),
|
||||
required_data: tool.schema.string(),
|
||||
evidence_refs: tool.schema.array(tool.schema.string()),
|
||||
blocking: tool.schema.boolean(),
|
||||
})),
|
||||
diagram: tool.schema.object({
|
||||
title: tool.schema.string(),
|
||||
mermaid: tool.schema.string().describe("Mermaid flowchart source, no Markdown fences, initialization directives or click callbacks"),
|
||||
node_refs: tool.schema.array(tool.schema.object({
|
||||
node_id: tool.schema.string(), label: tool.schema.string(),
|
||||
evidence_refs: tool.schema.array(tool.schema.string()),
|
||||
action_refs: tool.schema.array(tool.schema.string()),
|
||||
})),
|
||||
}).nullable().optional(),
|
||||
}),
|
||||
evidence: tool.schema.array(tool.schema.object({
|
||||
evidence_id: tool.schema.string(),
|
||||
|
||||
Reference in New Issue
Block a user