fix(agent-loop): open turns before pre-step

This commit is contained in:
_Kerman
2026-08-04 13:49:35 +08:00
parent 0ac95437b4
commit d4fa26023d
154 changed files with 1104 additions and 1099 deletions
+3 -3
View File
@@ -252,12 +252,12 @@ describe('ACP prompt lifecycle', () => {
}))
const sessionId = await newSession(harness)
await expect(harness.client.prompt({ sessionId, prompt: [{ type: 'text', text: 'go' }] }))
.resolves.toEqual({ stopReason: 'cancelled' })
// The rejected prompt opened no turn and streamed nothing.
.resolves.toEqual({ stopReason: 'end_turn' })
// The rejected prompt closed a blocked turn without streaming anything.
expect(messageText(harness)).toBe('')
})
it('settles a prompt when pre-step fails before opening a turn', async () => {
it('rejects a prompt when pre-step fails inside its open turn', async () => {
harness = await makeBridgeHarness({ script: [] })
harness.ctx.on('agent/pre-step', async () => { throw new Error('pre-step exploded') })
const sessionId = await newSession(harness)