fix(subagent): preserve published run failures

This commit is contained in:
Dudu-0223
2026-07-31 14:02:03 +08:00
committed by Tianyi Cui
parent 8b0a7a5d8d
commit a977ef30ee
57 changed files with 444 additions and 208 deletions

View File

@@ -43,9 +43,15 @@ function text(result: { content: { type: string; text?: string }[] }): string {
}
let calls = 0
function callTool(ctx: Context, name: string, args: unknown, agent?: unknown) {
function callTool(
ctx: Context,
name: string,
args: unknown,
agent?: unknown,
signal: AbortSignal = testToolSignal,
) {
return ctx.tools.execute({
signal: testToolSignal,
signal,
callId: CallId(`call-${++calls}`),
name,
arguments: args,
@@ -123,6 +129,17 @@ describe('dsh-tool-subagent-control/list-agents', () => {
)
})
it('forwards the tool cancellation signal to child enumeration', async () => {
const { ctx, parent } = await setup([])
const signal = new AbortController().signal
const listChildren = vi.spyOn(ctx.subagents, 'listChildren').mockResolvedValue([])
const result = await callTool(ctx, 'list_agents', {}, parent, signal)
expect(result.isError).toBe(false)
expect(listChildren).toHaveBeenCalledWith(parent.id, signal)
})
it('lists a real settled continuable child and omits a real one-shot sibling', async () => {
const { ctx, parent } = await setup([textResponse('once'), textResponse('done')])
const oneShot = await ctx.subagents.start('spawn', {