Replies: 2 comments 1 reply
|
Solid analysis — I verified the source and the seam is exactly where you say, and I'd strongly support this upstream. Let me confirm the pieces: The mechanism is already there. The gap is purely the composition threading. The continuation seam is the sharp edge — good catch. This is the same shape as a gap I've seen upstream for One small thing worth deciding early: whether to call it |
|
我刚research多了一下, 只改入口只能算一个简单patch(方便其它插件启动指定模式的fork sub agent), 如果要让AI支持自然语言指定模式,还需要改
|
Uh oh!
There was an error while loading. Please reload this page.
起因是主会话用的标准模式, 在需求确认后, 会对文件内容进行大幅度修改时, 但标准模式一来一回的方式会消耗大量token,而且慢. 而在PTC模式下,通过编程一次性的操作,可以快速完成并省token. 所以希望在主会话中fork agent 并指定为PTC模式运行. 但现在dsh fork agent只能自动继承父会话的模式, 不能手动指定...
我看了一下代码, 其实只要好小的改动就能实现fork agent指定模式运行:
tool-subagent (config: presentation: 'ptc') ← 新增字段,模型/配置层
│ request
▼
subagent-in-process-driver: startInProcessRun
│ setup(childCtx) ─┐
▼ ▼
child-agent.ts: applyChildComposition(childCtx, parent, composition)
├─ composeFrom(childCtx, parent.ctx) ← 已有:加入父 preset
├─ persona / toolFilter ← 已有:只穿这两个
└─ 新增: childCtx.tools.presentAs('ptc') ← 需要加的:子代理自己 scope 的声明
具体来说:
packages/subagent/subagent/src/child-agent.ts — ChildComposition 接口加一个可选 presentation?: 'ptc'(或 mode),在 applyChildComposition 里、composeFrom 之后调 childCtx.tools.presentAs('ptc')。modeFor 就近优先,子代理自己 scope 的声明会盖过父 preset standing scope 的(standard 没有声明,native 是默认值),父会话完全不受影响。
packages/subagent/tool-subagent/src/index.ts — Config schema 加同名字段并透传(provider: fork 那一行也能用 config 配死,不用暴露给模型)。
packages/subagent/subagent/src/continuation.ts(约 1232 行) — 同一 seam 的第二处调用点。标准 preset 里 subagent_fork 是 backgroundMode: continuable,续跑时走 continuation manager,也要同步穿这个字段,否则续跑的子代理会掉回 native。
不需要动 modeFor/presentAs/agent-presets 本身——机制和测试("一个 agent PTC、旁边 native")都已经证明是通的。
希望DSH官方可以支持...这样就不用自己改源码了
All reactions