diff --git a/packages/preset/agent-presets/src/index.ts b/packages/preset/agent-presets/src/index.ts index 809f370b35..160e34cfa8 100644 --- a/packages/preset/agent-presets/src/index.ts +++ b/packages/preset/agent-presets/src/index.ts @@ -715,10 +715,8 @@ export class AgentPresets extends TypertRemoteService { // model-loop execution; standalone plugin events never open one, so a // session that has only run commands is still blank. const boundary = this.selfCtx.sessionProjections.stateOf(agent.session, 'turnBoundary') - if (boundary === undefined) { - throw new Error('agent-presets: select requires the turnBoundary session projection') - } - if (boundary.openTurnStartSeq !== null || boundary.lastTurn > 0) { + if (boundary !== undefined + && (boundary.openTurnStartSeq !== null || boundary.lastTurn > 0)) { throw new PresetLockedError(agent.id, agentPreset) } const preset = await this.recompose(agent.ctx, agentPreset) diff --git a/packages/preset/agent-presets/tests/remote.spec.ts b/packages/preset/agent-presets/tests/remote.spec.ts index 5837cf2b6a..b7ece833cc 100644 --- a/packages/preset/agent-presets/tests/remote.spec.ts +++ b/packages/preset/agent-presets/tests/remote.spec.ts @@ -366,7 +366,7 @@ describe('switching one session\'s composition', () => { expect(recordedPreset(agent)).toEqual({ agentPreset: 'minimal' }) }) - it('fails loudly when a composition omits the turn boundary projection', async () => { + it('treats an absent turn boundary as no prior turn', async () => { const ctx = await harness() const agent = await agentOn(ctx, 'sel-no-turn-boundary', 'standard') const stateOf = ctx.sessionProjections.stateOf.bind(ctx.sessionProjections) @@ -374,12 +374,7 @@ describe('switching one session\'s composition', () => { key === 'turnBoundary' ? undefined : stateOf(session, key) )) - const failure = await remoteFailure(ctx.agentPresets.select(agent, 'minimal')) - - expect(failure).toMatchObject({ - code: 'internal', - message: expect.stringContaining('select requires the turnBoundary session projection') as string, - }) + expect(await ctx.agentPresets.select(agent, 'minimal')).toBe('minimal') }) it('serializes two concurrent switches on one session', async () => {