Skip to content

add the addMemory option docs#616

Merged
graphite-app[bot] merged 1 commit into
mainfrom
12-13-add_the_addmemory_option_docs
Dec 14, 2025
Merged

add the addMemory option docs#616
graphite-app[bot] merged 1 commit into
mainfrom
12-13-add_the_addmemory_option_docs

Conversation

@nexxeln

@nexxeln nexxeln commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 13, 2025

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

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

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
supermemory-app c42248f Commit Preview URL

Branch Preview URL
Dec 19 2025, 01:09 AM

nexxeln commented Dec 13, 2025

Copy link
Copy Markdown
Contributor Author

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.

@claude

claude Bot commented Dec 13, 2025

Copy link
Copy Markdown

Code Review: Add addMemory Option Documentation

Overview

This PR adds important documentation about the addMemory option for the withSupermemory middleware. The changes correctly document that memory saving is disabled by default and show users how to enable it.

✅ Positive Aspects

  1. Accurate Documentation: The changes correctly reflect the implementation in packages/tools/src/vercel/index.ts:66 and middleware.ts:75, where addMemory defaults to "never".

  2. Clear User Communication: The Note blocks effectively communicate an important behavioral detail that users need to know upfront.

  3. Consistent Placement: The documentation is added in both overview and user-profiles pages, ensuring users see this information regardless of their entry point.

  4. Good Code Examples: The TypeScript examples clearly show how to enable the feature with addMemory: "always".

🐛 Issues Found

1. Empty Code Block (apps/docs/ai-sdk/overview.mdx:48-49)

```typescript
**Issue**: Lines 48-49 contain an empty TypeScript code block that serves no purpose.

**Impact**: Minor - doesn't break anything but adds unnecessary clutter to the rendered documentation.

**Recommendation**: Remove these two lines.

---

### 2. Model Name Inconsistency (apps/docs/ai-sdk/overview.mdx:29, 42)
The example was changed from `"gpt-4"` to `"gpt-5"`:
```typescript
const modelWithMemory = withSupermemory(openai("gpt-5"), "user-123")

Issue: As of my knowledge cutoff (January 2025), OpenAI's latest models are GPT-4 variants. "gpt-5" doesn't exist yet.

Impact: Medium - Users copying this code will get API errors when they try to use a non-existent model.

Recommendation: Revert to "gpt-4" or use a valid model like "gpt-4-turbo" or "gpt-4o". The same issue exists in user-profiles.mdx:52.


3. Missing Model Update in user-profiles.mdx

In apps/docs/ai-sdk/user-profiles.mdx:68, the model is still correctly shown as "gpt-4":

const model = withSupermemory(openai("gpt-4"), "user-123")

Issue: Inconsistency - this file has the same gpt-5 change in one location (line 52) but not others (line 68).

Impact: Minor - creates confusion about which model to use.

Recommendation: Keep all examples consistent. Use valid OpenAI model names throughout.

💡 Suggestions for Improvement

1. Add Context About When to Use addMemory: "always"

Consider expanding the Note to explain use cases:

<Note>
  **Memory saving is disabled by default.** The middleware only retrieves existing memories. 
  
  To automatically save new memories from conversations, enable it explicitly:
  
  ```typescript
  const modelWithMemory = withSupermemory(openai("gpt-4"), "user-123", {
    addMemory: "always"
  })

When to enable: Use addMemory: "always" when building chat applications or assistants
where you want the system to learn from each conversation automatically.


### 2. Document the `"never"` Option Explicitly
Since the type is `"always" | "never"`, it might be helpful to show both options:
```typescript
// Default behavior - only read memories, don't save
const model = withSupermemory(openai("gpt-4"), "user-123", {
  addMemory: "never"  // explicit, though this is the default
})

// Save all conversations as memories
const model = withSupermemory(openai("gpt-4"), "user-123", {
  addMemory: "always"
})

3. Cross-reference with conversationId

The conversationId option works together with addMemory. Consider mentioning this relationship:

// Save memories grouped by conversation
const model = withSupermemory(openai("gpt-4"), "user-123", {
  conversationId: "chat-session-abc",
  addMemory: "always"
})

📋 Action Items

Must Fix:

  1. ❌ Remove empty code block at lines 48-49 in overview.mdx
  2. ❌ Change "gpt-5" back to "gpt-4" in both files (or use another valid model name)

Nice to Have:
3. ✨ Add guidance on when to use addMemory: "always"
4. ✨ Show both "always" and "never" options explicitly
5. ✨ Mention relationship with conversationId option

