信号
概览
信号把请求事实变成决策可复用的名称。例如,信号可以识别长提示、工具密集的对话、某种语言,或可能的提示注入。决策再根据该信号是否匹配来选择动作。
需要在决策运行前把多个信号组合成分数、分区或路由档位时,使用投影。
主要优势
- 同一检测器可被多条决策复用。
- 检测逻辑与路由结果分离。
- 一条路由可组合词法、策略、语义与安全输入。
- 信号名成为稳定策略构件,配置审查更容易。
解决什么问题?
没有信号层时,每条决策都要内联检测逻辑。这会造成重复、路由策略难审计,并把「检测到了什么」与「应该做什么」混在一起。
信号把请求理解变成命名目录,供路由图其余部分组合。
何时使用
在以下情况使用信号:
- 多条路由需要同一检测器
- 同一决策树要混合多种检测方式
- 需要在检测、决策逻辑、算法与插件之间划清边界
- 希望调检测而不改写路由结果
配置
在规范 v0.3 YAML 中,信号位于 routing.signals:
routing:
signals:
keywords:
- name: urgent_keywords
operator: OR
keywords: ["urgent", "asap"]
embeddings:
- name: technical_support
threshold: 0.75
candidates: ["installation guide", "troubleshooting steps"]
- name: account_management
threshold: 0.72
candidates: ["billing information", "subscription management"]
projections:
partitions:
- name: support_intents
semantics: exclusive
temperature: 0.3
members: [technical_support, account_management]
default: technical_support
scores:
- name: request_difficulty
method: weighted_sum
inputs:
- type: embedding
name: technical_support
weight: 0.18
value_source: confidence
mappings:
- name: request_band
source: request_difficulty
method: threshold_bands
outputs:
- name: support_escalated
gte: 0.25
按需要检测的事实类型选择信号。