refactor(agent): complete inbox lifecycle migration
This commit is contained in:
214 files changed
+6019
-4235
No files matched your search
@@ -190,6 +190,7 @@ export class ReactLoopAgent implements Agent {
|
||||
} catch (_error) {
|
||||
// Reported failures and cancellation are contained at the driver boundary.
|
||||
} finally {
|
||||
/* v8 ignore next -- kick owns a running phase until this driver boundary */
|
||||
if (this.phase.kind === 'running') {
|
||||
this.setPhase({ kind: 'idle', lastTurn: this.phase.turn })
|
||||
}
|
||||
@@ -197,6 +198,7 @@ export class ReactLoopAgent implements Agent {
|
||||
}
|
||||
|
||||
private async preStep(target: InboxTarget, position: { turn: number; step: number }): Promise<PreparedStep> {
|
||||
/* v8 ignore next -- private callers establish the running phase before proposing a step */
|
||||
if (this.phase.kind !== 'running') throw new Error(`agent "${this.id}": pre-step outside running phase`)
|
||||
const signal = this.phase.abort.signal
|
||||
const claimed = this.inbox.claim(target)
|
||||
@@ -294,6 +296,7 @@ export class ReactLoopAgent implements Agent {
|
||||
}
|
||||
|
||||
private async step(assembly: PromptAssembly): Promise<StepEndReason | null> {
|
||||
/* v8 ignore next -- private callers establish the running phase before executing a step */
|
||||
if (this.phase.kind !== 'running') throw new Error(`agent "${this.id}": step outside running phase`)
|
||||
const { turn, step, abort: { signal } } = this.phase
|
||||
signal.throwIfAborted()
|
||||
|
||||
Reference in New Issue
Block a user