Skip to content

Conversation

@dancer
Copy link
Contributor

@dancer dancer commented Dec 19, 2025

summary

upgrades project to ai sdk v6 beta and adds tool approval for the weather tool

changes

ai sdk v6 beta upgrade

updated all ai sdk packages to v6 beta versions:

  • ai: 6.0.0-beta.x
  • @ai-sdk/react: 3.0.0-beta.x
  • @ai-sdk/provider: 3.0.0-beta.x
  • @ai-sdk/gateway: 2.0.0-beta.x

tool approval for weather

lib/ai/tools/get-weather.ts

  • added needsApproval: true

components/message.tsx

  • handles tool-getWeather parts with approval ui
  • deny/allow buttons when approval requested
  • denied message when user denies
  • weather widget on success
  • all states use consistent w-[min(100%,450px)] width
  • fixed memo function that was always returning false (caused unnecessary rerenders)
  • w-full now applied when message has tool parts (not just text)

components/chat.tsx

  • sendAutomaticallyWhen auto-continues only for approved tools
  • denied tools don't auto-continue (prevents stuck loading state)
  • prepareSendMessagesRequest sends all messages when tool approval states detected

components/messages.tsx & components/artifact-messages.tsx

  • suppresses thinking indicator when tool is in approval-responded state
  • threaded addToolApprovalResponse prop through to PreviewMessage

components/artifact.tsx

  • added addToolApprovalResponse prop

app/(chat)/api/chat/schema.ts

  • added messages array for tool approval continuation flows

app/(chat)/api/chat/route.ts

  • handles tool approval flow (receives all messages)
  • passes originalMessages to createUIMessageStream for continuation
  • re-enabled resumable stream with graceful fallback
  • onFinish updates existing messages when tool state changes

lib/db/queries.ts

  • added updateMessage() function

components/document-preview.tsx

  • uses w-full max-w-[450px] for consistency

how it works

approval flow

  1. user asks "what's the weather in san francisco?"
  2. tool approval prompt appears with deny/allow buttons
  3. user clicks allow
  4. sendAutomaticallyWhen triggers (detects approval-responded with approved: true)
  5. request sent to server → tool executes → weather widget appears
  6. state saved to database

denial flow

  1. user asks "what's the weather in san francisco?"
  2. tool approval prompt appears with deny/allow buttons
  3. user clicks deny
  4. denied message appears locally
  5. user can immediately send new messages
  6. when user sends next message, all messages sent to server with denial context
  7. model responds appropriately understanding what was denied

testing

  1. ask "what's the weather in san francisco?"
  2. test approval: click "allow" → weather widget should appear
  3. test denial: click "deny" → denied message appears → can send new message
  4. test persistence: refresh page → state should persist
  5. test context: after denial, ask to retry → model should understand what was denied
  6. test artifact panel: click a note → chat should resize correctly (responsive width)

@vercel
Copy link
Contributor

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
ai-chatbot Ready Ready Preview, Comment Dec 19, 2025 9:19pm
chatbot_benchmarking Ready Ready Preview, Comment Dec 19, 2025 9:19pm
v0-v0-ai-chatbot Ready Ready Preview, Comment Dec 19, 2025 9:19pm
v0-vercel-ai-chatbot Ready Ready Preview, Comment Dec 19, 2025 9:19pm

@socket-security
Copy link

socket-security bot commented Dec 19, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​ai-sdk/​react@​2.0.109 ⏵ 3.0.0-beta.16299 +11007398100
Updated@​ai-sdk/​provider@​2.0.0 ⏵ 3.0.0-beta.2710010073 +197 -1100
Updated@​ai-sdk/​gateway@​2.0.18 ⏵ 2.0.0-beta.85100 +11008398100
Updatedai@​5.0.108 ⏵ 6.0.0-beta.159100 +1100100100 +1100

View full report

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The migration script throws an error when POSTGRES_URL is not defined, halting the build process. In CI/build environments where database credentials aren't configured, migrations should be gracefully skipped instead of failing.

Fix on Vercel

@dancer dancer merged commit 4d3ba8d into main Dec 19, 2025
8 checks passed
@dancer dancer deleted the josh/merrychristmas branch December 19, 2025 23:24
ababich added a commit to octoo-tech/vercel-ai that referenced this pull request Dec 20, 2025
Merged commits:
- fix dialog animations, mobile input ux, and tool descriptions (vercel#1362)
- ai sdk v6 beta + tool approval (vercel#1361)

Resolved conflicts:
- Kept PostgreSQL resumable streams in api/chat/route.ts
- Removed unused auth import from chat/page.tsx
DavideGCosta added a commit to DavideGCosta/ai-chatbot that referenced this pull request Jan 1, 2026
DavideGCosta added a commit to DavideGCosta/ai-chatbot that referenced this pull request Jan 1, 2026
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