Repository navigation
[Bug] 插件无法触达 compaction 服务:声明 inject 后条目永久 pending(0.2.0-rc.2 实测) #9425
Replies: 2 comments
|
Your strongest piece of evidence is not the plugin's own
export const inject = ['commands', 'compaction']
...
const result = await ctx.compaction.compactNow(invocation.agent, invocation.signal, invocation.commandId)and the registration itself is inside ctx.effect(function* () {
yield ctx.commands.register({ definitionId: ..., name: 'compact', description: ..., handler })
}, 'command-compact lifecycle')
Why the service is absent, in one line of the code you quoted. export abstract class CompactionEngine extends Service {
constructor(ctx: Context) { super(ctx, 'compaction') }
Two facts would settle it in one minute, and they are cheaper than the four probe paths you tried:
Your requested "request a fold" channel already exists one layer up, and it is supported API. async execute(agent, line, submittedAttachments, signal): Promise<CommandExecution | undefined>A plugin that holds For the third ask — making the failure visible — there is already a published tool. The read-only probe results are the part I would keep in the issue: four resolution paths failing for |
|
感谢——这份回复把我们卡住的地方往前推了一大步。我们当场做了核实:一处印证了你的方向,两处推翻了推断(包括我自己原来的结论)。 1. 「缺失 compact ⇒ command-compact 未激活」:结果对,机制不同最新一次启动的激活表里没有任何 pending 条目(desktop 版会把激活区块写进 host log,不只是 stderr 缓冲): 那两行是我们那条注入声明造成的, 所以要更正的是: 2. 而
|
Uh oh!
There was an error while loading. Please reload this page.
English summary — In
0.2.0-rc.2a plugin cannot reach thecompactionservice from its own context. Declaringinject: [..., 'compaction']leaves the entrypending (waiting for service: compaction)forever, so the plugin never loads at all;ctx.get('compaction'),ctx.reflect.get('compaction', false),ctx.compactionand a liveagent.ctxall fail to resolve it, whiletokenMeterresolves on every one of them. The only pattern the ecosystem uses is taking over the seam (disablecompaction-basic, implementCompactionEngine). Request: make the service injectable from a plugin, or expose a supported "request a fold" event/API (see 诉求 at the end).环境
desktop;bundles 内含自研插件dsh-context-truth0.2.0(遥测类,不是压缩后端)现象一:声明注入 → 条目永久 pending,插件完全不加载
启动日志(host log):
同一份
inject里tokenMeter能解析(pending 的原因只报compaction);把compaction去掉后条目立刻正常加载。也就是说:一次声明失误会让整个插件静默消失(连它提供的 runtime-context 行一起),而唯一的提示就是上面那一行。现象二:不声明注入,四条取服务的路径全部拿不到
同一进程内的同步只读探针(插件形式的后侧工具,分别从 root 作用域和一个活着的 agent 上下文各测一次):
compactiontokenMeter(对照)ctx.get(name)undefinedctx.reflect.get(name, false)undefinedctx[name](属性访问)stringstringagent.ctx.get(name)undefinedctx.root.compactionundefined另外:
ctx.root.reflect.props里compaction是已声明的服务(type: 'service'),但ctx.root.reflect.store有 0 个键——实现落在插件分支够不到的 store 里;commands,只有balance, chat, commandcode-refresh, commandcode-setkey, commandcode-status, export, feedback, permission, pet——没有compact;sessionController(26 方法) /agents(25) /sessions(16) /sessionQuery(22) /agentLoop(13) /sessionTelemetry(3) 都没有任何压缩相关方法。一个会误导诊断的细节:属性访问取不到服务时,返回的是字符串而不是
undefined。插件侧写if (ctx.compaction !== undefined)会认为服务存在,然后在形状检查上失败——我们为此排错了两轮。我们试过的三条路径(都不是插件侧能修的)
ctx.get('compaction')/ctx.reflect.get(..., false)→ 取不到(get走ctx.reflect,实现存在提供者的 store 里);ctx.inject(['compaction'], child => …)→ 回调从不执行(依赖永远等不到);inject: ['systemPrompt', 'tokenMeter', 'compaction']→ 条目永久 pending(本次报告的核心)。生态现状:只有"接管接缝"一条路
被调查的三个压缩类插件都是
CompactionEngine子类、自己提供ctx.compaction,并用 patch 关掉官方后端再插入自己(fan56/dsh-dcp的 bundle patch 原文):JohnXu22786/context-pruner的头注释写得更直白:「ctx.compaction 服务提供者:把核心分诊引擎接入 dsh 的压缩能力接缝」;Zhuchen00123/dsh-compaction-cacheaware同样是CacheAwareCompactionEngine extends CompactionEngine。结论:消费该服务的插件目前没有位置——要么接管整个接缝(重写摘要事务、checkpoint 格式、保留比例……),要么拿不到。
诉求(按侵入性从低到高)
compaction:把后端提供到插件可达的作用域(或在文档里说明为什么不能);compaction/request)或一个 API(如agents.requestCompaction(agent, reason)),让非后端插件能在任务边界请求一次折叠;这个能力为什么有用(附实测)
自动压缩是**"跨过阈值"**触发,而模型在临近阈值时的理性收缩(合并往返、回避高风险改动、改到一半先提交 WIP)恰好使读数停在阈值之下:
我们想要的只是很小的一个动作:在模型自己的回合边界(
agent/status === 'idle'),余量进入窗口 5% 时请求一次折叠(折完余量回到几百 K,条件不再满足,一个周期只折一次)。触发逻辑已经实测正确——两次都在正确的时机、正确的余量下触发——唯一缺的就是服务不可达。All reactions