Skip to content

Vercel AI SDK backfilling#769

Open
sreedharsreeram wants to merge 15 commits intomainfrom
back-filling-vercel
Open

Vercel AI SDK backfilling#769
sreedharsreeram wants to merge 15 commits intomainfrom
back-filling-vercel

Conversation

@sreedharsreeram
Copy link
Copy Markdown
Contributor

No description provided.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 6, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp 579ef03 Apr 14 2026, 03:21 PM

Copy link
Copy Markdown
Member

@MaheshtheDev MaheshtheDev left a comment

Choose a reason for hiding this comment

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

@sreedharsreeram please update the package version and update the documentation for this packages with these new tools

Copy link
Copy Markdown
Contributor Author

sreedharsreeram commented Mar 9, 2026


How to use the Graphite Merge Queue

Add the label Main to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor Author

@sreedharsreeram please update the package version and update the documentation for this packages with these new tools

​Done! Please review

Copy link
Copy Markdown
Member

@sreedharsreeram please fix merge conflicts

@entelligence-ai-pr-reviews
Copy link
Copy Markdown


Confidence Score: 2/5 - Changes Needed

Not safe to merge — the new withSupermemory signature in packages/tools/src/vercel/index.ts introduces a breaking API change by inserting conversationId as a required positional parameter between containerTag and options, which means all existing callers silently pass their options object as the conversationId string argument with no type error at the call site. This PR does deliver meaningful new functionality — hybrid and document-based RAG search modes, four new AI SDK tool factories, and updated documentation — but the backward-incompatible signature change without a major version bump or deprecation path is a correctness issue that will silently corrupt behavior for existing consumers.

Key Findings:

  • In packages/tools/src/vercel/index.ts, inserting conversationId as a required positional parameter between containerTag and options is a breaking change: existing callers using withSupermemory(model, containerTag, options) will silently pass their options object as conversationId, causing runtime misbehavior (wrong conversationId, options ignored) with no TypeScript error at the call site depending on overload resolution.
  • The new SearchMode type ('memories' | 'hybrid' | 'documents') and searchLimit addition to SupermemoryBaseOptions in types.ts appear well-scoped, but the routing logic in buildMemoriesText that switches on searchMode should be verified to handle undefined/default cases gracefully to avoid silent fallthrough.
  • The PR bumps to v1.5.0 (minor version), but introducing a positional parameter break in a public API warrants a major version bump under semver — shipping this as a minor version understates the compatibility impact for downstream consumers.
Files requiring special attention
  • packages/tools/src/vercel/index.ts
  • packages/tools/src/memory-client.ts
  • packages/tools/src/types.ts

Copy link
Copy Markdown

@entelligence-ai-pr-reviews entelligence-ai-pr-reviews bot left a comment

Choose a reason for hiding this comment

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

🔍 Duplicate Code Detected

Found 2 duplicate function(s) in this PR. Consider consolidating to reduce code duplication.

@claude
Copy link
Copy Markdown

claude bot commented Apr 1, 2026

Claude finished @sreedharsreeram's task in 1m 36s —— View job


PR Review: Vercel AI SDK backfilling

  • Fetch and analyze the PR diff
  • Review key changed files for bugs/security issues
  • Check if previously flagged issues have been resolved
  • Submit review

Summary: This PR adds hybrid/documents search modes for RAG via a new /v4/search endpoint and refactors withSupermemory to use an options object pattern.

Verdict: Ready to ship (9/10)

All previously flagged issues have been addressed:

  • The ReferenceError bug with memoriesResponse scoping is fixed — rawSearchResults is now properly declared at function scope
  • The API change to an options object pattern is fully documented with updated README examples and tests
  • No security issues or logic bugs found

See my full review for details.

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG and makes conversationId a required parameter.

Issues found:

  1. Critical: ReferenceError in memory-client.ts:329memoriesResponse is referenced outside its scope. When useHybridSearch is true (hybrid/documents mode), this will throw a ReferenceError at runtime since memoriesResponse is only defined in the else branch.

  2. Documentation mismatch — All README examples use the old 3-argument signature withSupermemory(model, containerTag, options) but the API now requires 4 arguments with conversationId as required positional parameter.

  3. Breaking change flagged by other reviewers — The withSupermemory signature change from (model, containerTag, options?) to (model, containerTag, conversationId, options?) is a breaking change that should warrant a major version bump (2.0.0), not minor (1.5.0).

Score: 5/10

The hybrid search feature looks well-designed, but the ReferenceError will crash any usage of hybrid/documents mode. This needs to be fixed before merge.

@entelligence-ai-pr-reviews
Copy link
Copy Markdown


Confidence Score: 1/5 - Blocking Issues

Not safe to merge — the withSupermemory function signature change in packages/tools/src/vercel/index.ts introduces a silent, destructive breaking change: promoting conversationId to a required positional 3rd argument means all existing callers using the 3-arg form withSupermemory(model, tag, options) will silently pass their WrapVercelLanguageModelOptions object as the conversationId string parameter, corrupting the conversation ID with [object Object] and discarding all option overrides without any error or warning. The PR does add valuable SearchMode and searchLimit capabilities with a sensible hybrid/documents branch in buildMemoriesText, but the API breakage is critical enough to block merge. This same concern was flagged in a previous unresolved review comment and remains unaddressed, confirming the issue is known but not fixed.

Key Findings:

  • In packages/tools/src/vercel/index.ts, inserting conversationId: string as the 3rd positional argument between containerTag and options is a breaking API change: callers on the prior 3-arg signature will pass their options object where a string is expected, silently coercing it to [object Object] as the conversationId and losing all option configuration with no runtime error.
  • The breaking change is doubly dangerous because TypeScript may not catch it at call sites if conversationId can accept any or if the options object is typed loosely, meaning the corruption can reach production silently across all existing integrations.
  • A pre-existing unresolved review comment from a prior review cycle explicitly called out this same conversationId positional-argument breakage in withSupermemory, and the issue has not been resolved before this re-review, indicating the risk is acknowledged but the fix (e.g., keeping conversationId inside WrapVercelLanguageModelOptions or making it optional with a default) has not been applied.
Files requiring special attention
  • packages/tools/src/vercel/index.ts
  • packages/tools/src/memory-client.ts
  • packages/tools/src/types.ts

@entelligence-ai-pr-reviews
Copy link
Copy Markdown


Confidence Score: 1/5 - Blocking Issues

Not safe to merge — this PR introduces two critical runtime-breaking bugs that will cause immediate failures in production. In memory-client.ts, memoriesResponse is declared with const inside an else block, making it inaccessible in the subsequent promptData construction when the if (useHybridSearch && queryText) branch executes, which will throw a ReferenceError at runtime. Simultaneously, in vercel/index.ts, inserting conversationId as a new required positional parameter between containerTag and options silently breaks every existing caller of withSupermemory(model, containerTag, options) — their options object is now consumed as conversationId, causing type mismatches and incorrect behavior with no compile-time error for JavaScript callers. While the PR's goal of adding hybrid search capabilities and a SearchMode union type is a meaningful feature addition, these two defects must be resolved before any merge can be considered.

Key Findings:

  • In memory-client.ts, memoriesResponse declared with const inside the else block is out of scope when the hybrid search if branch runs, causing a guaranteed ReferenceError: memoriesResponse is not defined crash on any call that takes the hybrid search path.
  • In vercel/index.ts, adding conversationId as a positional parameter between containerTag and options is a breaking API change — all existing callers invoking withSupermemory(model, containerTag, options) will silently pass their options object as the conversationId string argument, leading to wrong behavior and hard-to-debug runtime errors.
  • Both bugs are in the core execution paths of the new feature, meaning the hybrid search functionality is effectively non-functional and the Vercel middleware refactor is backwards-incompatible as written.
  • 4 previous unresolved comment(s) likely resolved in latest diff (score-only signal; thread status unchanged)
Files requiring special attention
  • packages/tools/src/shared/memory-client.ts
  • packages/tools/src/vercel/index.ts

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG and makes conversationId a required parameter.

Issues found:

  1. Critical: ReferenceError in memory-client.ts:335memoriesResponse is referenced outside its scope. When useHybridSearch is true (hybrid/documents mode), this will throw a ReferenceError at runtime since memoriesResponse is only defined in the else block at line 274.

  2. Documentation mismatch — All README examples (lines 193, 220) use the signature without the now-required conversationId field. Since options is now required with conversationId: string, examples like withSupermemory(openai("gpt-4"), "user-123", { mode: "full" }) will fail TypeScript compilation.

  3. Breaking change — Making options required and conversationId required within it is a breaking change. TypeScript will catch this at compile time (not a silent failure), but it warrants a major version bump (2.0.0) rather than minor (1.5.0).

Score: 4/10

The hybrid search feature is well-designed, but the ReferenceError will crash any usage of hybrid/documents mode. This must be fixed before merge.

@entelligence-ai-pr-reviews
Copy link
Copy Markdown


Confidence Score: 1/5 - Blocking Issues

Not safe to merge — this PR contains a confirmed runtime ReferenceError in memory-client.ts where memoriesResponse is declared inside an else block but referenced at line 328 outside that block, meaning the hybrid search code path crashes unconditionally. Beyond this new critical bug, four unresolved correctness issues in packages/tools/src/vercel/index.ts document that promoting conversationId to a required positional parameter between containerTag and options constitutes a breaking API change that will silently break all existing callers without a major version bump. The PR does introduce genuinely useful functionality — hybrid search mode, configurable searchLimit, and SearchMode typing — but the scope of breakage makes this unshippable in its current state.

Key Findings:

  • memoriesResponse is scoped inside the else branch in buildMemoriesText (or equivalent function in memory-client.ts) but read unconditionally at line 328 after the if/else block, producing a ReferenceError at runtime on every hybrid search invocation — the core new feature of this PR is broken.
  • In packages/tools/src/vercel/index.ts, conversationId was removed from WrapVercelLanguageModelOptions and made a required positional 3rd argument to withSupermemory, breaking all existing callers using the previous 2-arg or options-bag form without a corresponding major version change to signal the breaking API contract.
  • The duplicate unresolved comments about withSupermemory's signature change indicate this breaking change concern was raised in a previous review cycle and was never resolved, suggesting the author has not addressed reviewer feedback on a correctness-critical issue.
  • Releasing as 1.5.0 (minor bump) is inconsistent with the breaking signature change to withSupermemory, which requires a major version bump under semver; downstream consumers relying on automated updates could have their builds broken silently.
  • 2 previous unresolved comment(s) likely resolved in latest diff (score-only signal; thread status unchanged)
Files requiring special attention
  • packages/tools/src/shared/memory-client.ts
  • packages/tools/src/vercel/index.ts
  • packages/tools/src/shared/types.ts

@entelligence-ai-pr-reviews
Copy link
Copy Markdown


Confidence Score: 4/5 - Mostly Safe

Likely safe but review recommended — this PR introduces SearchMode typing and supermemoryHybridSearch in memory-client.ts with a clear branching strategy in buildMemoriesText, and the automated review found no flagged issues across the 6 reviewed files. The refactoring of conversationId to optional and the addition of formatSearchResults as a helper appear well-scoped, though 2 of 8 changed files were not reviewed, leaving a small blind spot. The PR is largely clean and achieves its stated goal of hybrid search support without introducing obvious regressions.

Key Findings:

  • No automated review comments were generated across 6 of 8 reviewed files, suggesting the core logic in memory-client.ts, types.ts, and the Vercel middleware refactor is structurally sound.
  • The branching in buildMemoriesText between profile-based and hybrid search paths is a meaningful control-flow change — while no bugs were flagged, this kind of conditional dispatch warrants human review to confirm edge cases (e.g., when searchMode defaults or is undefined) are handled correctly.
  • 2 files out of 8 changed were not covered by the automated review, meaning there is incomplete visibility into the full scope of changes — this is a minor but real gap in confidence.
  • Making conversationId optional is a subtle interface contract change that could silently affect downstream consumers if they relied on it being required — worth confirming no callers are broken.
Files requiring special attention
  • memory-client.ts
  • types.ts

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG and makes conversationId required.

Good news: The ReferenceError bug flagged by earlier reviewers has been fixed in this version. The code now properly declares rawSearchResults at function scope (line 216), avoiding the scoping issue where memoriesResponse was referenced outside its else block.

Issues found:

  1. Documentation examples missing required field — All new examples in README.md and user-profiles.mdx are missing the now-required conversationId field. Users following the docs will get TypeScript errors. See inline comments for suggested fixes.

  2. Breaking API change — Making options required and conversationId required within it changes the public API signature from withSupermemory(model, tag, options?) to withSupermemory(model, tag, options) where options must include conversationId. This is technically a breaking change that would warrant a major version bump (2.0.0) under strict semver. However, TypeScript will catch this at compile time (not a silent failure), so the impact is manageable.

Score: 8/10

The hybrid search feature is well-implemented and the previous scoping bug has been fixed. The only blocking issues are the documentation examples that won't compile. Once those are updated, this is good to ship.

@entelligence-ai-pr-reviews
Copy link
Copy Markdown


Confidence Score: 4/5 - Mostly Safe

Safe to merge — this PR cleanly introduces hybrid search (RAG) capability and conversation-scoped memory enforcement to @supermemory/tools v1.5.0 with no identified logic bugs, security concerns, or runtime issues. The new SearchMode type, supermemoryHybridSearch function, and SearchResultItem/SearchResponse interfaces appear to be well-scoped additions. No review comments were generated across the reviewed files, suggesting the implementation is structurally sound, though 4 of 10 changed files were not reviewed, leaving a small blind spot.

Key Findings:

  • supermemoryHybridSearch and the refactored buildMemoriesText in memory-client.ts introduce new code paths (hybrid/document search) that were not flagged for issues, suggesting the branching logic is straightforward and consistent with existing patterns.
  • The new SearchMode type ('memories' | 'hybrid' | 'documents') and searchLimit option added to SupermemoryBaseOptions in types.ts are additive and non-breaking changes, which reduces regression risk for existing consumers.
  • Coverage was 6/10 changed files — the 4 unreviewed files (likely documentation and/or test files) represent a minor blind spot but do not constitute a blocking concern given the nature of the PR.
  • No pre-existing unresolved comments were identified, meaning this PR does not compound any outstanding technical debt.
Files requiring special attention
  • memory-client.ts
  • types.ts

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG via a new /v4/search endpoint, enabling search across both memories AND document chunks.

Issues found: None — this looks good to ship.

Clarifications on previous review concerns:

  1. ReferenceError (FIXED): The scoping bug where memoriesResponse was referenced outside its else block has been properly fixed. The code now declares rawSearchResults at function scope (memory-client.ts:216-219), so it's always accessible regardless of which branch executes.

  2. Breaking API change (NOT an issue): The withSupermemory signature remains (model, containerTag, options?) with conversationId staying optional inside WrapVercelLanguageModelOptions (vercel/index.ts:17). The only change is a new runtime validation: if addMemory: "always" is set, then conversationId is required (vercel/index.ts:131-138). This is defensive programming — TypeScript will catch it at compile time if you have proper types, and runtime throws a clear error message. This is not a breaking change for existing callers.

  3. Documentation (CORRECT): The hybrid search examples correctly omit conversationId when not using addMemory: "always". Examples that do use addMemory: "always" now include conversationId.

What's well done:

  • Clean separation between hybrid search path and legacy profile search path in buildMemoriesText
  • Proper error handling in both supermemoryHybridSearch and supermemoryProfileSearch
  • Good TypeScript types for SearchMode and SearchResultItem
  • Clear JSDoc documentation throughout
  • Appropriate minor version bump (1.5.0) for additive, non-breaking features

Score: 9/10

@entelligence-ai-pr-reviews
Copy link
Copy Markdown


Confidence Score: 4/5 - Mostly Safe

Likely safe but review recommended — this PR introduces supermemoryHybridSearch, the SearchMode union type, and searchMode/searchLimit fields on SupermemoryBaseOptions cleanly, with no critical issues flagged by automated review. The new /v4/search endpoint integration appears straightforward, and the conversationId enforcement aligns with the stated v1.5.0 goals. However, only 6 of 10 changed files were reviewed, meaning portions of the implementation — potentially including the Vercel AI SDK adapter wiring and documentation updates — were not fully analyzed, leaving a residual gap in confidence.

Key Findings:

  • No logic bugs, null-pointer risks, or security issues were identified in the reviewed files; the SearchResultItem/SearchResponse interfaces provide typed boundaries around the /v4/search response, reducing runtime surprises.
  • The searchMode field defaults and searchLimit optionality were not flagged as problematic, but the absence of validation (e.g., guarding against invalid SearchMode strings at runtime if values come from external config) is worth a quick manual check.
  • 4 of 10 changed files went unreviewed, including likely the Vercel AI SDK backfill adapter itself — the primary feature of this PR — meaning the automated analysis has limited visibility into the core integration path.
  • Documentation-only files (READMEs, changelogs) appear to be part of the diff; these carry no runtime risk but should be spot-checked to ensure version numbers and API signatures match the actual implementation.
Files requiring special attention
  • packages/tools/src/shared/memory-client.ts
  • packages/tools/src/shared/types.ts
  • packages/tools/src/vercel-ai/index.ts

sreedharsreeram and others added 11 commits April 13, 2026 17:56
Prefix unused variables with underscore and fix formatting in memory-client.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Break long conditionals across multiple lines and use single quotes
for string containing escaped double quotes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG via a new /v4/search endpoint, enabling search across both memories AND document chunks.

Issues found: None — this looks good to ship.

Clarifications on previous review concerns:

  1. ReferenceError (FIXED): The scoping bug where memoriesResponse was referenced outside its else block has been properly fixed. The code now declares rawSearchResults at function scope (memory-client.ts:216-219), and it's correctly assigned in both the hybrid search branch (line 255) and the profile search branch (line 339).

  2. Breaking API change (NOT an issue): The withSupermemory signature remains (model, containerTag, options?) with conversationId staying optional inside WrapVercelLanguageModelOptions (vercel/index.ts:17). The new runtime validation at lines 131-138 only throws if addMemory: "always" is set without conversationId — this is correct defensive programming, not a breaking change. Existing callers are unaffected.

  3. Documentation: Updated correctly with new searchMode and searchLimit options. Examples that use addMemory: "always" now include conversationId.

What's well done:

  • Clean separation between hybrid search path and legacy profile search path in buildMemoriesText
  • Proper error handling in both supermemoryHybridSearch and supermemoryProfileSearch
  • Good TypeScript types for SearchMode and SearchResultItem
  • Clear JSDoc documentation throughout
  • Appropriate minor version bump (1.5.0) for additive, non-breaking features

Score: 9/10

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG via a new /v4/search endpoint and refactors the withSupermemory API to use an options object pattern.

Issues found:

  1. Breaking API change without README update — The withSupermemory signature changed from (model, containerTag, options?) to ({ model, containerTag, customId, ...options }). The README still shows the old positional argument API, which will cause runtime errors for anyone following the docs.

  2. addMemory default changed from "never" to "always" — This is a significant behavior change. Existing users who upgrade will suddenly have all conversations saved to memory without opting in. This should either be reverted to maintain backwards compatibility or explicitly documented as a breaking change.

  3. customId is now required — Previously conversationId was optional. Now customId is required in the options object. This needs to be reflected in all documentation.

What's working well:

  • The ReferenceError bug flagged by earlier reviewers has been properly fixed (rawSearchResults is now declared at function scope)
  • Clean implementation of hybrid search with proper TypeScript types
  • Good test coverage for the new caching behavior

Score: 7/10

The hybrid search feature is well-implemented, but the undocumented breaking changes and the addMemory default flip need to be addressed before merge. Either update all README examples to match the new API, or consider a major version bump to signal the breaking changes.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 14, 2026

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG via a new /v4/search endpoint and refactors withSupermemory to use an options object pattern.

Issues found: None — this looks good to ship.

Clarifications on previous review concerns:

  1. ReferenceError (FIXED): The scoping bug where memoriesResponse was referenced outside its else block has been properly fixed. The code now declares rawSearchResults at function scope (memory-client.ts:216-219) and correctly assigns it in both the hybrid search branch (line 255) and the profile search branch (line 339).

  2. Breaking API change (Documented): The withSupermemory signature changed from positional args (model, containerTag, options?) to an options object ({ model, containerTag, customId, ...options }). This is a breaking change, but:

    • All tests have been updated to use the new pattern
    • README documentation reflects the new API signature
    • The options object pattern is cleaner and more extensible
  3. addMemory default: The default is "always" as documented in the README under "Automatic Memory Capture". This is set explicitly in vercel/index.ts:155.

What's well done:

  • Clean separation between hybrid search path and legacy profile search in buildMemoriesText
  • Proper error handling with typed responses from supermemoryHybridSearch
  • Good TypeScript types for SearchMode, SearchResultItem, and SearchResponse
  • Per-turn memory caching to avoid redundant API calls during tool-call continuations
  • Comprehensive test coverage for the new options pattern

Score: 9/10

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG via a new /v4/search endpoint and refactors withSupermemory to use an options object pattern with customId as a required field.

Issues found: None — this looks good to ship.

Clarifications on previous review concerns:

  1. ReferenceError (FIXED): The scoping bug where memoriesResponse was referenced outside its else block has been properly fixed. The code now declares rawSearchResults at function scope (memory-client.ts:216-219) and correctly assigns it in both the hybrid search branch (line 255) and the profile search branch (line 339).

  2. Breaking API change (Documented): The withSupermemory signature changed from positional args to an options object { model, containerTag, customId, ...options }. This is a breaking change, but:

    • README documentation has been fully updated to show the new pattern
    • All tests have been updated to use the new API
    • Proper validation with clear error messages for missing customId
  3. Documentation: README correctly shows customId as required and documents all new options including searchMode and searchLimit.

What's well done:

  • Clean separation between hybrid search path and legacy profile search in buildMemoriesText
  • Proper error handling with typed SearchResponse and SearchResultItem interfaces
  • Per-turn memory caching via MemoryCache to avoid redundant API calls during tool-call continuations
  • Comprehensive test coverage for the new options pattern

Score: 9/10

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Overview: Adds hybrid/documents search modes for RAG via a new /v4/search endpoint and refactors withSupermemory to use an options object pattern with customId as a required field.

Issues found: None — this looks good to ship.

Verification of previously flagged concerns:

  1. ReferenceError (FIXED): The scoping bug where memoriesResponse was referenced outside its else block has been properly fixed. The code now declares rawSearchResults at function scope (memory-client.ts:216-219) and correctly assigns it in both the hybrid search branch (line 255) and the profile search branch (line 339). The promptData construction at line 345 uses this function-scoped variable.

  2. Breaking API change (Documented): The withSupermemory signature changed from positional args (model, containerTag, options?) to an options object { model, containerTag, customId, ...options }. This is properly reflected in:

    • README.md with all examples updated
    • All integration tests using the new pattern
    • docs-test files updated
    • Proper validation with clear error messages for missing customId
  3. Hybrid search implementation: Clean separation between hybrid search path (uses /v4/search) and legacy profile search path (uses /v4/profile) in buildMemoriesText. Error handling is consistent across both paths.

What's well done:

  • Per-turn memory caching via MemoryCache to avoid redundant API calls during tool-call continuations
  • Proper TypeScript types for SearchMode, SearchResultItem, and SearchResponse
  • Comprehensive test coverage for the new options pattern
  • Clear JSDoc documentation throughout

Score: 9/10

"@ai-sdk/anthropic": "^2.0.25",
"@ai-sdk/openai": "^2.0.23",
"ai": "^5.0.29",
"lru-cache": "^11.2.6",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@sreedharsreeram

may i ask why this is removed?

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