Skip to content

Conversation

@Dhravya
Copy link
Member

@Dhravya Dhravya commented Jan 9, 2026

Added comprehensive documentation for the new promptTemplate option in the AI SDK, which allows developers to customize how memories are formatted and injected into system prompts. This includes examples for XML-based prompting (Claude), custom branding, and the MemoryPromptData interface.

Files Changed

  • apps/docs/ai-sdk/user-profiles.mdx - Added "Custom Prompt Templates" section with examples and interface documentation
  • apps/docs/ai-sdk/overview.mdx - Updated User Profiles section to mention customization capabilities

Generated from feat: allow prompt template for @supermemory/tools package @MaheshtheDev

@claude
Copy link

claude bot commented Jan 9, 2026

Pull Request Review: Document promptTemplate feature for AI SDK

Summary

This PR adds documentation for the new promptTemplate feature that was implemented in PR #655. The documentation is well-structured and comprehensive, covering multiple use cases with clear examples.

✅ Strengths

1. Excellent Documentation Structure

  • Clear progression from basic to advanced usage
  • Well-organized sections with logical flow
  • Multiple practical examples for different scenarios

2. Comprehensive Coverage

  • Documents the MemoryPromptData interface thoroughly
  • Provides XML-based prompting example (valuable for Claude users)
  • Includes custom branding example
  • Shows default template for reference

3. Code Quality

  • Examples match the actual implementation (verified against source code)
  • TypeScript types are correctly imported and used
  • Code is consistent with the rest of the documentation

4. Accurate Technical Details

  • Correctly describes userMemories as "pre-formatted markdown combining static profile facts and dynamic context"
  • Accurately explains generalSearchMemories behavior (empty string when mode is "profile")
  • Default template matches implementation in memory-prompt.ts:46-47

🔍 Areas for Improvement

1. Minor Consistency Issue

In apps/docs/ai-sdk/user-profiles.mdx:176, the example uses:

