Просмотр исходного кода

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.
Tianyi Cui 2 недель назад
Родитель
Сommit
4eebc70df2
1 измененных файлов с 16 добавлено и 1 удалено
  1. 16 1
      packages/core/agent-loop/tests/system-prompt-admission.spec.ts

+ 16 - 1
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) => {