agent-loop-testkit.spec.ts 1.1 KB

12345678910111213141516171819202122232425262728
  1. import { describe, expect, it } from 'vitest'
  2. import { Context } from '@deepseek-ai/cordis'
  3. import AgentLoop from '@deepseek-ai/dsh-agent-loop'
  4. import { renderPrompt } from '@deepseek-ai/dsh-system-prompt'
  5. import { unsupportedInbox, mountAgentLoopTestDependencies } from '../src/index.ts'
  6. describe('dsh-agent-loop-testkit', () => {
  7. it('rejects mutations through an unsupported Agent stub Inbox', () => {
  8. const inbox = unsupportedInbox()
  9. expect(inbox.nextTurn).toEqual([])
  10. expect(inbox.nextStep).toEqual([])
  11. expect(() => { inbox.clear() }).toThrow('this test Agent does not support Inbox mutations')
  12. })
  13. it('mounts a configurable prerequisite spine that can activate AgentLoop', async () => {
  14. const ctx = new Context()
  15. await mountAgentLoopTestDependencies(ctx, {
  16. systemPrompt: { persona: 'Test persona.' },
  17. tools: { mode: 'native' },
  18. })
  19. expect(renderPrompt(await ctx.systemPrompt.assemble())).toContain('Test persona.')
  20. await expect(ctx.plugin(AgentLoop, { agents: [] })).resolves.toBeDefined()
  21. await ctx.fiber.dispose()
  22. })
  23. })