Back to Mastra

RAG | v1 Migration Guide

docs/src/content/en/guides/migrations/upgrade-to-v1/rag.mdx

2025-12-181.2 KB
Original Source

RAG

The RAG package has renamed chunking parameters and narrowed their types.

Changed

keepSeparator to separatorPosition

The keepSeparator parameter has been renamed to separatorPosition with a simplified type. The old parameter had a confusing boolean | 'start' | 'end' type where true was secretly an alias for 'start'. The new parameter uses explicit 'start' | 'end' values, and omitting the parameter discards the separator.

To migrate, replace keepSeparator with separatorPosition using the mapping below:

Old valueNew value
keepSeparator: trueseparatorPosition: 'start'
keepSeparator: 'start'separatorPosition: 'start'
keepSeparator: 'end'separatorPosition: 'end'
keepSeparator: falseRemove the parameter
Parameter omittedNo change needed
diff
  await doc.chunk({
    strategy: 'character',
    separator: '.',
-   keepSeparator: true,
+   separatorPosition: 'start',
  });

  await doc.chunk({
    strategy: 'character',
    separator: '.',
-   keepSeparator: 'end',
+   separatorPosition: 'end',
  });

  await doc.chunk({
    strategy: 'character',
    separator: '.',
-   keepSeparator: false,
+   // Parameter removed - separator is discarded by default
  });