refactor(agent): return request retry action

This commit is contained in:
_Kerman
2026-07-27 21:17:49 +08:00
parent c6073f07c2
commit ed67ad53d2
83 changed files with 277 additions and 309 deletions

View File

@@ -136,10 +136,10 @@ describe('plan mode through the agent loop', () => {
const adapter = new MockAdapter([failedRequest, textResponse('Recovered in plan mode.')])
const ctx = await harness(adapter)
const agent = ctx.agentLoop.create(SessionId('it-plan-retry-flip'), { provider: 'mock', model: 'mock' })
ctx.on('agent/settled', (subject, _turn, reason) => {
if (subject !== agent || reason.kind !== 'error') return
ctx.on('agent/request-error', async (subject, _turn, _step, _error, _failure, _signal, next) => {
if (subject !== agent) return next()
ctx.planMode.set(agent, true)
agent.retry()
return { kind: 'retry' }
})
const idle = waitForIdle(ctx, agent)