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

View File

@@ -38,13 +38,10 @@ function stubAgentForSession(session: Session): StubAgent {
inbox,
ctx: new Context(),
status: 'idle',
acceptsNextStep: false,
send: () => {},
updateInbox: () => 'not-found',
followup: () => {},
steer: () => {},
inject(input) { inbox.append('next-step', input) },
reserveTurnAdmission: () => undefined,
cancel() {},
whenIdle() { return Promise.resolve() },
}
@@ -76,7 +73,7 @@ function appendRound(session: Session, ref: GoalRef, round: number): void {
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: `round ${round}` }], source,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
}
describe('GoalService creation and replay', () => {
@@ -584,7 +581,7 @@ describe('goal replay validation', () => {
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'ordinary' }], source,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
expect(foldGoal(session.events)).toEqual({ roundsStarted: 0 })
})
@@ -726,7 +723,7 @@ describe('goal replay validation', () => {
session.append('user/message', createUserMessage({
content: [{ type: 'text', text: 'missing' }], source,
}), { surfaceOp: 'append' })
session.append('turn/end', { turn, reason: { kind: 'completed' } })
session.append('turn/end', { turn, step: 0, reason: { kind: 'completed' } })
expect(() => foldGoal(session.events)).toThrow('goal message source is invalid')
})

View File

@@ -45,7 +45,6 @@ function liveAgent(ctx: Context, session: Session): Agent {
inject(input: UserMessage) {
inbox.append('next-step', input)
},
reserveTurnAdmission: () => undefined,
cancel() {},
whenIdle() { return Promise.resolve() },
}