Cover next-step report delivery in subagent runtime
This commit is contained in:
1 parent
d91df8cbd5
commit
20cd777753
1 file changed
+36
@@ -1524,6 +1524,42 @@ function settlementNotices(agent: Agent): { sender: string; text: string; summar
|
||||
})
|
||||
}
|
||||
|
||||
describe('continuable report delivery', () => {
|
||||
it('wakes an idle parent for a next-step report', async () => {
|
||||
const releaseChild = Promise.withResolvers<undefined>()
|
||||
const adapter = new GatedAdapter([
|
||||
{ chunks: textResponse('child answer'), gate: releaseChild.promise },
|
||||
{ chunks: textResponse('parent report ack') },
|
||||
{ chunks: textResponse('parent settlement ack') },
|
||||
])
|
||||
const { ctx, parent } = await setupWith(adapter)
|
||||
const started = await ctx.subagents.startContinuable(startSpec(parent))
|
||||
await vi.waitFor(() => {
|
||||
expect(adapter.requests.filter(request => request.sessionId === started.childId)).toHaveLength(1)
|
||||
})
|
||||
const child = ctx.agents.get(started.childId)
|
||||
expect(child).toBeDefined()
|
||||
|
||||
const messageId = await ctx.subagents.reportFrom(child!, message('an explicit report'), {
|
||||
delivery: 'next-step',
|
||||
signal: testSignal,
|
||||
})
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(adapter.requests.filter(request => request.sessionId === parent.id)).toHaveLength(1)
|
||||
})
|
||||
const report = parent.session.events.flatMap(event => event.type === 'user/message'
|
||||
&& event.data.source.kind === 'subagent-report' ? [event.data] : [])[0]
|
||||
expect(report?.id).toBe(messageId)
|
||||
|
||||
releaseChild.resolve(undefined)
|
||||
await waitNoActivation(ctx, started.childId)
|
||||
await vi.waitFor(() => {
|
||||
expect(adapter.requests.filter(request => request.sessionId === parent.id)).toHaveLength(2)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('continuable settlement delivery', () => {
|
||||
it('tells the parent what the child finished with, without being asked', async () => {
|
||||
const { ctx, parent } = await setup([textResponse('the answer'), textResponse('parent ack')])
|
||||
|
||||
Reference in new issue
Block a user