Skip to content

feat(mongodb): implement complete MongoDB memory adapter#1000

Open
UmeshpJadhav wants to merge 9 commits intoVoltAgent:mainfrom
UmeshpJadhav:feat/mongodb-memory-storage
Open

feat(mongodb): implement complete MongoDB memory adapter#1000
UmeshpJadhav wants to merge 9 commits intoVoltAgent:mainfrom
UmeshpJadhav:feat/mongodb-memory-storage

Conversation

@UmeshpJadhav
Copy link
Contributor

@UmeshpJadhav UmeshpJadhav commented Jan 29, 2026

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

There is currently no built-in support for MongoDB as a persistent storage backend for agent memory. Users are limited to in-memory or Postgres adapters.

What is the new behavior?

This PR implements the @voltagent/mongodb package with a full MongoDBMemoryAdapter.

  • Implements the complete StorageAdapter interface.
  • Supports persistent storage for:
    • Messages (with role-based filtering)
    • Conversations (metadata, titles)
    • Workflow State (resumable workflows)
    • Working Memory (user and conversation scope)
  • Includes strict type safety for Date vs string fields to match Core interfaces.
  • Includes comprehensive integration tests using Docker.

fixes #505

Notes for reviewers

  • Integration Tests: The tests require a running MongoDB instance. I've included a docker-compose.test.yaml and vitest.integration.config.mts to make this easy (npm run test:integration).
  • Performance: Indexes are automatically created on initialization for userId, conversationId, and createdAt to ensure query performance.

Summary by cubic

Adds a new @voltagent/mongodb package with a complete MongoDBMemoryAdapter and a minimal example app to show usage. Addresses #505 by adding built-in MongoDB support with indexes and integration tests.

  • New Features

    • Full StorageAdapter: messages (batch/role filters, deleteMessages), conversations (CRUD/pagination/count), conversation steps, working memory (user/conversation), and workflow state (set/get/update/query, suspended runs).
    • Auto indexes (userId, conversationId, createdAt, unique messageId per conversation), strict Date/string typing, README, and Docker-based integration tests.
    • Minimal example app (examples/with-mongodb) with Hono server, .env setup, and usage of MongoDBMemoryAdapter.
  • Bug Fixes

    • Fixed race condition in createConversation to prevent duplicate insert conflicts.
    • Secured deleteMessages to scope deletions by user and conversation.

Written for commit ee9c1ff. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added a MongoDB memory storage adapter package and a runnable example wiring it into an agent/server.
  • Documentation

    • Added package README and example README with usage, config, and installation guidance.
  • Tests

    • Added comprehensive integration and unit tests, test configs, and a Docker Compose test setup.
  • Chores

    • Added package metadata, build/bundle/type configs, release changeset, example env and .gitignore.

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: ee9c1ff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/mongodb Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new MongoDB-backed memory storage package for VoltAgent: implementation, public exports, build/test configs, integration/unit tests, Docker Compose for integration testing, README, example, and a changeset announcing the initial release.

Changes

