Repository navigation
Replies: 1 comment 2 replies
|
Your diagnosis matches the failure mode: optional chaining only handles a missing adapter, not an adapter object whose const adapter = this.adapters.get(provider)?.adapter;
const pricing = adapter?.imageRequestPricing;
return typeof pricing === 'function'
? pricing.call(adapter, provider, model)
: undefined;I’d add an adapter-contract test for a legacy duck-typed adapter, plus a |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
DSH 0.2.0-rc.2 压缩上下文失败问题反馈
场景
DSH 版本:0.2.0-rc.2
Profile:web
操作系统:Windows
你碰到的问题或情况
执行 /compact 命令压缩上下文时,命令执行失败,返回错误:command.execute failed: gateway/internal: this.adapters.get(...)?.adapter.imageRequestPricing is not a function
复现步骤
在 DSH Web UI 中打开任意已有一定历史的会话
输入 /compact 并发送
命令立即返回上述错误,上下文压缩未执行
根因分析
该报错来自 DSH 运行时 LlmRuntime.imageRequestPricing 的调用点:this.adapters.get(provider)?.adapter.imageRequestPricing(provider, model)
这里的可选链 ?. 只保护了“适配器不存在”的情况,没有保护“适配器存在但未实现 imageRequestPricing 方法”的情况。当已注册的 LLM 适配器是鸭子类型(普通对象)且未实现该方法时,直接抛出 TypeError。
imageRequestPricing 是 DSH 0.1.2-rc.1 新增的接缝。第三方插件(如视觉类、搜索类插件)通过鸭子类型注册适配器时,不会自动获得该方法,导致 /compact 在调用 tokenMeter.measure() 解析图片计价时崩溃。
已验证的排查
卸载 @liustack/modsearch 后问题仍存在
卸载 @anionex/dsh-vision-toolkit 后问题仍存在
说明问题不局限于特定插件,而是 DSH 运行时缺少对适配器方法存在性的防御
影响
/compact 命令完全不可用
自动压缩静默失效
会话上下文持续增长,最终触及上下文窗口上限被截断
期望结果
在 LlmRuntime.imageRequestPricing 调用点增加方法存在性检查,或在适配器注册时通过基类/契约检查自动注入默认实现:const adapter = this.adapters.get(provider)?.adapter
if (typeof adapter?.imageRequestPricing === 'function') {
return adapter.imageRequestPricing(provider, model)
}
return undefined
All reactions