-
Notifications
You must be signed in to change notification settings - Fork 1.6k
mastra integration #717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mastra integration #717
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | 9553434 | Feb 03 2026, 12:48 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 pls review |
|
Claude finished @nexxeln's task in 1m 59s —— View job Code Review Complete ✅I've completed a comprehensive review of the Mastra integration PR. Here's my detailed feedback: OverviewThis PR successfully adds Mastra integration with a Summary:
Detailed Feedback1. Core Implementation (Mastra)Strengths:
Issues:Minor: Type casting in processor.ts:137-141 The type assertion here feels fragile: const queryText = extractQueryText(
messages as unknown as Array<{
role: string
content: string | Array<{ type: string; text?: string }>
}>,
this.ctx.mode,
)The
Location: packages/tools/src/mastra/processor.ts:137-141 Minor: Error handling in message conversion (processor.ts:282-318) The private convertToConversationMessages(messages: MastraDBMessage[]): ConversationMessage[] {
const result: ConversationMessage[] = []
let skippedCount = 0
for (const msg of messages) {
if (msg.role === "system") {
continue
}
// ... existing logic
// If nothing was added, increment skippedCount
}
if (skippedCount > 0) {
this.ctx.logger.debug(`Skipped ${skippedCount} messages during conversion`)
}
return result
}Location: packages/tools/src/mastra/processor.ts:282-318 2. Shared Module RefactoringStrengths:
Issues:Minor: GenericMessage type could be more precise In export interface GenericMessage {
role: string
content: string | Array<{ type: string; text?: string }>
}This is fine, but the const objContent = content as unknown as {
content?: string
parts?: Array<{ type: string; text?: string }>
}Consider making Location: packages/tools/src/shared/memory-client.ts:174-177, 217-228 Minor: tools-shared.ts rename The file was renamed from
Location: packages/tools/src/tools-shared.ts 3. TestsStrengths:
Issues:None identified - Test coverage is excellent! 4. DocumentationStrengths:
Issues:Minor: Missing closing backtick in mastra.mdx Line 126 in const agent = new Agent(withSupermemory(config, "user-123", { mode: "full" }))
### Mode Comparison // This should be after closing ```Location: apps/docs/integrations/mastra.mdx:126 Suggestion: Add troubleshooting section Consider adding a troubleshooting section to the docs covering:
5. Package ConfigurationStrengths:
Issues:Question: Should @mastra/core be a peer dependency? Currently
Location: packages/tools/package.json:24 6. Minor Code Quality IssuesSuggestion: Extract magic strings in cache.ts Line 26 in return `${containerTag}:${threadId || ""}:${mode}:${normalizedMessage}`Consider extracting the separator as a constant for easier modification: private static readonly CACHE_KEY_SEPARATOR = ':'
static makeTurnKey(...): string {
const sep = MemoryCache.CACHE_KEY_SEPARATOR
return `${containerTag}${sep}${threadId || ""}${sep}${mode}${sep}${normalizedMessage}`
}Location: packages/tools/src/shared/cache.ts:26 Minor: Inconsistent error messages In error: error instanceof Error ? error.message : "Unknown error"This pattern is used consistently, which is good. However, consider extracting to a helper: const getErrorMessage = (error: unknown): string =>
error instanceof Error ? error.message : String(error) || "Unknown error"Then use: This would be more DRY and could handle more error types. 7. Frontend ChangesThe changes to Security Considerations✅ API key handling: Properly validated with Performance Considerations✅ Caching implemented: Per-turn memory cache prevents redundant API calls Breaking ChangesNone identified. This is a purely additive feature. Recommendations
Final VerdictApprove with minor suggestions ✅ This is a high-quality PR that adds a valuable integration while improving the overall codebase through refactoring. The test coverage is excellent, documentation is comprehensive, and the architecture follows best practices. The issues identified are minor and don't block merging. Great work on this PR! The shared module refactoring will make future integrations much easier to implement. |
b5651d7 to
05ecc18
Compare
Merge activity
|
adds withSupermemory wrapper and input/output processors for
mastra agents:
- input processor fetches and injects memories into system prompt
before llm calls
- output processor saves conversations to supermemory after
responses
- supports profile, query, and full memory search modes
- includes custom prompt templates and requestcontext support
const agent = new Agent(withSupermemory(
{ id: "my-assistant", model: openai("gpt-4o"), instructions:
"..." },
"user-123",
{ mode: "full", addMemory: "always", threadId: "conv-456" }
))
includes docs as well
this pr also reworks how the tools package works into shared modules
b823124 to
9553434
Compare

adds withSupermemory wrapper and input/output processors for
mastra agents:
before llm calls
responses
const agent = new Agent(withSupermemory(
{ id: "my-assistant", model: openai("gpt-4o"), instructions:
"..." },
"user-123",
{ mode: "full", addMemory: "always", threadId: "conv-456" }
))
includes docs as well
this pr also reworks how the tools package works into shared modules