fix(routing): 根治模型路由×provider解析,修复 compaction 静默失效#202
Merged
Conversation
纯 GPT 部署下 /compact 与 auto-compact 从不生效:摘要任务被 build_model_router 硬编码默认成 claude-haiku,但无 Anthropic provider, 解析失败被静默成 Ok(false)。生产 session 因此上下文涨到 68万 token 顶 25.6万 窗口、237 turn 0 次成功压缩,切 gpt-5.4/5.5 都无效。 根因是"选模型→找 provider"两步各自决定、provider-盲默认散落、失败 处理不一致。本次从架构上收敛: - Kernel::resolve_task 成为唯一 provider 感知解析咽喉;compaction 与 classifier 都走它(classifier 经 ProviderResolver trait 委托同一实现) - 删 build_model_router 的硬编码摘要默认;未配置任务回落主模型 (ModelRouter::resolve 既有 fallback),省钱靠显式 model_routing.summarization - SharedModelRouter/ModelRouterReader 读写句柄分离:runner 持写、 classifier 持只读,共享单一 Arc,/model 切换被双方实时观测, single-writer 由类型固化(修 classifier stale) - 启动期 preflight 校验 settings.model + model_routing,逐条不可解析报 error/warn(软警告不 bail);provider 缺失时 compaction 发可见 Stream 提示而非终止语义的 Error(避免子 agent 视图被弹回 root) - 卫生:hook prompt 删 claude-haiku 默认(无 model 则 skip); DEFAULT_MODEL 提取为 loopal-config SSOT 测试:新增 resolve_task/is_model_resolvable/preflight/SharedModelRouter 单测 + compaction provider-error e2e + reader 观测 /model 切换 e2e; 全量 94/94 通过、clippy 零警告、所有文件 ≤200 行。
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.
Summary
/compact与 auto-compact 从不生效:摘要任务被build_model_router硬编码默认成claude-haiku,无 Anthropic provider 时解析失败被静默成Ok(false)(生产 session 涨到 68万 token 顶 25.6万 窗口、237 turn 0 次成功压缩)。Changes
Kernel::resolve_task(kernel/resolve.rs);compaction 与 classifier 都经它解析,classifier 经ProviderResolvertrait 委托同一实现。build_model_router硬编码摘要默认,未配置任务回落主模型;省钱靠显式model_routing.summarization。SharedModelRouter(写)/ModelRouterReader(读)共享同一Arc,/model切换被双方实时观测,single-writer 由类型固化(修 classifier stale)。preflight校验settings.model+model_routing(软警告不 bail);provider 缺失时 compaction 发可见Stream提示而非终止语义的Error。claude-haiku默认(无 model 则 skip);DEFAULT_MODEL提取为loopal-configSSOT。loopal-kernel(resolve/preflight)、loopal-provider-api(SharedModelRouter)、loopal-provider(is_model_resolvable)、loopal-runtime(compaction/llm)、loopal-agent-server(wiring/preflight)。Test plan
resolve_task/is_model_resolvable/preflight/SharedModelRouter单测 + compaction provider-error e2e + reader 观测/model切换 e2e。