AI控制面生产化改造:LLM意图路由与ReAct执行边界
这次改造把 ats_iot_ai 的 Orchestrator 从 MVP 规则路由,切到生产模式的 LLM 驱动编排。
背景
线上痛点很明确:process_input 里 IntentRouter.route(query) 主要依赖模式匹配,无法稳定处理语义歧义、槽位缺失和复杂意图。与此同时,React 执行层存在 query 二次解析,执行边界不够清晰。
目标是把链路拉直为:
Understand -> Decide -> Act -> Verify -> Respond
本次核心变更
IntentRouter升级为 LLM-based 主路径。
- 保留 deterministic fast path:
tool:<name> {json}。 - 其他请求走 Qwen 结构化解析(intent/confidence/slots/missing_slots/tool_plan)。
- 新增
QwenIntentParser。
- 强约束 JSON 输出。
- 解析失败自动回退到安全 chat 路由,避免阻塞主流程。
PolicyEngine从静态 strategy map 升级为决策闸门。
- 新增 action:
execute/clarify/fallback/deny。 - 引入 confidence 阈值与 missing_slots 规则。
ReactStrategy去掉 query 二次解析。
- 仅消费结构化
tool_call,执行输入边界可控。
- 引入
Verify最小硬规则。
- 先落三条:schema、权限上下文、空结果。
- 校验失败写出
verification_failed事件并终止错误收敛。
- SSE 事件链路增强。
intent_determined增加 confidence/candidates/slots/missingSlots/toolPlan。policy_decision增加 action。- 新增
clarification_needed、verification_failed。
代码落点
app/orchestration/intent_router.pyapp/orchestration/intent_llm_parser.pyapp/orchestration/policy_engine.pyapp/orchestration/strategies.pyapp/orchestration/verify.pyapp/orchestrator.pytests/orchestrator/*
文档同步
README.md切到 Production Mode 描述。docs/REACT_ORCHESTRATOR_INTENT_UPGRADE_SPEC.md升级为生产基线(LLM 主路径、Policy 闸门、Verify 必经)。- 对应 skill 文档也从 MVP 调整为 production 导向。
测试结果
- Orchestrator 核心回归通过。
- 全量测试通过(本次改造后运行结果:
49 passed)。
结论
这次改造的关键不是“把 ReAct 做复杂”,而是先把生产边界做正确:
- 语义理解交给 LLM(结构化输出)
- 执行决策交给 Policy(代码闸门)
- 执行结果交给 Verify(质量防线)
下一步会继续做 LLM parser 的生产强化:schema 校验加强、重试与降级策略、prompt/version 管理和可观测性细化。
AI控制面生产化改造:LLM意图路由与ReAct执行边界
https://willfordzhan.github.io/2026/02/25/ai-llm-react/