Cohort / File(s) Summary
Package metadata
packages/mongodb/package.json
New npm package manifest, scripts, dependencies (mongodb), exports for ESM/CJS, types, and publish configuration.
Implementation & public API
packages/mongodb/src/memory-adapter.ts, packages/mongodb/src/index.ts
New MongoDBMemoryAdapter and MongoDBMemoryOptions; connection lifecycle, index creation, conversations/messages CRUD, steps, working memory, workflow state APIs, validation, and exported types/classes.
Tests
packages/mongodb/src/index.integration.test.ts, packages/mongodb/src/memory-adapter.spec.ts
Comprehensive integration tests against real MongoDB and unit tests with mocked MongoClient covering lifecycle, CRUD, workflows, edge cases, and error conditions.
Build & TS configs
packages/mongodb/tsup.config.ts, packages/mongodb/tsconfig.json
TSup build configuration, strict TypeScript settings, declaration output to dist.
Test configs & Docker
packages/mongodb/vitest.config.mts, packages/mongodb/vitest.integration.config.mts, packages/mongodb/docker-compose.test.yaml
Vitest configs for unit and integration tests and Docker Compose to run a MongoDB service for integration testing.
Docs, example & release note
packages/mongodb/README.md, examples/with-mongodb/**, .changeset/mongodb-feature-storage.md
New README for the adapter, a runnable example project with env and README, and a changeset documenting the initial release.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Client
  participant Adapter as MongoDBMemoryAdapter
  participant DB as MongoDB

  Client->>Adapter: createConversation(input)
  Adapter->>DB: insert conversation document (collectionPrefix + conversations)
  DB-->>Adapter: inserted document ( _id, createdAt, updatedAt )
  Adapter-->>Client: return Conversation (id, createdAt, updatedAt)

  Client->>Adapter: addMessage(message, userId, conversationId)
  Adapter->>DB: find conversation by id
  alt conversation exists
    Adapter->>DB: insert message (collectionPrefix + messages), enforce unique messageId
    DB-->>Adapter: ack
    Adapter-->>Client: success
  else conversation missing
    Adapter-->>Client: ConversationNotFoundError
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through indexes and lined each row,
tucked messages in Mongo where memories grow.
I ran the tests, watched tiny pings and cheers,
example agents woke and shook their ears.
Now agents stash memories for many future years. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(mongodb): implement complete MongoDB memory adapter' clearly and concisely summarizes the main change—adding a complete MongoDB memory adapter implementation for the project.
Description check ✅ Passed The PR description is comprehensive and follows the template structure, including a complete checklist, clear explanations of current vs. new behavior, relevant issue links, test/doc/changeset confirmations, and detailed reviewer notes.
Linked Issues check ✅ Passed The PR fully addresses issue #505 by implementing a complete MongoDB memory adapter that satisfies the StorageAdapter interface with persistent storage for messages, conversations, workflow state, and working memory, along with strict type safety and operational considerations.
Out of Scope Changes check ✅ Passed All changes are directly in scope for issue #505, covering MongoDB adapter implementation, integration tests, documentation, examples, and configuration files needed for a complete MongoDB storage backend feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@packages/mongodb/README.md`:
- Around line 35-39: Replace the erroneous placeholder row "str | str | str |
str" that follows the header "Option | Type | Default | Description" with a
proper Markdown table separator row made of hyphens for each column separated by
pipes (i.e., a hyphen group under each header). Locate the header and the
placeholder row in packages/mongodb/README.md and update the second row so the
table renders correctly while keeping the existing header and subsequent rows
(like the `connection`, `database`, `collectionPrefix` lines) unchanged.

In `@packages/mongodb/src/memory-adapter.spec.ts`:
- Around line 570-608: In saveConversationSteps, the expression step.id ||
this.generateId() is evaluated twice when building the replaceOne operation
which can create mismatched _id values for records without step.id; fix by
computing a single id per step (e.g., const id = step.id || this.generateId())
before constructing the replacement object and use that id for both filter._id
and replacement._id so replaceOne.upsert uses a consistent identifier (refer to
saveConversationSteps, steps, generateId, getCollection, and stepsCollection to
locate the code).

In `@packages/mongodb/src/memory-adapter.ts`:
- Around line 571-609: In saveConversationSteps, the code calls step.id ||
this.generateId() twice which can yield different IDs for filter vs replacement;
for each step compute a single id (e.g., const id = step.id ??
this.generateId()) and use that id for both filter._id and replacement._id in
the operations array so the upsert targets the same document; update references
in the stepsCollection.bulkWrite payload to use that computed id.
- Around line 786-975: Remove the erroneous .toISOString() conversions so
createdAt and updatedAt are returned as Date objects to match
WorkflowStateEntry: in getWorkflowState replace createdAt: (state as
any).createdAt.toISOString() and updatedAt: (state as
any).updatedAt.toISOString() with the raw Date values, and in queryWorkflowRuns
replace createdAt: state.createdAt.toISOString() and updatedAt:
state.updatedAt.toISOString() with the Date values; keep
getSuspendedWorkflowStates as-is (it already returns Date objects).
🧹 Nitpick comments (5)
packages/mongodb/package.json (1)

49-52: Avoid fixed sleep for MongoDB readiness if possible.
A hard sleep 10 can be flaky on slower CI. Consider a readiness/healthcheck or docker compose --wait if supported.

♻️ Possible update (verify docker compose supports --wait)
-    "test:integration:setup": "docker compose -f docker-compose.test.yaml up -d && sleep 10",
+    "test:integration:setup": "docker compose -f docker-compose.test.yaml up -d --wait",
packages/mongodb/src/index.integration.test.ts (2)

388-492: Tighten workflow state fixtures typing.
any casts around Line 390/416/442/469 reduce compile-time coverage. Prefer WorkflowStateEntry-typed fixtures (or a typed helper builder) over as any.
As per coding guidelines: Maintain type safety in TypeScript-first codebase.


498-583: Use typed fixtures for conversation steps.
any[] and as any around Line 508/553 weaken type safety. Prefer ConversationStepRecord[] fixtures to keep tests aligned with adapter contracts.
As per coding guidelines: Maintain type safety in TypeScript-first codebase.

packages/mongodb/src/memory-adapter.ts (1)

195-350: Reduce any usage in message operations for stronger type safety.
filter: any and msg: any (Line 286 onward) weaken compile-time checks. Consider defining MongoDB document interfaces and using typed filters/collections to avoid as any.
As per coding guidelines: Maintain type safety in TypeScript-first codebase.

packages/mongodb/src/memory-adapter.spec.ts (1)

1-21: Avoid duplicating the adapter implementation in a .spec.ts.
Consider importing/re-exporting the adapter from packages/mongodb/src/memory-adapter.ts so fixes don’t have to be duplicated and drift doesn’t occur.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 13 files

@omeraplak
Copy link
Member

Hey @UmeshpJadhav , thanks a lot for the PR! 🙌
Did you get a chance to look into the build failure and the code review comments?

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 13 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/mongodb/src/memory-adapter.ts">

<violation number="1" location="packages/mongodb/src/memory-adapter.ts:381">
P2: createConversation uses a check-then-insert pattern without handling MongoDB duplicate key errors; concurrent creation can raise an E11000 error instead of ConversationAlreadyExistsError.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/mongodb/src/memory-adapter.spec.ts (1)

1-980: ⚠️ Potential issue | 🔴 Critical

Remove memory-adapter.spec.ts or replace with unit tests; integration tests are properly implemented in index.integration.test.ts.

The spec file (lines 1–980) is an exact duplicate of the implementation in memory-adapter.ts with only trivial formatting differences, containing no test code. Comprehensive integration tests already exist in index.integration.test.ts (651 lines) covering all major operations. The .spec.ts file should either be deleted or converted to unit tests. Per project conventions, test files should follow the **/*.test.ts pattern.

