From 4eebc70df29acfe1bc194c5a94c22cf8cb8def2a Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 7 Sep 2026 23:29:49 +0800 Subject: [PATCH] test(agent-loop): account for route switch notice during prompt admission The plain-to-capable transition emits the model-selection notice inherited from master. Preserve the exact in-history system ordering and assert both the admitted user input and the single durable notice instead of expecting the obsolete five-message request. Reproduces the identical Linux and Windows CI failure; all 57 adjacent admission, projection, reconstruction and selection tests pass. --- .../tests/system-prompt-admission.spec.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/core/agent-loop/tests/system-prompt-admission.spec.ts b/packages/core/agent-loop/tests/system-prompt-admission.spec.ts index 716d0e2156..3a7bfa09ba 100644 --- a/packages/core/agent-loop/tests/system-prompt-admission.spec.ts +++ b/packages/core/agent-loop/tests/system-prompt-admission.spec.ts @@ -205,7 +205,22 @@ describe('prepared-route prompt admission', () => { expect(systemTexts(h.capable.requests[0]!)).toEqual([ [{ type: 'text', text: 'prompt one' }], [{ type: 'text', text: 'prompt two' }], ]) - expect(h.capable.requests[0]!.messages.map(message => message.role)).toEqual(['system', 'user', 'assistant', 'system', 'user']) + const messages = h.capable.requests[0]!.messages + expect(messages.map(message => message.role)).toEqual(['system', 'user', 'assistant', 'system', 'user', 'user']) + const notice = [{ + type: 'text', + text: '[model changed: assistant turns above this point were generated by plain/model; the session continues with capable/model]', + }] + expect(messages.slice(-2).map(message => message.content)).toEqual([ + [{ type: 'text', text: 'second' }], notice, + ]) + const notices = h.agent.session.snapshotEvents().filter(event => event.type === 'user/message' + && event.data.source.kind === 'plugin' && event.data.source.plugin === 'model-selection') + expect(notices).toHaveLength(1) + expect(notices[0]!.data).toMatchObject({ + content: notice, + source: { kind: 'plugin', plugin: 'model-selection', form: 'notice', summary: 'plain/model → capable/model' }, + }) }) it.each([false, true])('resumes capable history with first pre-step replacement=%s', async (replace) => {