Kaynağa Gözat

test(ptc): strengthen literal prompt assertions

_Kerman 3 hafta önce
ebeveyn
işleme
e1f0911618

+ 7 - 2
packages/core/system-prompt/tests/system-prompt.spec.ts

@@ -579,13 +579,18 @@ describe('SystemPrompt', () => {
       expect(renderPrompt(await ctx.systemPrompt.assemble())).toBe(`${IDENTITY}\n\nYou run on deepseek-v4 in /work.`)
     })
 
-    it.each([false, true])('preserves literal section text with complete=%s', async (complete) => {
+    it.each([
+      [false, false],
+      [false, true],
+      [true, false],
+      [true, true],
+    ])('preserves literal section text with complete=%s and dynamic=%s', async (complete, dynamic) => {
       const ctx = new Context()
       try {
         await ctx.plugin(SystemPrompt, { includeHarnessIdentity: false, personaPrefix: '{{model}}' })
         ctx.systemPrompt.variable('model', () => 'actual-model')
         const text = '{{item}} {{model}} {{ model }} {{nested{{item}}}}'
-        ctx.systemPrompt.section({ name: 'literal', order: 1, text: () => text, interpolate: false, complete })
+        ctx.systemPrompt.section({ name: 'literal', order: 1, text: dynamic ? () => text : text, interpolate: false, complete })
         expect(renderPrompt(await ctx.systemPrompt.assemble()))
           .toBe(complete ? text : `actual-model\n\n${text}`)
       } finally {

+ 3 - 1
packages/core/tools/tests/ptc.spec.ts

@@ -138,9 +138,11 @@ describe('mode-aware wire contribution', () => {
         execute: args => Promise.resolve(args.value),
       }))
       const assembly = await systemPrompt.assemble()
+      const sdk = assembly.sections.find(section => section.name === 'tools:sdk')
+      expect(sdk).toBeDefined()
       const prompt = renderPrompt(assembly)
       expect(prompt).toContain(description)
-      expect(prompt).toContain(assembly.sections.find(section => section.name === 'tools:sdk')?.text)
+      expect(prompt).toContain(sdk!.text)
       expect(prompt).not.toContain('actual-model')
     } finally {
       await ctx.fiber.dispose()