🧹 Nitpick comments (3)
packages/mongodb/src/memory-adapter.ts (3)

121-128: Initialization guard has a logical issue.

The check at lines 125-127 will never trigger because this.initPromise is assigned at line 87 before initialize() completes, and when initialize() is called again, this.initPromise will always be truthy. However, since initialize() is private and only called once from the constructor, this redundant check is benign but misleading.

The guard at line 122 (if (this.initialized) return) provides the actual protection after initialization completes.

♻️ Simplify the guard logic
   private async initialize(): Promise<void> {
     if (this.initialized) return;
 
-    // Prevent multiple simultaneous initializations
-    if (this.initPromise && !this.initialized) {
-      return this.initPromise;
-    }
-
     try {

556-564: Consider using a transaction for cascade delete.

The delete operation removes from three collections sequentially. If the process crashes between deletions, orphaned records may remain. While not critical for most use cases, a transaction would ensure atomicity.

♻️ Wrap in a transaction for atomicity
   async deleteConversation(id: string): Promise<void> {
     await this.initPromise;
 
     const conversationsCollection = this.getCollection("conversations");
-
-    // MongoDB will cascade delete messages and steps automatically via application logic
     const messagesCollection = this.getCollection("messages");
     const stepsCollection = this.getCollection("steps");
 
-    await messagesCollection.deleteMany({ conversationId: id } as any);
-    await stepsCollection.deleteMany({ conversationId: id } as any);
-    await conversationsCollection.deleteOne({ _id: id } as any);
+    const session = this.client.startSession();
+    try {
+      await session.withTransaction(async () => {
+        await messagesCollection.deleteMany({ conversationId: id } as any, { session });
+        await stepsCollection.deleteMany({ conversationId: id } as any, { session });
+        await conversationsCollection.deleteOne({ _id: id } as any, { session });
+      });
+    } finally {
+      await session.endSession();
+    }
 
     this.log(`Deleted conversation ${id}`);
   }

102-106: Consider using a more robust ID generation method.

Math.random() is not cryptographically secure and has a theoretical collision risk under high load. For production use with unique constraints, consider using crypto.randomUUID() or MongoDB's ObjectId.

♻️ Use crypto.randomUUID() for better uniqueness
+import { randomUUID } from "crypto";
+
 /**
  * Generate a random ID
  */
 private generateId(): string {
-  return (
-    Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
-  );
+  return randomUUID();
 }

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/mongodb/src/memory-adapter.ts">

<violation number="1" location="packages/mongodb/src/memory-adapter.ts:328">
P2: deleteMessages deletes by conversationId only without any userId/ownership check, allowing deletion of other users’ conversation data if the ID is known.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@packages/mongodb/src/memory-adapter.spec.ts`:
- Around line 1-980: The spec file contains the full MongoDBMemoryAdapter
implementation (class MongoDBMemoryAdapter and methods like addMessage,
addMessages, createConversation, getConversation, saveConversationSteps,
getWorkingMemory, setWorkflowMemory, setWorkflowState, etc.) instead of tests;
move this implementation into the proper source file (e.g., memory-adapter.ts)
or delete it from memory-adapter.spec.ts and replace with the actual test suite
for MongoDBMemoryAdapter, creating appropriate unit tests that import
MongoDBMemoryAdapter and exercise methods such as createConversation,
addMessage, getMessages, saveConversationSteps, and workflow state functions.

In `@packages/mongodb/src/memory-adapter.ts`:
- Around line 195-233: In addMessage, remove the explicit _id: undefined from
the document passed to messagesCollection.insertOne so MongoDB can auto-generate
ObjectIds; locate the insert in the addMessage method and delete the _id
property from the inserted object literal (keep messageId, conversationId,
userId, role, parts, metadata, formatVersion, createdAt intact) and keep the
existing 11000 duplicate-key catch logic as-is.
- Around line 235-272: The batch insert in addMessages is setting _id: undefined
which the MongoDB driver serializes as null causing duplicate key errors; update
the documentsToInsert construction in addMessages to NOT include an _id property
at all (so each document lets MongoDB generate a unique ObjectId) before calling
messagesCollection.insertMany, leaving messageId generation and other fields
unchanged.
- Around line 613-654: The saveConversationSteps method currently uses
replaceOne which resets createdAt on every upsert; change the bulk operations in
saveConversationSteps to use updateOne with upsert:true, using $set for mutable
fields (conversationId, userId, agentId, agentName, operationId, stepIndex,
type, role, content, arguments, result, usage, subAgentId, subAgentName, etc.)
and $setOnInsert to set createdAt (and _id when generated) so the original
creation timestamp is preserved; follow the same pattern used in
setWorkingMemory and ensure you still generate an id via this.generateId() when
step.id is missing and include it in the $setOnInsert._id.
🧹 Nitpick comments (2)
packages/mongodb/src/memory-adapter.ts (2)

99-106: Prefer a stronger ID source than Math.random.
Consider crypto.randomUUID() to reduce collision risk and align with common Node practices.

♻️ Proposed update
-  private generateId(): string {
-    return (
-      Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
-    );
-  }
+  private generateId(): string {
+    return randomUUID();
+  }

Additional import (outside this line range):

+import { randomUUID } from "crypto";

377-416: Tighten collection typing to avoid any.
Consider defining collection document interfaces and using getCollection<ConversationDocument>() to preserve type safety and reduce casts.

As per coding guidelines: Maintain type safety in TypeScript-first codebase.

@UmeshpJadhav
Copy link
Contributor Author

@omeraplak Yes, I've just pushed the updates I fixed the build errors and addressed all the code review comments. It should be good to go now.

"@voltagent/mongodb": minor
---

Initial release of MongoDB memory storage adapter
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Initial release of MongoDB memory storage adapter
feat: initial release of MongoDB memory storage adapter

Copy link
Member

Choose a reason for hiding this comment

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

Can we also add minimal usage example?

@omeraplak
Copy link
Member

Hey @UmeshpJadhav ,
Thank you so much! Can you also add docs? https://voltagent.dev/docs/agents/memory/overview/

@GanpatJangra
Copy link

@UmeshpJadhav
If you have some time, could you please complete the remaining requested changes so that @omeraplak can proceed with merging this PR?

It would be great to get this finalized and merged soon. Thank you so much 🙏

@GanpatJangra
Copy link

I opened a follow-up PR that is based on this branch and includes the requested docs updates + minimal usage example: #1127\n\nIt adds:\n- MongoDB mention in the memory overview\n- a dedicated MongoDB memory docs page\n- README minimal usage example\n- llms.txt update\n\nIf easier, maintainers can merge #1127 directly or cherry-pick the docs commit from that branch.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
examples/with-mongodb/src/index.ts (1)

41-41: Make server port configurable via environment variable.

Line 41 hardcodes 3141; using PORT improves local/dev/CI portability.

Suggested refactor
+const port = Number(process.env.PORT ?? 3141);
+
 new VoltAgent({
   agents: {
     agent,
   },
   logger,
-  server: honoServer({ port: 3141 }),
+  server: honoServer({ port }),
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/with-mongodb/src/index.ts` at line 41, Change the hardcoded port in
the honoServer configuration to read from an environment variable so the server
is configurable; update the server: honoServer({ port: 3141 }) call to use
process.env.PORT (or a similarly named env var) parsed as a number with a
sensible default (e.g., 3141) so honoServer receives a numeric port; ensure any
type conversion (Number or parseInt) and a fallback default are applied so
server startup behavior remains unchanged when PORT is not set.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/with-mongodb/README.md`:
- Line 30: The Contributor Covenant badge links to a relative CODE_OF_CONDUCT.md
that breaks for this example; update the badge link target (the Markdown
starting with [![Contributor Covenant] and pointing to CODE_OF_CONDUCT.md) to
reference the repo root (e.g. /CODE_OF_CONDUCT.md) so it resolves correctly from
the example folder.

In `@examples/with-mongodb/tsconfig.json`:
- Around line 6-8: The tsconfig sets "module": "ESNext" but uses
"moduleResolution": "node", which can ignore package.json "exports" and break
ESM conditional exports; update the tsconfig.json by changing the
moduleResolution field from "node" to "NodeNext" so TypeScript resolves the
correct ESM export variants when compiling with "module": "ESNext".

---

Nitpick comments:
In `@examples/with-mongodb/src/index.ts`:
- Line 41: Change the hardcoded port in the honoServer configuration to read
from an environment variable so the server is configurable; update the server:
honoServer({ port: 3141 }) call to use process.env.PORT (or a similarly named
env var) parsed as a number with a sensible default (e.g., 3141) so honoServer
receives a numeric port; ensure any type conversion (Number or parseInt) and a
fallback default are applied so server startup behavior remains unchanged when
PORT is not set.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 690ab3f2-b811-4988-9a1f-a0e179a14f7d

📥 Commits

Reviewing files that changed from the base of the PR and between 7d0eb68 and ee9c1ff.

📒 Files selected for processing (6)
  • examples/with-mongodb/.env.example
  • examples/with-mongodb/.gitignore
  • examples/with-mongodb/README.md
  • examples/with-mongodb/package.json
  • examples/with-mongodb/src/index.ts
  • examples/with-mongodb/tsconfig.json
✅ Files skipped from review due to trivial changes (2)
  • examples/with-mongodb/.gitignore
  • examples/with-mongodb/.env.example

<div align="center">

[![npm version](https://img.shields.io/npm/v/@voltagent/core.svg)](https://www.npmjs.com/package/@voltagent/core)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix broken Contributor Covenant link path.

Line 30 links to CODE_OF_CONDUCT.md relative to this example folder, which likely breaks. Point it to the repo-root file.

Suggested fix
-[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md)
+[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](../../CODE_OF_CONDUCT.md)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](../../CODE_OF_CONDUCT.md)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/with-mongodb/README.md` at line 30, The Contributor Covenant badge
links to a relative CODE_OF_CONDUCT.md that breaks for this example; update the
badge link target (the Markdown starting with [![Contributor Covenant] and
pointing to CODE_OF_CONDUCT.md) to reference the repo root (e.g.
/CODE_OF_CONDUCT.md) so it resolves correctly from the example folder.

Comment on lines +6 to +8
"module": "ESNext",
"target": "ES2022",
"moduleResolution": "node"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n tsconfig.json

Repository: VoltAgent/voltagent

Length of output: 902


🏁 Script executed:

cat -n packages/mongodb/package.json | head -50

Repository: VoltAgent/voltagent

Length of output: 1780


🏁 Script executed:

cat -n examples/with-mongodb/tsconfig.json

Repository: VoltAgent/voltagent

Length of output: 507


Align ESM resolution with NodeNext to properly resolve conditional package exports.

Line 8 uses "moduleResolution": "node", which ignores package.json exports field and can cause resolution mismatches with packages like @voltagent/mongodb that use conditional exports. Since the example uses "module": "ESNext" (ESM), set moduleResolution to "NodeNext" to ensure correct export variant resolution.

Suggested fix
   "compilerOptions": {
       "outDir": "./dist",
       "rootDir": "./src",
       "module": "ESNext",
       "target": "ES2022",
-      "moduleResolution": "node"
+      "moduleResolution": "NodeNext"
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/with-mongodb/tsconfig.json` around lines 6 - 8, The tsconfig sets
"module": "ESNext" but uses "moduleResolution": "node", which can ignore
package.json "exports" and break ESM conditional exports; update the
tsconfig.json by changing the moduleResolution field from "node" to "NodeNext"
so TypeScript resolves the correct ESM export variants when compiling with
"module": "ESNext".

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.

[FEAT] supports the use of Mongodb as one of the memory storage

3 participants