mirror of
https://github.com/symfony/ai-platform.git
synced 2026-03-23 23:12:22 +01:00
- Added unique identifiers (UUIDv7) to all message types
- Each message now automatically gets a unique ID upon instantiation
- Added comprehensive tests for the new ID functionality
This is a breaking change as `MessageInterface` now requires the
`getId(): Uuid` method to be implemented by all message classes.
- Added `symfony/uid` package dependency (^6.4 || ^7.1)
- Added `public readonly Uuid $id` property to all message classes
- IDs are generated automatically in constructors using `Uuid::v7()`
- Added `getId()` method to all message implementations
UUID v7 offers significant advantages over other UUID versions:
- **Time-ordered**: Natural chronological sorting without additional
timestamp fields
- **Millisecond precision**: Captures creation time with high accuracy
- **Better database performance**: Sequential nature improves B-tree
index locality
- **Globally unique**: No coordination needed between distributed
systems
- **Extractable timestamp**: Creation time can be retrieved from the ID
itself
```php
$message = new UserMessage(new Text('Hello'));
$timestamp = $message->getId()->getDateTime(); // Returns \DateTimeImmutable
echo $timestamp->format('Y-m-d H:i:s.u'); // e.g., "2025-06-29 23:45:12.123456"
```
Added tests for each message type to ensure:
- ID is properly generated and accessible
- ID remains consistent for the same message instance
- Different message instances have different IDs
- Messages with identical content still receive unique IDs
Closes #77
Closes #344
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>