Repository navigation
DSH | dsh-block-ptc | 动态上下文压缩:让模型按任务区块收口,保留自己写的交接摘要 #9754
mengwEX
started this conversation in
Show Your Plugins!
Replies: 0 comments
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.
项目地址:mengwEX/dsh-block-ptc
npm:dsh-block-ptc
文档:中文 · English
适配基线:DeepSeek Harness 0.2.0-rc.2,MIT。
做什么
给 PTC 模式加一层按任务区块收口的动态上下文压缩。长会话里,一个子任务已经完成,原始工具结果和中间过程却还一直占着后续请求的上下文;这个插件让模型自己标记工作区块,并在完成时交上自己写的交接摘要。
block_run_code({ id, description, code }):给每次程序执行附上区块 ID,通过嵌套派发委派到内置run_code,复用宿主的工具 SDK、沙箱与执行机制。await tools.block_summary({ id, summary }):从程序内部提交摘要,在模型可见的上下文里替换已完成区块的消息。摘要是模型当前生成的内容,不另起一次摘要模型请求;生成摘要本身仍消耗 token。与 DSH 如何集成
这是声明了
dsh.bundle.patch的可安装 bundle。安装后新增独立的 Block PTC agent preset,不覆盖原生ptc预设。插件注册block_run_code、block_summary和直接调用 guard;通过 DSH 原有 surface replacement / compaction 事务提交替换,不调用内置 compaction engine 额外生成摘要。安装
在 Harness 的 Plugin Manager 中按包名 dsh-block-ptc 安装,或让启用了 Plugin Manager 工具的 agent 安装:
安装后重启应用,新建会话时选择 Block PTC。例如给它任务:“读 parser 模块并解释 tokenizer,完成后把这块收口,再继续看 lexer。”
上下文与缓存机制图
这是机制示意,不是宿主界面截图或真实 API 基准。 两组重放相同的模拟工作量,token 权重人工指定;替换范围由实际插件逻辑生成,缓存使用理想化前缀模型。原始数据、假设和重现脚本 已公开。
整根柱子是输入上下文,蓝色是模拟缓存命中,橙色是未命中。已完成区块被替换后,后续请求的上下文减少,但改写历史也会使后面的缓存前缀失效,所以图中明确展示了前缀重建。上下文变小不保证命中率更高或账单下降;暂不宣称真实费用、速度或任务质量提升。
摘要有损,模型没有写进交接摘要的细节可能从它后续的上下文里消失。
tokensFreed是被替换消息的估算 token 数,尚未扣除摘要开销,不能当作 API 缓存命中统计。English summary
Model-directed dynamic context compaction for PTC mode. Group program runs into named blocks, then let the model close completed work with its own handover summary. The plugin delegates execution to the built-in PTC transport and uses DSH's surface-replacement transaction. Original log events, system/user messages and the in-flight tool pair are retained. It adds a separate Block PTC preset and is available on npm as
dsh-block-ptc.The figure is a reproducible mechanism illustration, not measured API usage. It shows both reduced context and the cache-prefix rebuild that history replacement can cause. Smaller context is not a promise of higher cache hit rate or lower cost.
欢迎试用和反馈,尤其是区块收口时机、摘要遗漏、跨任务交接和真实 cache usage 的表现。Issues
All reactions