← All work

Testing · mastra-ai/mastra

Test durable agent state serialization contracts

Adds a Vitest suite for ten pure helpers that serialize agent state for durable workflow execution. Coverage includes error handling, date round-trips, model filtering, tool selection normalization, and tool metadata.

The problem

The serialization utilities lacked unit coverage despite being called when durable agent workflows are created or resumed. Their contracts include preserving error names, excluding disabled fallback models, and normalizing tool selection instructions for resumed workflows.

The approach

Introduces a single test file exercising pure functions without I/O, asynchronous behavior, or mocks. Tests cover error instances and non-error values, optional fields, date conversion, model and scorer configuration, durable state and options, and tool metadata. Assertions check both retained values and omitted information, including exclusion of model settings.

What changed

Adds explicit checks for serialization behavior and edge cases across ten helpers, with no production behavior changes or new dependencies.

  • typescript
  • vitest
  • unit-tests
  • serialization
  • durable-workflows
  • agents