fischer-agentkit/docs/plans/2026-06-16-005-code-review-...

40 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 代码审查修复报告
日期: 2026-06-16
分支: feat/simple-router-architecture
审查范围: SimpleRouter + Prompt-based Tool Calling 重构
## 修复的问题
### HIGH 级别
| # | 问题 | 修复方式 | 文件 |
|---|------|----------|------|
| H1 | execute() 缺少 prompt-based tool calling 注入 | 与 execute_stream() 一致,在 execute() 中注入 _build_tool_use_prompt | react.py |
| H2 | agent._routing_result 竞态条件 | _resolve_for_chat 返回 routing_result 而非 monkey-patch agent | portal.py |
| H3 | TEAM_COLLAB/REWOO/REFLEXION 降级为 REACT 无提示 | 添加 execution_mode 完整分支处理,高级模式降级时记录 warning 日志 | portal.py, chat.py |
| H4 | Any 类型滥用 | SimpleRouter 使用 SkillRegistry/Tool 类型ConversationStore 使用 SessionManager 类型 | simple_router.py, portal.py |
### MEDIUM 级别
| # | 问题 | 修复方式 | 文件 |
|---|------|----------|------|
| M1 | default_system_prompt `or` vs `is not None` | 改为 `if default_system_prompt is not None` | simple_router.py |
| M2 | CostAwareRouter 死代码 | 改为条件初始化legacy_cost_aware_router 配置项),默认不初始化 | app.py |
| M3 | chat.py 不处理 DIRECT_CHAT | 添加 DIRECT_CHAT 分支:直接 LLM 调用,不经过 ReActEngine | chat.py |
## 测试结果
- SimpleRouter 单元测试: 20/20 通过
- SimpleRouter E2E 回测: 24/24 通过(准确率 100%
- chat/core 单元测试: 153/153 通过
- Ruff lint: All checks passed
## 变更文件
1. `src/agentkit/core/react.py` — execute() 添加 prompt-based tool calling 注入
2. `src/agentkit/chat/simple_router.py` — 类型注解修复Any → SkillRegistry/Tool`is not None` 修复
3. `src/agentkit/server/routes/portal.py` — 竞态条件修复execution_mode 完整分支,类型修复
4. `src/agentkit/server/routes/chat.py` — DIRECT_CHAT 处理execution_mode 降级警告
5. `src/agentkit/server/app.py` — CostAwareRouter 条件初始化,移除 semantic router build_index 死代码