-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test(ai-sdk): streamText and generateText for ai sdk #451
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
base: main
Are you sure you want to change the base?
test(ai-sdk): streamText and generateText for ai sdk #451
Conversation
Deploying with
|
Status | Name | Latest Commit | Updated (UTC) |
---|---|---|---|
✅ Deployment successful! View logs |
supermemory-app | 573c00f | Oct 04 2025, 01:24 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. |
PR Review: AI SDK Integration Tests🟢 Strengths
🔴 Critical Issues1. Circular Dependency (packages/tools/package.json:19)"@supermemory/tools": "^1.1.12" ❌ The package depends on itself. This will cause installation failures and build issues. Fix: Remove this dependency entirely. 2. Trailing Comma Syntax Error (packages/tools/package.json:14)"test:local": "vitest --env-file .env.local", ❌ Trailing comma after last object property will cause JSON parsing errors. Fix: Remove the comma after 3. Invalid .env Format (packages/tools/.env.example:1-9)SUPERMEMORY_API_KEY="your_supermemory_api_key_here",
TEST_TIMEOUT=30000,
// Test timeouts (in milliseconds) ❌ Issues:
Fix: # Supermemory Configuration
SUPERMEMORY_API_KEY=your_supermemory_api_key_here
SUPERMEMORY_PROJECT_ID=sm_project_default
# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here
# Test Configuration
TEST_MODEL=gpt-4o-mini
# Test timeouts (in milliseconds)
TEST_TIMEOUT=30000 🟡 Code Quality Issues4. Console.log in Production Code (test/ai-sdk.test.ts:16)console.log("SUPERMEMORY_API_KEY", SUPERMEMORY_API_KEY) Fix: Remove this line entirely. 5. Fragile Test Assertions (test/ai-sdk.test.ts:42-46)expect(
result.toolResults.some((tool) =>
JSON.stringify(tool.output).includes("pineapple"),
),
).toBe(true) Fix: Either set up test data in a 6. Incomplete Stream Test (test/ai-sdk.test.ts:71)The stream test should verify text was actually streamed and tools were invoked. 7. Test Interdependency (test/ai-sdk.test.ts:78-110 & 112-132)🟣 Performance & Best Practices8. Hardcoded Timeout in Test Config (vitest.config.ts:7)The package.json removed explicit timeouts but vitest.config.ts still has a 100s default. Individual tests use 30s. This inconsistency is confusing. 9. Redundant Type Assertion (test/ai-sdk.test.ts:29)Already validated in 10. Missing Test CleanupRecommendation: Add 🎯 SummaryMust Fix Before Merge:
Should Fix: Nice to Have: Overall, this is a solid addition of integration tests, but the critical issues (especially the circular dependency and syntax errors) will prevent the code from working. Once those are fixed, this will be a valuable addition to the test suite. 🤖 Generated with Claude Code |
PR Review: AI SDK Integration TestsOverviewThis PR adds comprehensive integration tests for the AI SDK tools with good environment configuration support. The tests validate both ✅ Strengths
🐛 Issues & ConcernsCritical Issues
Code Quality Issues
Testing Best Practices
Performance Considerations
🔒 Security
📝 Recommendations
Convention Compliance✅ Follows Biome formatting (tabs, double quotes, semicolons as needed) |
Pull Request Review: AI SDK Integration TestsOverall AssessmentGood work adding comprehensive integration tests for the AI SDK! The test suite covers the main functionality well. Below are some suggestions for improvement across code quality, bugs, performance, security, and test coverage. 🟡 Code Quality & Best Practices1. Environment Configuration IssuesFile: - TEST_TIMEOUT=30000,
+ TEST_TIMEOUT=30000
2. Hard-coded Test AssertionsFile: expect(
result.toolResults.some((tool) =>
JSON.stringify(tool.output).includes("pineapple"),
),
).toBe(true)
3. Package.json Script CleanupFile: The PR removes the
4. Inconsistent Timeout Values
🔴 Potential Bugs1. Missing Await in Stream TestFile: const finalResult = streamResult
2. Weak AssertionsFile: expect(streamedText).toBeDefined()
expect(finalResult.text).toBeDefined()
expect(finalResult.toolResults).toBeDefined()
3. Flaky Test DependenciesFile: Tests depend on previous tests having populated memories:
⚡ Performance Considerations1. Timeout Management
2. Sequential Test Execution
🔒 Security Concerns1. API Key Exposure RiskFile: SUPERMEMORY_API_KEY="your_supermemory_api_key_here"
OPENAI_API_KEY= "your_openai_api_key_here"
2. Test Data Persistence
🧪 Test Coverage✅ Well Covered
|
Pull Request Review: AI SDK Integration TestsThank you for adding comprehensive integration tests for the AI SDK! This is a valuable addition to the codebase. Here's my detailed review: ✅ Strengths
🐛 Issues FoundCritical Issues
Configuration Issues
🔧 Code Quality Issues
📊 Test Coverage Gaps
🏗️ Architecture Concerns
🔒 Security Considerations
🎯 RecommendationsHigh Priority:
Medium Priority: Low Priority: 📝 Suggested Changes// ai-sdk.test.ts improvements
describe("Supermemory AI SDK Integration Tests", () => {
const SUPERMEMORY_API_KEY = process.env.SUPERMEMORY_API_KEY
const OPENAI_API_KEY = process.env.OPENAI_API_KEY
const PROJECT_ID = process.env.SUPERMEMORY_PROJECT_ID || `test_${Date.now()}`
const MODEL = process.env.TEST_MODEL || "gpt-4o-mini"
const TEST_TIMEOUT = Number(process.env.TEST_TIMEOUT) || 30000
beforeAll(() => {
if (!SUPERMEMORY_API_KEY) {
throw new Error("SUPERMEMORY_API_KEY environment variable is required")
}
if (!OPENAI_API_KEY) {
throw new Error("OPENAI_API_KEY environment variable is required")
}
})
it("should generate text with supermemory tools", async () => {
const result = await generateText({
model: openai(MODEL),
messages: [
{ role: "user", content: "What do you remember about my preferences?" },
],
tools: {
...supermemoryTools(SUPERMEMORY_API_KEY, {
containerTags: [PROJECT_ID],
}),
},
})
expect(result).toBeDefined()
expect(result.content).toBeDefined()
expect(result.toolResults).toBeDefined()
expect(Array.isArray(result.toolResults)).toBe(true)
// Check that tools were actually invoked
if (result.toolResults.length > 0) {
expect(result.toolResults[0]).toHaveProperty('toolName')
}
}, TEST_TIMEOUT)
}) Overall AssessmentScore: 7/10 This PR adds valuable test coverage, but needs refinement around configuration consistency and test reliability. The tests are well-structured but have some brittleness issues that should be addressed before merging. Great work on getting integration tests in place! Once the critical issues are addressed, this will be a solid addition to the codebase. 🚀 |
Added AI SDK integration tests for Supermemory tools with environment configuration support.
What changed?
.env.example
file with configuration for Supermemory and OpenAI API keys@supermemory/tools
dependency to package.jsonai-sdk.test.ts