Version management
The chatbot uses semantic versioning and follows the AI SDK’s release cycle. Major changes are coordinated with AI SDK updates.Always review the changelog and test upgrades in a development environment before deploying to production.
Upgrade checklist
Update dependencies
Update your package.json dependencies to the latest versions:Pay special attention to these core dependencies:
ai- The AI SDKnext- Next.js frameworkdrizzle-orm- Database ORM@vercel/functions- Vercel runtime utilities
Review breaking changes
Check the release notes for breaking changes. Common areas that may require updates:
- Database schema changes
- API route signatures
- Environment variable names
- AI SDK streaming API changes
- Tool definition structures
Run database migrations
Apply any new database migrations:This ensures your database schema matches the latest version.
Major version migrations
Message parts migration
One of the most significant changes is the migration from content-based to parts-based messages. See the message parts migration guide for detailed instructions.AI SDK v4 changes
The chatbot uses AI SDK v4, which introduced several breaking changes:Tool approval flow
Tool approval flow
Tools now support a
needsApproval flag for requiring user confirmation:lib/ai/tools/get-weather.ts
Streaming updates
Streaming updates
The streaming API now uses
createUIMessageStream for better control:app/(chat)/api/chat/route.ts
Database schema evolution
The database schema evolves over time. Here’s how to handle schema changes:Adding new fields
When new fields are added to existing tables:Creating new tables
New features may introduce new tables like theStream table for resumable streams:
lib/db/schema.ts
Configuration updates
Model provider changes
As new AI providers are added, update your model configuration:Rate limiting adjustments
Rate limits can be adjusted based on user type:lib/ai/entitlements.ts
API changes
Request validation
API routes now use Zod schemas for request validation:Error handling
The error handling system uses typed error codes:lib/errors.ts
Common upgrade issues
Type errors after upgrade
Type errors after upgrade
If you encounter TypeScript errors after upgrading:
- Clear your build cache:
rm -rf .next - Reinstall dependencies:
rm -rf node_modules && pnpm install - Restart your TypeScript server in your editor
- Check for breaking changes in the AI SDK changelog
Database connection errors
Database connection errors
If database queries fail after migration:
- Verify
POSTGRES_URLis set correctly - Run migrations:
pnpm db:migrate - Check that new tables were created
- Verify foreign key relationships are intact
Streaming not working
Streaming not working
If streaming responses break:
- Check that you’re using
createUIMessageStream - Verify
maxDurationis set on API routes - Ensure
toUIMessageStream()is called on the result - Check that data stream is properly merged
Rollback strategy
If you need to rollback an upgrade:Next steps
- Review the message parts migration guide
- Learn about rate limiting configuration
- Explore streaming implementation details
- Check out building AI tools for custom functionality