refactor agent pre-step inbox lifecycle

This commit is contained in:
_Kerman
2026-07-31 19:21:16 +08:00
parent c2ff9ddec8
commit fcc2b5e282
267 changed files with 2052 additions and 1546 deletions
@@ -220,13 +220,17 @@ describe('session-checkpoint-policy tool and step boundaries', () => {
expect(flushes).toBe(0)
})
it('checkpoints before the next agent step', async () => {
it('checkpoints during pre-step processing', async () => {
const ctx = await setup()
const session = ctx.sessions.create(SessionId('post-step'))
const agent = { session } as Agent
const flushed: string[] = []
ctx.on('session/flush', (current) => { flushed.push(current.id) })
await agentEvents(ctx, agent).serial('agent/step', 1, 1, new AbortController().signal)
const signal = new AbortController().signal
await agentEvents(ctx, agent).waterfall(
'agent/pre-step', [], { turn: 1, step: 1, signal },
() => Promise.resolve({ kind: 'enter', messages: [] }),
)
expect(flushed).toEqual([session.id])
})
})