Add command model, priority tie-break, and boundary matching (I1 WP1/WP4/WP5) #6

Merged
weichen merged 2 commits from feature/agent-stack-i1 into main 2026-10-07 07:28:19 +00:00
Owner

I1 增量一(库侧):命令模型、同分决胜与词界匹配(WP1/WP5/WP4)

按 Documents 提案 2026-10-07-agent-stack-n1q1i1-plans.md §4.2 落地 I1 的库侧前三块。

改动

  • WP1 命令模型:新 intent/command.go——Command 联合(start/set_slot/change_slot/cancel/clarify/chitchat/handoff)+ ActionRef{Kind, ID}(auto/handler/blueprint,command/workflow 预留给 WP2 的 spec.action)。Result.Commands 单点展开(deriveCommands):
    • matched 槽位齐全 → 单条 Start;有缺失/非法 → Start(带已抽槽)+ Clarify(合并缺失、取槽位建议提问);
    • expectation_hit → 每槽一条 SetSlot;齐了追加 Start(验收形态「SetSlot 加 Start」),不齐追加 Clarify;
    • ambiguous → 单条 Clarify(候选消歧);guard_hit/fallback → 空(宿主语义,不代为表达)。
      ActionRef 推导:metadata.blueprint → blueprint;Handler → handler;否则 auto(宿主在命令总线与工作流间裁决,与现网兼容)。Top/Branch 全部保留。
  • WP5 同分决胜(I5):分差为 0 且前两名 Priority 不同 → 高优先者直接 matched(Explain 同规则);同 Priority 仍 ambiguous;非零分差 < margin 仍 ambiguous(margin 语义不变)。受影响的既有夹具:分类器套件改用新增的等优先级对(demo.tie.alpha/beta),greet 语料用例改述为 I5 决胜结果。
  • WP4 词界(I3):MatchSpec.Boundary(默认 false 零行为变化)。规则:右缘必须(「配置」不命中「配置项」、「write」不命中「rewrites」);左缘仅拉丁词条要求(「改配置」里的「配置」仍算命中——中文没有天然词界,右封左放)。intentctl lint 新增词界提示:短词条(≤2 字符)且未开 boundary 的 spec 逐条列出(非错误,实测输出正常)。
  • 语料:corpus.json 的 greet 用例改述为 tie-break 结果 + 新增 tie_ambiguous 保 ambiguous 覆盖。

验证

  • go vet ./... 通过;go test -count=1 ./... 6 包全 ok。
  • 新测:command 6(齐全 Start、缺失 Start+Clarify 含提问、SetSlot+Start、ambiguous Clarify、fallback 空、ActionRef 推导)、boundary 3(CJK 误命中压制、拉丁词缘、决胜与 Explain 一致)。

主任务:Dev 仓 feature/agent-stack-i1。

# I1 增量一(库侧):命令模型、同分决胜与词界匹配(WP1/WP5/WP4) 按 Documents 提案 `2026-10-07-agent-stack-n1q1i1-plans.md` §4.2 落地 I1 的库侧前三块。 ## 改动 - **WP1 命令模型**:新 `intent/command.go`——`Command` 联合(start/set_slot/change_slot/cancel/clarify/chitchat/handoff)+ `ActionRef{Kind, ID}`(auto/handler/blueprint,command/workflow 预留给 WP2 的 spec.action)。`Result.Commands` 单点展开(`deriveCommands`): - matched 槽位齐全 → 单条 Start;有缺失/非法 → Start(带已抽槽)+ Clarify(合并缺失、取槽位建议提问); - expectation_hit → 每槽一条 SetSlot;齐了追加 Start(验收形态「SetSlot 加 Start」),不齐追加 Clarify; - ambiguous → 单条 Clarify(候选消歧);guard_hit/fallback → 空(宿主语义,不代为表达)。 ActionRef 推导:metadata.blueprint → blueprint;Handler → handler;否则 auto(宿主在命令总线与工作流间裁决,与现网兼容)。Top/Branch 全部保留。 - **WP5 同分决胜(I5)**:分差为 0 且前两名 Priority 不同 → 高优先者直接 matched(Explain 同规则);同 Priority 仍 ambiguous;非零分差 < margin 仍 ambiguous(margin 语义不变)。受影响的既有夹具:分类器套件改用新增的等优先级对(demo.tie.alpha/beta),greet 语料用例改述为 I5 决胜结果。 - **WP4 词界(I3)**:`MatchSpec.Boundary`(默认 false 零行为变化)。规则:右缘必须(「配置」不命中「配置项」、「write」不命中「rewrites」);左缘仅拉丁词条要求(「改配置」里的「配置」仍算命中——中文没有天然词界,右封左放)。`intentctl lint` 新增词界提示:短词条(≤2 字符)且未开 boundary 的 spec 逐条列出(非错误,实测输出正常)。 - 语料:`corpus.json` 的 greet 用例改述为 tie-break 结果 + 新增 tie_ambiguous 保 ambiguous 覆盖。 ## 验证 - `go vet ./...` 通过;`go test -count=1 ./...` 6 包全 ok。 - 新测:command 6(齐全 Start、缺失 Start+Clarify 含提问、SetSlot+Start、ambiguous Clarify、fallback 空、ActionRef 推导)、boundary 3(CJK 误命中压制、拉丁词缘、决胜与 Explain 一致)。 主任务:Dev 仓 `feature/agent-stack-i1`。
weichen added 1 commit 2026-10-07 07:22:23 +00:00
Add command model, priority tie-break, and boundary matching
ci / vet-and-test (pull_request) Successful in 17s
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
fa512ec03c
Why: I1 increment one - recognition output becomes a command list
for the host router, same-score ties resolve by priority (I5), and
CJK substring false positives get an opt-in boundary mode (I3).

Evidence: go vet clean; go test ./... all ok, including new command
(6), boundary (3), and tie-break tests; intentctl lint smoke run
shows boundary hints on short unbounded terms. Existing classifier
and ambiguity fixtures repointed to an equal-priority pair; the
greet corpus case now expects the I5 tie-break outcome.

Impact: Result gains Commands; recognizer derives them at one point
(guard/fallback stay empty); MatchSpec gains Boundary (default off,
legacy behavior unchanged); lint gains boundary hints. Top/Branch
stay for compatibility.

Refs: Documents proposal 2026-10-07-agent-stack-n1q1i1-plans.md I1 WP1/WP4/WP5
weichen added 1 commit 2026-10-07 07:27:51 +00:00
Merge origin/main into the I1 branch
ci / vet-and-test (pull_request) Successful in 17s
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
a007586f71
weichen merged commit c407554d6d into main 2026-10-07 07:28:19 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-Intent#6