70 lines
3.2 KiB
Markdown
70 lines
3.2 KiB
Markdown
# Diagnosis Agent 执行架构
|
||
|
||
**更新日期**:2026-07-23
|
||
**状态**:当前可运行架构
|
||
|
||
## 1. 单 Agent 原则
|
||
|
||
当前业务诊断只有一个 `Diagnosis Agent`。它使用框架 `ReactAgent` 完成规划、行动、观察和最终 Draft,但项目不在外层复制 ReAct 状态机,也不使用业务 Graph 或多角色协作链。
|
||
|
||
## 2. 职责
|
||
|
||
Diagnosis Agent:
|
||
|
||
- 接收当前 query 与可选、受限的安全 PreviousTurn。
|
||
- 自主选择只读 evidence Tool。
|
||
- 根据 Agent projection 判断是否需要继续查询。
|
||
- 输出结构化 `DiagnosisDraft`,每条 analysis 绑定 framework `tool_call_id`。
|
||
- 证据不足时明确限制,不补造事实。
|
||
|
||
Diagnosis Agent 不负责:
|
||
|
||
- HTTP/SSE、Session/Run 生命周期和持久化。
|
||
- 模型/Tool/Token/timeout/cancel 预算。
|
||
- Tool 参数授权、raw response 投影或证据物理验真。
|
||
- SemanticGuard 与最终发布决定。
|
||
|
||
## 3. 执行序列
|
||
|
||
```mermaid
|
||
sequenceDiagram
|
||
participant App as Chat Application
|
||
participant Core as Harness Core
|
||
participant Agent as Diagnosis Agent
|
||
participant Tool as ACI Tool Boundary
|
||
participant Audit as Audit Hook / Trace Recorder
|
||
participant EG as EvidenceGuard
|
||
participant SG as SemanticGuard
|
||
participant Release as Release Policy
|
||
|
||
App->>Core: start RunContext
|
||
App->>Agent: query + safe previous_turn
|
||
Agent->>Tool: tool name + framework tool_call_id + typed args
|
||
Tool-->>Agent: bounded agent_result
|
||
Tool->>Audit: bounded Tool lifecycle metadata
|
||
Agent->>Audit: step metadata + Provider reasoning availability
|
||
Agent-->>App: DiagnosisDraft
|
||
App->>EG: Draft + current Run canonical invocations
|
||
EG-->>App: verified snapshot or deterministic failure
|
||
App->>SG: query + full Draft + verified snapshot
|
||
SG-->>App: SUPPORTED / UNSUPPORTED
|
||
App->>Release: decide public content
|
||
Release-->>App: report or fixed fallback
|
||
```
|
||
|
||
## 4. PreviousTurn
|
||
|
||
PreviousTurn 只来自同一 Session 最近一个 `DIAGNOSIS + SUCCESS + published_result`。Fallback、失败、取消、raw evidence 和完整历史都不能进入下一轮;字段与字节上限由 Harness 配置控制。
|
||
|
||
## 5. Provider Reasoning 审计
|
||
|
||
`HarnessAgentAuditHook` 在每次模型步骤结束后检查 `AssistantMessage` metadata。当前识别 `reasoning_content`、`reasoningContent`、`reasoning` 和 `thinking`,但只接受 Provider 实际返回的非空文本:
|
||
|
||
- 有内容时写入 `agent_reasoning_audit`,单条最多保留 32000 个字符,并记录 UTF-8 `content_bytes`。
|
||
- 无内容时写入 `reasoning_available=false`、`reasoning_content=NULL`、`content_bytes=0`,不得根据最终回答反推或生成 reasoning。
|
||
- `agent_step.thought` 始终为空;步骤表只记录 message count、roles、是否有文本、Tool names、reasoning availability 和字节数等 metadata。
|
||
- 普通 `diagnosis_trace_event` 的 `AGENT_MODEL_STEP` 只记录 reasoning availability/bytes,不保存 reasoning 原文。
|
||
- Reasoning 只用于受限审计,不进入 Agent 后续上下文,不参与 EvidenceGuard、SemanticGuard 或 Release Policy 的事实判断。
|
||
|
||
当前查询隔离已经实现,完整访问治理和真实 Provider 行为验证仍属于 ISS-015。
|