fix(router): keyword match tiebreaker should preserve list order, not alphabetical

This commit is contained in:
chiguyong 2026-06-24 10:11:42 +08:00
parent d1250cf32b
commit 4ea7801bcf
1 changed files with 2 additions and 2 deletions

View File

@ -101,8 +101,8 @@ class IntentRouter:
if not candidates:
return None
# 按得分降序排序,得分相同时按 skill 名称字母序稳定排序
candidates.sort(key=lambda c: (-c[2], c[0].name))
# 按得分降序排序得分相同时保持列表顺序Python sort 稳定)
candidates.sort(key=lambda c: -c[2])
best_skill, best_kws, _best_score = candidates[0]
confidence = min(1.0, 0.5 + 0.1 * len(best_kws))