Repository navigation
feat(inject): 注入条数的查询自适应——确定少注入、模糊维持上限(issue #239 第 5 项) - #263
Merged
Merged
Conversation
- 新增 injectUncertaintyAdaptive(默认关)。开启后:确定性强的话题把注入条数收缩到 一半(下限 1),模糊话题(回指/时间线索,或极短查询)维持 maxInjectedItems 上限 ——只做**单向收缩**,绝不越过用户配置的上限。 - 依据:不确定性驱动的读路径(模糊多召回、确定少召回);但「注入相关却带偏生成」 的内容可能比不注入更糟(两处独立出处),故宁可少注入也不新增该风险面。 - 判据只看查询本身、零额外检索(先探针检索等于白付一次 fuseRecall);拿不到查询 时维持现状不猜。 - 纯函数 needsBroadRecall / adaptiveInjectBudget 落在 src/search/adaptive.js(与既有 的查询自适应向量阈值同源),可单测。 - 测试:新增 test/adaptive-inject-budget.test.js 5 例(判据、预算边界、默认关行为 不变、开启后确定/模糊分档、无会话日志退化);变异测试把开关钉死 → 1 例转红。 - api 旗标锁 58 → 59;README 补一行;CHANGELOG 记入 [Unreleased]。
modusensus
force-pushed
the
feat/239-inject-uncertainty-budget
branch
from
September 19, 2026 12:42
2496c89 to
77e9c58
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
issue #239 第 5 项(注入侧不确定性召回)。第 1/3 项已随 #251 合入,第 4 项见 #259。
动机:注入条数此前是固定的
maxInjectedItems——不论用户问的是具体技术细节,还是要回忆很久以前的事,都注入同样多条。不确定性强的话题应多召回、确定性强的应少召回(去 always-on 化的一部分)。改动
injectUncertaintyAdaptivefalse。开启后:确定 → 注入条数收缩到一半(下限 1);模糊 → 维持maxInjectedItems上次之前还记得我们讨论last timeremember…),或极短查询(<5 字符,与既有adaptiveThreshold对短查询的判断同源)。fuseRecall);拿不到查询时维持现状,不猜。needsBroadRecall/adaptiveInjectBudget落在src/search/adaptive.js,与既有的查询自适应向量阈值同源、可单测。验证
test/adaptive-inject-budget.test.js5 例:判据(中英线索 / 极短 / 空查询)、预算边界(减半 / 下限 1 / 上限 0 / 非法上限)、默认关行为不变、开关打开后确定与模糊分档、无会话日志的退化路径;check-sync✓;api旗标计数锁 58 → 59;注入族回归全绿(inject17 /inject-content-cap6 /inject-rotation7 /inject-recall6 /inject-heat4 /inject-first-round-bm253)以及settings/config/lib-smoke。说明
mode='inject'留痕已记录实际注入条目,slotFillRate可观测),后续按数据再决定是否升级为学习型触发;