refactor(subagent): narrow continuation interface

This commit is contained in:
Tianyi Cui
2026-07-28 00:10:24 +08:00
committed by imccyu
parent 644bf00b86
commit f14121a4c2
55 changed files with 669 additions and 441 deletions

View File

@@ -398,7 +398,9 @@ export class BasicCompactService extends CompactService {
{
owner: null,
stability: 'selected-span',
flush: () => this.ctx.sessions.flush(agent.session),
flush: async () => {
await this.ctx.sessions.flush(agent.session)
},
},
signal,
)

View File

@@ -217,7 +217,7 @@ function detachedService(): { ctx: Context; compact: GatedCompactService; flushe
let flushes = 0
vi.spyOn(ctx.sessions, 'flush').mockImplementation(() => {
flushes += 1
return Promise.resolve()
return Promise.resolve(false)
})
return { ctx, compact: new GatedCompactService(ctx, { auto: false }), flushes: () => flushes }
}
@@ -730,7 +730,7 @@ describe('compactNow transaction and failure classification', () => {
const { ctx, compact } = detachedService()
const controller = new AbortController()
const reason = new Error('cancelled during flush')
const flushGate = Promise.withResolvers<undefined>()
const flushGate = Promise.withResolvers<boolean>()
const flush = vi.spyOn(ctx.sessions, 'flush').mockReturnValueOnce(flushGate.promise)
const session = closedConversation(2)
let released = 0
@@ -750,7 +750,7 @@ describe('compactNow transaction and failure classification', () => {
expect(settled).toBe(false)
expect(released).toBe(0)
flushGate.resolve(undefined)
flushGate.resolve(false)
await expect(running).rejects.toBe(reason)
expect(released).toBe(1)
})