🎯 Verdict

Status: Needs minor fixes before merging

The core documentation addition is excellent and fills an important gap. However, the gpt-5 model name issue needs to be fixed as it will cause user confusion and errors. The empty code block should also be removed.

Once these issues are addressed, this will be a valuable improvement to the documentation! 👍

@nexxeln nexxeln marked this pull request as ready for review December 13, 2025 17:32
@graphite-app graphite-app Bot requested a review from Dhravya December 13, 2025 17:32
@graphite-app

graphite-app Bot commented Dec 14, 2025

Copy link
Copy Markdown

Merge activity

@graphite-app

graphite-app Bot commented Dec 14, 2025

Copy link
Copy Markdown

Video gif. A toddler grins wide, raising their hand and giving an exuberant thumbs up at us. Their nose krinkles under their big smile.  (Added via Giphy)

@graphite-app graphite-app Bot force-pushed the 12-13-add_the_addmemory_option_docs branch from 7de1043 to c42248f Compare December 14, 2025 01:19
@graphite-app graphite-app Bot merged commit c42248f into main Dec 14, 2025
4 of 6 checks passed
@claude

claude Bot commented Dec 14, 2025

Copy link
Copy Markdown

Pull Request Review

Summary

This PR adds important documentation for the addMemory option in the withSupermemory middleware. The option controls whether conversations are automatically saved as memories, which is a critical behavioral setting that was previously undocumented in the user-facing docs.

Code Quality ✅

Positive aspects:

  • Clear and concise documentation that explains the default behavior (disabled by default)
  • Consistent formatting across both modified files
  • Good use of the <Note> component to highlight the important default behavior
  • Example code is accurate and matches the implementation

Issues Found 🔍

1. Empty code block (apps/docs/ai-sdk/overview.mdx:48-49)

```typescript
This appears to be leftover from editing and should be removed.

#### 2. **Model name inconsistency**
The PR changes `gpt-4` to `gpt-5` in the examples. While this might be intentional:
- `gpt-5` doesn't currently exist (as of my knowledge cutoff)
- If this is forward-looking documentation, that's fine
- Otherwise, consider using `gpt-4o` or `gpt-4-turbo` which are current models

#### 3. **Missing test coverage**
The `addMemory: "always"` option is documented but there are no test cases covering this functionality in the test files. Consider adding integration tests for:
- Memory saving when `addMemory: "always"` is set
- No memory saving when `addMemory: "never"` (default)
- Verification that memories are properly stored via the API

### Documentation Quality ✅

**Strengths:**
- The note clearly states the default behavior, which is crucial for users
- Code examples show the exact syntax needed
- Placement in both `overview.mdx` and `user-profiles.mdx` ensures visibility
- Consistent with the existing README.md documentation pattern

**Suggestions:**
1. Consider adding a brief explanation of when to use `addMemory: "always"` vs leaving it disabled
2. Mention any performance or cost implications of auto-saving every message
3. Link to the README or API docs for more details on memory management

### Security Considerations ✅

No security concerns identified. The feature:
- Uses existing authenticated API calls
- Follows the same permission model as manual memory storage
- Doesn't expose sensitive data

### Performance Considerations ⚠️

**Potential concern:**
When `addMemory: "always"` is enabled, every user message triggers an API call to store the memory. The implementation shows this happens via `addMemoryTool()` in the middleware (packages/tools/src/vercel/middleware.ts:118-123).

**Recommendations:**
1. Consider documenting the performance impact in the note
2. Users should be aware this doubles API calls (one for generation, one for storage)
3. For high-volume applications, this could significantly increase costs and latency

### Alignment with Repository Standards ✅

According to CLAUDE.md:
- ✅ Uses TypeScript throughout
- ✅ Documentation format is consistent with existing docs
- ✅ Follows the monorepo structure

### Summary of Recommendations

**Must fix:**
- [ ] Remove the empty code block at apps/docs/ai-sdk/overview.mdx:48-49

**Should consider:**
- [ ] Verify `gpt-5` vs `gpt-4` model naming
- [ ] Add test coverage for `addMemory: "always"` functionality
- [ ] Document performance/cost implications in the note

**Nice to have:**
- [ ] Add guidance on when to enable automatic memory saving
- [ ] Link to more detailed memory management docs

### Overall Assessment

This is a valuable documentation addition that fills an important gap. The `addMemory` feature is powerful but was previously undocumented in user-facing docs, which could lead to confusion. With the minor fixes above, this will greatly improve the developer experience.

**Recommendation:** Approve with minor changes requested.

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