feat: add vercel-ai-sdk.mdc rule to prevent v6 hallucinations#2727
feat: add vercel-ai-sdk.mdc rule to prevent v6 hallucinations#2727cubaseuser123 wants to merge 1 commit intogiselles-ai:mainfrom
Conversation
|
@cubaseuser123 is attempting to deploy a commit to the Giselle Team on Vercel. A member of the Team first needs to authorize it. |
|
Finished running flow.
|
||||||||||||||||||
|
Review Summary by QodoAdd Vercel AI SDK v6 Cursor rule to prevent common hallucinations
WalkthroughsDescription• Adds comprehensive Cursor rule for Vercel AI SDK v6 patterns • Documents 7 common API hallucinations with correct/incorrect examples • Includes official documentation links for each pattern • Provides canonical Route Handler template for reference Diagramflowchart LR
A["Vercel AI SDK v6<br/>Common Hallucinations"] -->|toolContext| B["experimental_context"]
A -->|generateObject| C["Output.object()"]
A -->|parameters| D["inputSchema"]
A -->|Zod.strict()| E["tool strict option"]
A -->|toDataStreamResponse| F["toUIMessageStreamResponse"]
A -->|maxSteps| G["stopWhen: stepCountIs"]
A -->|Raw messages| H["UIMessage + conversion"]
B --> I["Cursor Rule<br/>vercel-ai-sdk.mdc"]
C --> I
D --> I
E --> I
F --> I
G --> I
H --> I
File Changes1. .cursor/rules/vercel-ai-sdk.mdc
|
📝 WalkthroughWalkthroughA new documentation file introducing Vercel AI SDK v6 patterns and guidelines is added to the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 QA Testing Assistant by Giselle📋 Manual QA ChecklistBased on the changes in this PR, here are the key areas to test manually:
✨ Prompt for AI AgentsUse the following prompts with Cursor or Claude Code to automate E2E testing: 📝 E2E Test Generation Prompt |
Code Review by Qodo
1. v6 rule vs repo ai@5
|
| --- | ||
| description: Vercel AI SDK v6 patterns — prevents common hallucinations of legacy APIs | ||
| globs: *.tsx,*.ts | ||
| alwaysApply: false |
There was a problem hiding this comment.
1. V6 rule vs repo ai@5 🐞 Bug ✓ Correctness
The rule is labeled as “Vercel AI SDK v6 patterns” and applies to all *.ts/*.tsx, but the repo catalog pins ai to 5.0.101; this can drive agents to generate APIs/patterns that may not exist in the installed SDK, leading to compilation/runtime failures when code is added based on this rule.
Agent Prompt
## Issue description
The new Cursor rule is presented as “Vercel AI SDK v6 patterns” but the repo pins `ai` to 5.0.101. Since the rule’s `globs` cover all TS/TSX files, agents may generate code using APIs/patterns that don’t exist for the repo’s installed SDK version, causing compile/runtime errors.
## Issue Context
Cursor rules influence generated code. If the rule is version-specific, it should either be scoped to the relevant code areas or clearly gated by the dependency version.
## Fix Focus Areas
- .cursor/rules/vercel-ai-sdk.mdc[1-12]
- pnpm-workspace.yaml[52-60]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
shige
left a comment
There was a problem hiding this comment.
Thanks for the contribution! Preventing AI SDK hallucinations is a great idea — we've definitely seen agents generate outdated patterns. However, there are a few issues that need to be addressed before we can merge this.
1. Version mismatch: our project is on AI SDK v5, not v6
We currently pin ai: 5.0.101 in pnpm-workspace.yaml. Several patterns in this rule are v6-specific and would be incorrect guidance for our codebase:
generateObject→Output.object():generateObjectis still valid in v5maxSteps→stopWhen: stepCountIs(N):maxStepsis the correct option in v5toDataStreamResponse()→toUIMessageStreamResponse(): our codebase actually usestoUIMessageStream()(neither of the two options listed)
Could you verify each pattern against v5 and adjust accordingly?
2. Code style: single quotes → double quotes
Our project uses Biome with double quotes as the standard. All code examples in the rule use single quotes, which would cause agents to generate code that fails our formatter. Please update all examples to use double quotes.
3. Overly broad glob scope
globs: *.tsx,*.ts applies this rule to every TypeScript file, including UI components, tests, and database schemas that never touch the AI SDK. Consider narrowing the glob to relevant directories (e.g., packages/giselle/src/generations/**) or removing it so the rule is only triggered manually.
4. Canonical example doesn't match project patterns
The route handler example uses model: 'anthropic/claude-sonnet-4.5' as a raw string, but we use a language model registry pattern. This could steer agents away from our established conventions.
5. Relationship with existing update-ai-sdk.mdc
We already have .cursor/rules/update-ai-sdk.mdc. Could you clarify how these two rules relate? It might make sense to merge them or clearly differentiate their purposes.
Summary
I started using the Vercel AI SDK when version 6 was released. I've noticed that when I ask an agent (Cursor, Antigravity, Claude) to write code, it often defaults to version 4 or 5 patterns.
These agents frequently confuse
toolContextwithexperimental_context, use the wronggenerateObjectsyntax, and getexecutesignatures wrong.To address this, I created a Cursor rule that teaches agents how to avoid these hallucinations. This approach completely stopped the errors for me.
Related Issue
vercel-labs/agent-skills#133
Changes
Added
.cursor/rules/vercel-ai-sdk.mdc— a companion to the existingupdate-ai-sdk.mdcthat focuses on writing correct v6 code. It covers 7 hallucination-prone API changes:toolContext→experimental_contextgenerateObject→Output.object()(Legacy)parameters→inputSchema.strict()on Zod →strict: trueon tooltoDataStreamResponse()→toUIMessageStreamResponse()maxSteps→stopWhen: stepCountIs(N)UIMessage+convertToModelMessages()All patterns are sourced from official Vercel AI SDK docs.
Testing
N/A — documentation-only change, no runtime code affected.
Other Information
Every code example includes a ✅ CORRECT / ❌ WRONG comparison with links to official docs. A canonical Route Handler reference is included at the end as a quick-copy template.
Summary by CodeRabbit