fix(dsh): isSubagent — origin===subagent вместо parentSession (форки не сабагенты) (T2.3, #43)
This commit is contained in:
parent
1d35a3be2c
commit
622dd32e1a
@ -75,7 +75,7 @@ export function resolveRolesDir(bundleDir, configured, home = homedir()) {
|
|||||||
function isSubagent(agent) {
|
function isSubagent(agent) {
|
||||||
return Boolean(
|
return Boolean(
|
||||||
agent?.session?.header?.delegationDepth > 0 ||
|
agent?.session?.header?.delegationDepth > 0 ||
|
||||||
agent?.session?.header?.parentSession != null ||
|
agent?.session?.header?.origin === 'subagent' ||
|
||||||
agent?.options?.subagentDepth > 0,
|
agent?.options?.subagentDepth > 0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -383,13 +383,13 @@ test('apply: bootstrap:false leaves harness-check wired (the gate is ctx.on, not
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent shapes that the runtime uses for a delegated step. The old
|
* Agent shapes that the runtime uses for a delegated step: the session header
|
||||||
* parent/parentAgent/parentSessionId/depth checks were dead; these three are
|
* carries `origin: 'subagent'` (or a positive delegationDepth / subagentDepth
|
||||||
* the live ones.
|
* as a robust fallback).
|
||||||
*/
|
*/
|
||||||
const SUBAGENT_AGENTS = [
|
const SUBAGENT_AGENTS = [
|
||||||
{ session: { header: { delegationDepth: 1 } } },
|
{ session: { header: { delegationDepth: 1 } } },
|
||||||
{ session: { header: { parentSession: 's0' } } },
|
{ session: { header: { origin: 'subagent', parentSession: 's0' } } },
|
||||||
{ options: { subagentDepth: 1 } },
|
{ options: { subagentDepth: 1 } },
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -430,3 +430,23 @@ test('apply: a plain pre-step still injects bootstrap, harness-check, and role-h
|
|||||||
cleanup(skill)
|
cleanup(skill)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('apply: a forked session (parentSession without origin) still injects all three', async () => {
|
||||||
|
const repo = nonAdoptedRepo()
|
||||||
|
const skill = tempDir('dsh-harness-skill-')
|
||||||
|
try {
|
||||||
|
write(join(skill, 'SKILL.md'), '---\nname: using-superpowers\n---\nbody\n')
|
||||||
|
const harness = prestepHarness({ bootstrapSkillPath: join(skill, 'SKILL.md') }, repo)
|
||||||
|
const forkAgent = { session: { header: { parentSession: 's0', isSeeded: true } } }
|
||||||
|
const decision = await harness.run({ agent: forkAgent, messages: [userMessage('Напиши тест')] })
|
||||||
|
|
||||||
|
assert.equal(decision.messages.length, 4, 'forks are not subagents: all three injections expected')
|
||||||
|
const texts = decision.messages.map(messageText)
|
||||||
|
assert.ok(texts.some((text) => text.includes('DSH-HARNESS-BOOTSTRAP')), 'bootstrap injected')
|
||||||
|
assert.ok(texts.some((text) => text.includes('не подключён к обвязке')), 'harness-check injected')
|
||||||
|
assert.ok(texts.some((text) => text.includes('Роль сессии: dev')), 'role-hint injected')
|
||||||
|
} finally {
|
||||||
|
cleanup(repo)
|
||||||
|
cleanup(skill)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user