Skip to content

Feat/checkpoint#33

Open
gyash1512 wants to merge 6 commits into
mainfrom
feat/checkpoint
Open

Feat/checkpoint#33
gyash1512 wants to merge 6 commits into
mainfrom
feat/checkpoint

Conversation

@gyash1512
Copy link
Copy Markdown
Contributor

This pull request introduces robust support for message IDs throughout the conversation engine and memory providers, ensuring all messages (user, assistant, and tool) are consistently assigned unique identifiers. It also adds a checkpoint restoration feature to the in-memory memory provider, allowing conversations to be reverted to a specific user message using various criteria. Additionally, a demo server is provided to showcase the checkpoint functionality with helpful usage instructions.

Comment thread src/core/types.ts Outdated

export const generateMessageId = (): MessageId => {
// Simple, deterministic-safe generator without external deps
const rand = Math.random().toString(36).slice(2, 10);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math.random() is not crypto-strong. Use crypto.randomUUID()

Comment thread src/server/server.ts Outdated
schema: {
body: {
type: 'object',
properties: {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the endpoint accepts multiple selectors simultaneously. enforce exactly one selector or log which was applied

Use oneOf in the schema to ensure a single selector.

const updatedConversation: ConversationMemory = {
...conversation,
messages: newMessages,
metadata: {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata merge can overwrite fresh fields. You spread old metadata after setting updatedAt/lastActivity/totalMessages. Swap the order to preserve new values.

metadata: {
...(conversation.metadata ? { ...conversation.metadata } : {}),
createdAt: conversation.metadata?.createdAt ?? now,
updatedAt: now,
lastActivity: now,
totalMessages: newMessages.length
}

Comment thread src/memory/types.ts Outdated
gyash1512 and others added 3 commits September 26, 2025 14:51
Co-authored-by: Anurag Sharan <34830688+sharananurag998@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants