pkg(tools): Expose raw search results in MemoryPromptData for prompt templates#787
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🕒 Queued | supermemory-mcp | bafe6ff | Mar 18 2026, 05:51 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | a00a751 | Mar 19 2026, 12:42 AM |
How to use the Graphite Merge QueueAdd 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. |
|
Claude finished @MaheshtheDev's task in 1m 41s —— View job Code Review Complete
Overview: Adds a Issues found: None — this looks good to ship. The implementation is clean:
Score: 10/10 |
There was a problem hiding this comment.
Overview: Adds a searchResults field to MemoryPromptData exposing raw API search results with metadata for custom filtering in prompt templates.
Issues found: None — this looks good to ship.
The implementation is clean:
- Type
Array<{ memory: string; metadata?: Record<string, unknown> }>correctly matchesProfileStructure.searchResults.results - Null safety handled properly with
memoriesResponse.searchResults?.results ?? [] - Clear distinction between
generalSearchMemories(deduplicated, pre-formatted string) andsearchResults(raw data with metadata) gives users flexibility - Documentation accurately reflects the new capability
- Version bump to 1.4.01 is appropriate for this additive change
- Type cleanup in
memory-prompt.tsusingMemoryPromptDatainstead of inline type is a nice improvement
Score: 10/10
Merge activity
|
…templates (#787) Expose raw search results in `MemoryPromptData` so prompt templates can traverse, filter, and selectively include results based on metadata (e.g. score, source). ##### Usage example ```typescript const promptTemplate = (data: MemoryPromptData) => { const relevant = data.searchResults.filter( (r) => (r.metadata?.score as number) > 0.7 ) return `${data.userMemories}\n${relevant.map(r => r.memory).join('\n')}` } ```
11dc404 to
a00a751
Compare
| </user_memories> | ||
| <relevant_context> | ||
| ${relevant.map((r) => `- ${r.memory}`).join("\n")} | ||
| </relevant_context> |
There was a problem hiding this comment.
Bug: The documentation example for filtering search results uses r.metadata?.score, but the API returns the score in the top-level similarity field, causing the filter to fail.
Severity: MEDIUM
Suggested Fix
Update the documentation example in apps/docs/ai-sdk/user-profiles.mdx to filter by r.similarity instead of r.metadata?.score. The corrected code should be const relevant = data.searchResults.filter((r) => r.similarity > 0.7).
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: apps/docs/ai-sdk/user-profiles.mdx#L198
Potential issue: The documentation example for filtering memory search results
incorrectly references `r.metadata?.score`. The actual API response places the
similarity score in a top-level `similarity` field. As a result, any user code following
this example will have the filter condition `(r.metadata?.score as number) > 0.7`
evaluate to `false`, because `r.metadata?.score` is `undefined`. This will cause all
search results to be filtered out, leading to an empty `relevant` array and preventing
the intended user profile information from being included in the prompt.
Did we get this right? 👍 / 👎 to inform future reviews.

Expose raw search results in
MemoryPromptDataso prompt templates can traverse, filter, and selectively include results based on metadata (e.g. score, source).Usage example