fix(subagent): confirm steering request admission

This commit is contained in:
Dudu-0223
2026-07-24 14:32:19 +08:00
committed by imccyu
parent 189502e4ac
commit e1f7eeeb95
58 changed files with 565 additions and 480 deletions
@@ -235,7 +235,7 @@ describe('dsh-subagent-spawn', () => {
expect(result.stopReason).toBe('aborted')
})
it('exposes strict steer (no run-level resume): a settled child throws instead of queueing', async () => {
it('exposes confirmed steer (no run-level resume): a settled child rejects instead of queueing', async () => {
const { ctx, parent } = await setup([textResponse('x')])
const run = await start(ctx, 'spawn', { prompt: [{ type: 'text', text: 'p' }], parent })
// A run represents one disposable activation: cold resume is a provider
@@ -243,11 +243,11 @@ describe('dsh-subagent-spawn', () => {
expect('resume' in run).toBe(false)
expect(typeof run.steer).toBe('function')
await run.result
// Strict live-only contract: after the child settles, delivery fails loud
// Confirmed live-only contract: after the child settles, delivery fails loud
// rather than falling back to Agent.steer()'s idle queue (which would
// start an untracked turn).
expect(() => { run.steer!([{ type: 'text', text: 'late' }], { kind: 'user' }) })
.toThrow(/not running; the message was not delivered/)
await expect(run.steer!([{ type: 'text', text: 'late' }], { kind: 'user' }))
.rejects.toThrow(/not running; the message was not delivered/)
await run.dispose()
})