const model = withSupermemory(anthropic("claude-3-sonnet"), "user-123", {

However, the anthropic import is not shown. Consider adding:

import { anthropic } from "@ai-sdk/anthropic"

at the top of this example for consistency with other examples.

2. Test Coverage Consideration

No tests were found for the promptTemplate functionality in this PR (which is appropriate for a docs-only PR). However, it would be beneficial to verify that:

Note: This is not a blocker for this PR since it's documentation-only.

3. Potential Enhancement

Consider adding a note about:

  • Maximum length considerations for custom templates (if any API limits apply)
  • Whether HTML/special characters need escaping in custom templates
  • Performance implications of very long custom templates

🔒 Security Review

No security concerns identified

  • Documentation only, no code changes
  • Examples follow secure patterns
  • No exposure of sensitive data

📊 Performance Considerations

No performance impact

  • Documentation changes have no runtime performance impact
  • Examples demonstrate efficient patterns

🎯 Best Practices Alignment

Follows Repository Standards

  • ✅ Consistent with existing documentation style
  • ✅ Uses TypeScript throughout
  • ✅ Follows the Mintlify documentation format
  • ✅ Uses proper code fencing and syntax highlighting

Adheres to CLAUDE.md Guidelines

  • ✅ Documentation is placed in the correct location (apps/docs/)
  • ✅ Examples use the repository's tech stack (TypeScript, AI SDK)
  • ✅ Follows the monorepo structure conventions

📝 Specific Line-by-Line Review

apps/docs/ai-sdk/overview.mdx (Line 21)

✅ Clear, concise addition that teases the new feature without overwhelming the overview

apps/docs/ai-sdk/user-profiles.mdx (Lines 120-211)

✅ Comprehensive new section with excellent examples

Verified Against Implementation:

  • Line 129: type MemoryPromptData import matches packages/tools/src/vercel/index.ts:13
  • Lines 153-156: Interface description matches packages/tools/src/vercel/memory-prompt.ts:12-24
  • Lines 209-210: Default template matches packages/tools/src/vercel/memory-prompt.ts:46-47

🎉 Conclusion

Recommendation: APPROVE ✅

This is a high-quality documentation PR that accurately documents the new promptTemplate feature. The examples are practical, the explanations are clear, and the technical details match the implementation.

Minor Suggestion

Add the missing import in the Claude example (line 176), but this is not a blocking issue.

Great work on documenting this feature! The examples will be very helpful for developers who want to customize prompt formatting for different LLM providers or branding needs.


Generated with assistance from Claude Sonnet 4.5

Copy link
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.

lgtm

@graphite-app
Copy link

graphite-app bot commented Jan 9, 2026

Merge activity

Added comprehensive documentation for the new `promptTemplate` option in the AI SDK, which allows developers to customize how memories are formatted and injected into system prompts. This includes examples for XML-based prompting (Claude), custom branding, and the `MemoryPromptData` interface.

## Files Changed
- `apps/docs/ai-sdk/user-profiles.mdx` - Added "Custom Prompt Templates" section with examples and interface documentation
- `apps/docs/ai-sdk/overview.mdx` - Updated User Profiles section to mention customization capabilities

Generated from [feat: allow prompt template for @supermemory/tools package](#655) @MaheshtheDev
@graphite-app graphite-app bot force-pushed the mintlify/docs-ai-sdk-prompt-template-98176 branch from 385ef96 to 2dfadd3 Compare January 9, 2026 02:40
@graphite-app graphite-app bot merged commit 2dfadd3 into main Jan 9, 2026
6 checks passed
@claude
Copy link

claude bot commented Jan 9, 2026

Pull Request Review: Document promptTemplate Feature for AI SDK

Thank you for documenting the new promptTemplate feature! This is a valuable addition that gives developers flexibility in how memories are injected. Here is my comprehensive review:


Strengths

1. Excellent Documentation Structure

  • Clear progression from basic usage to advanced examples
  • Well-organized sections with descriptive headings
  • Good use of code examples demonstrating real-world use cases

2. Comprehensive Coverage

  • Documents the MemoryPromptData interface clearly
  • Provides multiple template examples (XML, custom branding, default)
  • Explains the motivation for each use case

3. Code Quality

The underlying implementation (from PR #655) is solid:

  • Type-safe with proper TypeScript interfaces
  • Clean separation of concerns (memory-prompt.ts)
  • Good use of JSDoc comments

Observations & Suggestions

1. Import Statement Inconsistency

Location: apps/docs/ai-sdk/user-profiles.mdx:129

The first example includes the type import, but later examples (lines 163, 187) omit it.

  • Suggestion: Either include the import in all examples or add a note that it is only needed when explicitly typing the function parameter

2. Missing Import in Claude Example

Location: apps/docs/ai-sdk/user-profiles.mdx:176

The Claude example uses anthropic() but does not show the import statement.
Suggestion: Add the missing import for completeness

3. Template String Formatting

All examples use .trim() which is good practice.
Suggestion: Add a brief note explaining that .trim() removes leading/trailing whitespace to avoid unnecessary tokens

4. Empty String Handling

Location: packages/tools/src/vercel/memory-prompt.ts:178-179

When mode is not profile, empty search results will still produce a "Search results" header.

  • Suggestion: Consider adding conditional logic to omit the section entirely when there are no results, or document this behavior

5. Error Handling Documentation

The documentation does not mention what happens if:

  • The API call fails
  • No memories are found
  • The promptTemplate function throws an error

Suggestion: Add a brief troubleshooting section or mention error handling behavior

6. Performance Considerations

The promptTemplate function is called synchronously in the request path.
Suggestion: Document that the template function should be lightweight and avoid async operations or heavy computation


Security Considerations

Good Practices:

  1. User-provided template functions are executed in the same context, which is acceptable since this is a developer-facing API
  2. No direct string interpolation into system prompts from user input
  3. Memory content is pre-formatted before reaching the template

Minor Consideration:

If a developer accidentally includes user input in their custom template without sanitization, they could create prompt injection vulnerabilities.

Suggestion: Add a security warning in the docs about not interpolating unsanitized user input into custom templates


Test Coverage

Observation: I checked the test files in packages/tools/test/ and did not see specific tests for the promptTemplate functionality.

Suggestion: Consider adding tests to verify:

  1. Custom template functions are called with correct MemoryPromptData
  2. The default template behaves as expected
  3. Empty memories are handled gracefully
  4. Template output is properly injected into system prompts

Documentation Best Practices

Follows Repository Conventions:

  • Consistent with other AI SDK docs
  • Uses proper MDX formatting
  • Includes code examples with proper syntax highlighting

Minor Enhancements:

  1. Consider adding version information about when this feature was introduced
  2. The Custom Prompt Templates section is substantial - consider if it should be promoted in navigation
  3. If you have a documentation playground, this feature would benefit from an interactive example

Summary

Overall Assessment: Excellent

This PR successfully documents a powerful new feature with clear, practical examples. The code quality is solid, and the documentation is comprehensive.

Action Items (Priority Order):

High Priority:

  1. Add missing anthropic import in Claude example
  2. Standardize import statements across all examples

Medium Priority:
3. Add security warning about user input sanitization
4. Explain why .trim() is used in templates
5. Add unit tests for promptTemplate functionality

Low Priority:
6. Consider adding version information
7. Document empty search results behavior
8. Add troubleshooting section for common issues


Approval Recommendation

This PR is ready to merge with minor improvements suggested above. The documentation is clear, accurate, and provides real value to developers. The underlying implementation (from PR #655) is well-designed and type-safe.

Great work on giving developers more control over memory injection!


Review generated by Claude Code following CLAUDE.md conventions

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.

3 participants