Why: I2 layering - between rules and the L2 classifier there is now a deterministic host-scored semantic layer (rules then semantic then model), and fallback can be rescued by a validated command generator instead of going straight to the default channel. Evidence: go vet clean; full suite ok, including ten new tests (rerank resolve/below-threshold/tie/error-then-L2, generator valid/invalid/error, catalog top-k). Impact: IntentSpec gains Examples; Options gains Semantic (with threshold), Generator; ambiguous candidates rerank through host scores before L2; fallback validates generated commands (action/slots/kind fail-closed) and synthesizes Top with slots; generated commands are no longer overwritten by deriveCommands; CatalogTopK by priority. Refs: Documents proposal 2026-10-07-agent-stack-n1q1i1-plans.md I2
18 lines
959 B
Go
18 lines
959 B
Go
package intent
|
|
|
|
import "context"
|
|
|
|
// CommandGenerator 模型命令生成端口(I2):宿主用模型实现
|
|
// (借鉴 Rasa 的 LLM command generators:只把相关流程交给生成器)。
|
|
// 只在规则与语义都未命中(fallback)时被调用;实现自担延迟与成本。
|
|
// 返回错误时识别保持 fallback,不会使 Recognize 失败。
|
|
//
|
|
// 库侧校验与 deriveCommands 同款:start 命令的 ActionRef 必须可解析——
|
|
// auto/command/workflow/blueprint 的目标必须在 catalog 的 spec ID 集合内,
|
|
// handler 的目标必须在 catalog 的 Handler 集合内;槽位键必须在目标 spec 的
|
|
// 槽位键集合内(可解析时)。生成器幻觉一律 fail-closed 回 fallback。
|
|
type CommandGenerator interface {
|
|
// Generate 基于输入与能力目录产出命令列表(catalog 由调用方按 top-k 给)。
|
|
Generate(ctx context.Context, input string, catalog []CatalogSpec) ([]Command, error)
|
|
}
|