refactor(server): Phase 1 图拓扑重构 - LangGraph 成为唯一编排者

P1.3-P1.7:把 endpoint 补丁搬进图节点,门控收敛到 gate_classify 单一决策点。

- StewardGraphState 扩展:recent_history/steward_state/gate_decision/gate_scene_id/conversation_id
- 新增 5 个图节点:load_context(读历史+state)/gate_classify(统一门控)/execute_scene_handler/resume_recent_task/pending_flow wrapper
- 图拓扑从 5 节点重构为 10 节点:load_context → gate_classify → {off_topic/handler_only/resume/ambiguous/model_intent} → attach_action_steps
- gate_classify 四步裁决:resume门 → off_topic门 → 规则匹配门 → LLM门
- resume 门控优先于 off_topic,避免'再提交'被误判闲聊
- schema 放宽 planning_source/next_action Literal → str,支持 scene_handler:*/context_resume/answer_only
- endpoint 按 planner 类型分发 build_plan(LangGraph 接 db,legacy 不接)
- 76 passed + 4 场景端到端验证(出差申请/再提交/查差旅标准/闲聊)
This commit is contained in:
caoxiaozhu
2026-06-25 15:44:20 +08:00
parent 54356ba81a
commit 992cf71fa1
4 changed files with 461 additions and 13 deletions

View File

@@ -83,6 +83,18 @@
- 影响为后续图拓扑重构P1.3-P1.8)提供了声明式场景注册基础设施。当前 scene_registry 与现有 intent_registry 并存,后续 P1.3-P1.7 会把 intent_registry 的消费者逐步迁移到 scene_registry。
- 下一步P1.3-P1.8 图拓扑重构(新增 load_context/gate_classify/resume/persist 节点、endpoint 退化、registry 消费者迁移)。
- 01:30我完成了统一门控管道 Phase 1 的图拓扑重构P1.3-P1.7LangGraph 成为唯一编排者。
- Git 提交检查:本地与 origin/main 同步。
- 修改①(图节点扩展):`steward_graph_planner.py``StewardGraphState` 新增 recent_history/steward_state/gate_decision/gate_scene_id/conversation_id 字段。新增 5 个图节点——`load_context`读最近10条历史+steward_state+注入recent_history到request`gate_classify`(统一门控裁决,resume门→off_topic门→规则匹配门→LLM门四步顺序`execute_scene_handler`HANDLER_ONLY 路由,构造 StewardActionExecuteRequest 调 handler`resume_recent_task`RESUME 路由,从 state 恢复 task`_build_pending_flow_fallback_graph_plan`ambiguous 路由 wrapper
- 修改②(图拓扑):从 5 节点prepare_context→{model/off_topic/fallback}→attach_action_steps重构为 10 节点load_context→gate_classify→{off_topic/handler_only/resume/ambiguous/model_intent}→各自分支→attach_action_steps
- 修改③endpoint 退化endpoint 的 inject/resume 补丁搬进图节点hydrate/persist 仍由 endpoint 调(阶段性保留,P3 收敛到图内)。按 planner 类型分发 `build_plan(payload, db=db)`LangGraphvs `build_plan(payload)`legacy
- 修改④schema 放宽):`StewardPlanningSource`/`StewardPlanNextAction` 从 Literal 改 str,支持 scene_handler:*/context_resume/answer_only 等新值。
- 修改⑤resume 门控优先级resume 门控提到 off_topic 门之前,避免"再提交"被误判 off_topic。
- 验证:后端全量 **76 passed**;端到端 4 场景全部通过——①出差申请(llm_function_call, 1 task)、②再提交(context_resume, 1 task, 5 fields)、③查差旅标准(scene_handler:query_travel_standard)、④闲聊(off_topic)。
- 影响LangGraph 图成为唯一编排者,门控收敛到 gate_classify 单一决策点。endpoint 仍保留 hydrate/persist 两个补丁,P3 会收敛。
## TODO
## TODO
- [ ]`quick_validate.py` 准备稳定运行环境,避免后续新增 Skill 时继续依赖人工兜底。来源09:18 技能校验)