refactor(agent): simplify inbox-driven turn admission

This commit is contained in:
_Kerman
2026-08-02 00:27:37 +08:00
parent d38c8bfaf3
commit dbdf270af0
104 changed files with 550 additions and 511 deletions
@@ -42,14 +42,11 @@ function sessionAgent(session: Session, id = 'agent'): Agent {
session,
inbox: new Inbox(session, { inserted: () => {}, discarded: () => {} }),
status: 'running',
acceptsNextStep: true,
ctx: new Context(),
send: () => {},
followup: () => {},
steer: () => {},
inject: () => { throw new Error('time-context must append directly to the open step') },
updateInbox: () => 'not-found',
reserveTurnAdmission: () => undefined,
cancel() {},
whenIdle: () => Promise.resolve(),
}
@@ -250,7 +247,7 @@ describe('durable step context', () => {
surfaceOp: { op: 'replace', start: user.seq, end: reading.seq },
sourceEventSeqs: [user.seq, reading.seq],
})
original.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
original.append('turn/end', { turn: 1, step: 0, reason: { kind: 'completed' } })
expect(JSON.stringify(original.deriveMessages())).not.toContain('Time sampled while preparing')
const resumed = new Session(SessionId('resumed'), [...original.events])
@@ -279,7 +276,7 @@ describe('durable step context', () => {
const firstAgent = sessionAgent(first, 'first-agent')
openMessageTurn(first, 1)
await fire(ctx, firstAgent, 1, 1)
first.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
first.append('turn/end', { turn: 1, step: 0, reason: { kind: 'completed' } })
vi.setSystemTime(BASE + 500)
openMessageTurn(first, 2)