fix(core): handle inherited-key message identifiers
What is the current behavior?
In-memory message storage uses plain objects as user and conversation dictionaries. String identifiers such as constructor, toString and __proto__ resolve to inherited object properties instead of message buckets. Reading an empty conversation can throw messages.sort is not a function, and inherited user buckets can bypass the expected isolation and statistics.
What is the new behavior?
Use dictionaries without prototypes at both levels, including the empty-read fallback and resets after clearing messages or storage. Reserved-looking strings behave like other identifiers. Parameterized tests cover empty reads, per-user isolation, adding/deleting messages, conversation clearing, user clearing and complete storage resets.
Validation
- All six regressions fail on the base revision through the public storage API.
- All 155 memory tests, including 34 type tests, pass with the fix.
- Core TypeScript checking and CJS/ESM/declaration builds pass.
- Core Biome checks pass with five existing complexity warnings.
- Validation uses the repository's locked core/internal/logger dependencies; the entire monorepo build was not run.
PR Checklist
- Conventional commit message
- Regression tests added
- Patch changeset added
- Related issues: independently reproduced bug.
- Documentation: no API changes; ordinary string identifiers now work consistently.
Summary by cubic
Fixes @voltagent/core in-memory message storage so user and conversation identifiers like constructor, toString, and __proto__ are treated as ordinary strings. Previously these identifiers resolved to inherited object properties, causing messages.sort is not a function errors on empty reads and letting inherited buckets bypass per-user isolation and statistics.
Bug Fixes
- Replaces plain object dictionaries with prototype-less objects at every level, including the empty-read fallback and resets after clearing messages or storage.
- Adds parameterized regression tests covering empty reads, per-user isolation, message CRUD, and clearing scenarios for these identifiers used as both user and conversation identifiers.
Summary by CodeRabbit
- Bug Fixes
- In-memory message storage now reliably supports identifiers such as
constructor,toString, and__proto__, including after user-specific or full storage clears. - Message retrieval, CRUD operations, statistics, and user isolation work with these identifiers.
- In-memory message storage now reliably supports identifiers such as