Repository navigation
【BUG/性能】压缩摘要调用不携带 reasoningEffort ⇒ 与同会话主请求的缓存键不同 ⇒ 每次压缩白烧 ≈25 万 token #9629
Replies: 1 comment
|
Confirmed on the source you cite (I read const options: GenerateOptions = {
provider: target.provider,
model: target.model,
messages,
toolHistory: agent.session.toolHistory(),
...input.tools === undefined ? {} : { tools: [...input.tools] },
maxTokens: config.maxTokens,
sessionId: agent.session.id,
purpose: 'compaction',
...signal === undefined ? {} : { signal },
}Two things that make the fix smaller than it looks, and that your report does not state:
On your caveat that you do not claim the cache mechanism — that is the right discipline, and there is upstream text that speaks to it without settling it. The module header of If it helps: a published plugin already sits on this seam, so the mitigation does not require a core patch — |
Uh oh!
There was an error while loading. Please reload this page.
在 DSH + OpenCode Go 订阅(本机:DSH kernel
0.1.7-rc.2,路由opencode-go, 模型deepseek-v4.1-flash)下,每次压缩(compaction)会额外产生约 25 万未缓存 token, 而其中绝大部分是可避免的。根因不在上游,在 DSH 侧的一处调用参数缺失:
后果:该请求的
reasoning_effort与同一会话内所有主请求的取值不同。 实测表现:把该值改为与会话一致之后,同一次压缩的缓存命中由 1.2%–8.0% 变为 99.9% (未缓存输入 227,606–280,919 → 474),其它条件(会话、模型、上游端点、请求体前 1 MiB 的字节)全部不变。因此,摘要请求此前只能命中「系统提示 + 工具定义」这段公共头,其后全部未缓存。
实测 A/B(同一会话、同一模型、同一上游端点、前缀逐字节相同):
8. 验证清单(可执行)
/compact);reasoning_effort(代理、插件或 debug 日志均可);cache_read是否仍只等于「系统提示 + 工具定义」的量级 (本机实测该量级约 24,576);9. 相关文件索引
ocgo-sync/plugin/lib/index.js(patchReasoningEffort+ 中间件分支)All reactions