refactor(agent): trim obsolete loop surfaces

This commit is contained in:
_Kerman
2026-07-24 21:58:07 +08:00
parent 194b18a32f
commit 009d113e0e
40 changed files with 252 additions and 288 deletions

View File

@@ -140,13 +140,9 @@ describe('config-driven session id', () => {
first.inject([{ type: 'text', text: 'persist before replacement' }], {
source: { kind: 'plugin', plugin: 'test' },
})
await expect.poll(async () => {
try {
return JSON.stringify((await ctx.sessionPersistence.inspect(sessionId)).events)
} catch {
return ''
}
}).toContain('persist before replacement')
await ctx.sessions.flush(first.session)
expect(JSON.stringify((await ctx.sessionPersistence.inspect(sessionId)).events))
.toContain('persist before replacement')
const firstDisposal = firstLoop.dispose()
await cleanupStarted.promise
@@ -190,13 +186,9 @@ describe('config-driven session id', () => {
first.inject([{ type: 'text', text: 'persist before cancellation' }], {
source: { kind: 'plugin', plugin: 'test' },
})
await expect.poll(async () => {
try {
return JSON.stringify((await ctx.sessionPersistence.inspect(sessionId)).events)
} catch {
return ''
}
}).toContain('persist before cancellation')
await ctx.sessions.flush(first.session)
expect(JSON.stringify((await ctx.sessionPersistence.inspect(sessionId)).events))
.toContain('persist before cancellation')
const firstDisposal = firstLoop.dispose()
await cleanupStarted.promise

View File

@@ -436,7 +436,7 @@ describe('disposal leaves the two-state status contract balanced', () => {
await fiber.dispose()
await driverDone(agent) // must not hang
await expect.poll(() => ctx.agents.get(SessionId('scoped')) === undefined).toBe(true)
expect(ctx.agents.get(SessionId('scoped'))).toBeUndefined()
})
})

View File

@@ -161,7 +161,6 @@ describe('agent/prompt-submit', () => {
expect(log.some(e => e.type === 'turn/end')).toBe(false)
expect(log.some(e => e.type === 'user/message')).toBe(false)
expect(log.some(e => e.type === 'step/start')).toBe(false)
expect(log.some(e => e.type === 'prompt/blocked')).toBe(false)
expect(reasons).toEqual([])
})
@@ -189,7 +188,6 @@ describe('agent/prompt-submit', () => {
expect(userMsgs).toHaveLength(1)
expect(userMsgs[0]?.type === 'user/message' && userMsgs[0].data.content).toEqual([{ type: 'text', text: 'safe' }])
expect(adapter.requests.length).toBeGreaterThanOrEqual(1)
expect(log.filter(e => e.type === 'prompt/blocked')).toHaveLength(0)
expect(log.filter(e => e.type === 'turn/start')).toHaveLength(1)
expect(reasons).toEqual([{ kind: 'completed' }])
})

View File

@@ -1041,7 +1041,7 @@ describe('agent loop', () => {
await fiber.dispose()
await driverDone(agent)
await expect.poll(() => ctx.agents.get(SessionId('scoped')) === undefined).toBe(true)
expect(ctx.agents.get(SessionId('scoped'))).toBeUndefined()
})
it('creates agents from config on startup', async () => {