89 lines
3.1 KiB
Markdown
89 lines
3.1 KiB
Markdown
# 修订记录 - 2026-04-13
|
|||
|
|
|
||
|
|
## 今日任务
|
||
|
|
修复"/api/agent/execute"执行核型分析时返回错误阶段的问题
|
||
|
|
|
||
|
|
## 问题描述
|
||
|
|
用户说"帮我执行核型分析",但系统执行了identify阶段,而不是synteny+karyotype阶段。
|
||
|
|
|
||
|
|
## 根本原因
|
||
|
|
1. `/api/agent/plan` 直接调用 `orchestrator.plan()` → PlanningAgentV2,正确返回['synteny', 'karyotype']
|
||
|
|
2. `/api/agent/execute` 调用 `orchestrator.run()` → LangGraph → `_planning_node` → PlanningAgentV2
|
||
|
|
3. `completed_stages` 在传递过程中丢失,PlanningAgentV2收到空列表
|
||
|
|
|
||
|
|
## 已完成的修复
|
||
|
|
|
||
|
|
### 1. IntentAgentV2 依赖定义统一
|
||
|
|
**文件**: `gfa_core/mas/agents/intent_v2.py`
|
||
|
|
- 将 `synteny` 依赖从 `["identify", "phylogeny"]` 改为 `["identify"]`
|
||
|
|
- 添加 karyotype 关键词检查到 fallback 方法
|
||
|
|
- 修改 LLM prompt,明确指示不要过度推断
|
||
|
|
|
||
|
|
### 2. PlanningAgentV2 使用 completed_stages
|
||
|
|
**文件**: `gfa_core/mas/agents/planning_v2.py`
|
||
|
|
- 在 `_generate_plan_with_llm` 中添加逻辑,检查依赖阶段是否已完成
|
||
|
|
- 添加调试日志 `print(f"[PlanningAgentV2] completed_stages: {completed_stages}")`
|
||
|
|
|
||
|
|
### 3. 接受 partial_success 作为已完成状态
|
||
|
|
**文件**: `apps/web/vue3/main.py`
|
||
|
|
- `/api/agent/plan` 现在接受 `partial_success` 作为已完成状态
|
||
|
|
|
||
|
|
### 4. LangGraphOrchestrator 使用 PlanningAgentV2
|
||
|
|
**文件**: `gfa_core/mas/core/langgraph_orchestrator.py`
|
||
|
|
- 将 `PlanningAgent` 改为 `PlanningAgentV2`
|
||
|
|
- 修复 `state.get("user_input")` 可能为 None 的错误
|
||
|
|
- 在 `_to_agent_state` 中添加 `completed_stages` 传递
|
||
|
|
|
||
|
|
### 5. tasks.py 使用 LangGraphOrchestrator
|
||
|
|
**文件**: `tasks.py`
|
||
|
|
- 将 `Orchestrator` 改为 `LangGraphOrchestrator`
|
||
|
|
- 添加 `messages` 字段到 initial_state
|
||
|
|
- 添加 `completed_stages` 查询逻辑
|
||
|
|
- 添加调试日志
|
||
|
|
|
||
|
|
### 6. GraphState 添加 completed_stages 字段
|
||
|
|
**文件**: `gfa_core/mas/core/state.py`
|
||
|
|
- 添加 `completed_stages: list[str]` 字段
|
||
|
|
|
||
|
|
## 当前状态
|
||
|
|
|
||
|
|
### 验证结果
|
||
|
|
|
||
|
|
**`/api/agent/plan` 测试**:
|
||
|
|
```bash
|
||
|
|
curl -s "http://localhost:7867/api/agent/plan" \
|
||
|
|
-X POST -H "Content-Type: application/json" \
|
||
|
|
-d '{"message":"帮我执行核型分析","session_id":"job_1776004000991"}'
|
||
|
|
# 返回: ['synteny', 'karyotype'] ✅ 正确
|
||
|
|
```
|
||
|
|
|
||
|
|
**`/api/agent/execute` 调试日志**:
|
||
|
|
```
|
||
|
|
[tasks.py] Completed stages: ['identify', 'phylogeny'] ✅ 正确查询
|
||
|
|
[PlanningAgentV2] completed_stages: [] ❌ 收到空列表
|
||
|
|
```
|
||
|
|
|
||
|
|
### 待解决问题
|
||
|
|
`completed_stages` 在从 `tasks.py` 传递到 `PlanningAgentV2` 的过程中丢失
|
||
|
|
|
||
|
|
可能原因:
|
||
|
|
1. LangGraph 工作流中 state 被修改导致 `completed_stages` 丢失
|
||
|
|
2. `_to_agent_state` 方法没有正确读取 `completed_stages`
|
||
|
|
3. RouterAgent 或其他节点修改了 state
|
||
|
|
|
||
|
|
## 明日计划
|
||
|
|
1. 修复 `completed_stages` 传递丢失问题
|
||
|
|
2. 验证 `/api/agent/execute` 正确返回 ['synteny', 'karyotype']
|
||
|
|
3. 测试完整执行流程
|
||
|
|
|
||
|
|
## 总体计划
|
||
|
|
1. 修复阶段依赖识别问题 ✅
|
||
|
|
2. 修复 completed_stages 传递问题 ⏳
|
||
|
|
3. 测试核型分析完整流程 ⏳
|
||
|
|
4. 修复其他潜在问题 ⏳
|
||
|
|
|
||
|
|
## 今日完成任务数
|
||
|
|
**已完成**: 6 项修复
|
||
|
|
**进行中**: 1 项(completed_stages 传递)
|
||
|
|
**剩余**: 3 项
|