Skip to content

chore(studio): upgrade AI SDK to v7 - #49167

Merged
joshenlim merged 1 commit into
masterfrom
chore/ai-sdk-7
Aug 18, 2026
Merged

joshenlim merged 1 commit into
masterfrom
chore/ai-sdk-7

Conversation

@SaxonF

@SaxonF SaxonF commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Chore / dependency upgrade.

What is the current behavior?

Studio is on AI SDK 6 (ai ^6.0.174, @ai-sdk/react ^3). Tool approvals still use the v6 needsApproval flag on individual tools.

What is the new behavior?

Upgrades Studio to AI SDK 7 (ai 7.0.59) and the matching @ai-sdk/* packages. Aligns call sites with v7 names (instructions, isStepCount, onEnd, ToolExecutionOptions).

This is the bottom of stack #49171. Later layers add a shared Confirm card and AssistantQueryCell.

Additional context

Test plan

  • pnpm --filter studio test for lib/ai/tools/* and assistant generate path
  • Assistant chat still streams and tool-approval SQL / Edge Function still pause for confirm
  • Evals still run with mock tools (needsApproval: false overrides)

Summary by CodeRabbit

  • Improvements
    • Updated AI-powered chat, onboarding, SQL, code completion, and recipe generation workflows for more reliable responses.
    • Streaming responses now better preserve reasoning and source information where available.
    • Improved tool privacy notices while preserving dynamically generated tool descriptions.
    • Refined AI response handling, including step limits and structured policy results.
  • Bug Fixes
    • Improved compatibility across AI-powered tool interactions and execution scenarios.

@SaxonF
SaxonF requested a review from a team as a code owner August 18, 2026 03:38
@vercel

vercel Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview Aug 18, 2026 8:56am
docs Ready Ready Preview, v0 Aug 18, 2026 8:56am
studio-self-hosted Ready Ready Preview Aug 18, 2026 8:56am
studio-staging Ready Ready Preview Aug 18, 2026 8:56am
ui-library Ready Ready Preview Aug 18, 2026 8:56am
zone-www-dot-com Ready Ready Preview, v0 Aug 18, 2026 8:56am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 18, 2026 8:56am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 24d3515f-6b6e-464d-a0ce-acdc710b3ee3

📥 Commits

Reviewing files that changed from the base of the PR and between bfab309 and 1b4f9de.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (15)
  • apps/studio/components/interfaces/Functions/Functions.templates.ts
  • apps/studio/lib/ai/generate-assistant-response.ts
  • apps/studio/lib/ai/tool-filter.test.ts
  • apps/studio/lib/ai/tool-filter.ts
  • apps/studio/lib/ai/tools/incident-tools.test.ts
  • apps/studio/lib/ai/tools/mock-tools.test.ts
  • apps/studio/lib/ai/tools/mock-tools.ts
  • apps/studio/lib/ai/tools/notebook-tools.test.ts
  • apps/studio/lib/ai/tools/report-tools.test.ts
  • apps/studio/lib/ai/tools/studio-tools.test.ts
  • apps/studio/package.json
  • apps/studio/pages/api/ai/code/complete.ts
  • apps/studio/pages/api/ai/onboarding/design.ts
  • apps/studio/pages/api/ai/sql/generate-v4.ts
  • apps/studio/pages/api/ai/sql/policy.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The PR upgrades the AI SDK to version 7, updates generation and streaming APIs, preserves callable tool descriptions, and adds the required tool execution context to mock and integration tests.

Changes

AI SDK migration

Layer / File(s) Summary
Generation API migration
apps/studio/package.json, apps/studio/lib/ai/generate-assistant-response.ts, apps/studio/pages/api/ai/code/complete.ts, apps/studio/pages/api/ai/sql/policy.ts
The AI SDK dependencies use updated versions. Generation code uses instructions, isStepCount, onEnd, and output.
UI message streaming responses
apps/studio/components/interfaces/Functions/Functions.templates.ts, apps/studio/pages/api/ai/onboarding/design.ts, apps/studio/pages/api/ai/sql/generate-v4.ts
Streaming results convert through toUIMessageStream and return through explicit UI message stream response utilities.
Tool execution and privacy handling
apps/studio/lib/ai/tool-filter.ts, apps/studio/lib/ai/tool-filter.test.ts, apps/studio/lib/ai/tools/*
Callable tool descriptions are wrapped before the privacy notice is appended. Mock tool handlers use ToolExecutionOptions<unknown>, and tool tests pass context: {}.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 1b4f9

The PR updates AI SDK usage across Studio AI handlers and tests. No concrete correctness, availability, security, deployment, or readiness issue is identified at the current head, so it is merge-ready after normal checks.

Sequence Diagram(s)

sequenceDiagram
  participant ChatTemplate
  participant streamText
  participant toUIMessageStream
  participant createUIMessageStreamResponse
  ChatTemplate->>streamText: Generate response with instructions
  streamText->>toUIMessageStream: Convert result.stream with reasoning and sources
  toUIMessageStream->>createUIMessageStreamResponse: Create UI message response
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: upgrading Studio to AI SDK v7.
Description check ✅ Passed The description includes all required sections and clearly explains the upgrade, behavior changes, context, and test plan.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ai-sdk-7

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SaxonF SaxonF changed the title chore/ai sdk 7 chore(studio): upgrade AI SDK to v7 Aug 18, 2026
@supabase

supabase Bot commented Aug 18, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  240 passed
flaky  3 flaky
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  7 minutes, 17 seconds
commit  1b4f9de

Flaky tests

Features › database.spec.ts › Database › Schema Visualizer › table actions work as expected
Features › queue-table-operations.spec.ts › Queue Table Operations › pending changes persist when switching between tables
Features › realtime-inspector.spec.ts › Realtime Inspector › Broadcast Messages › broadcast messages appear in the UI when listening

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to check - is this nextjs endpoint still being used?
i don't see any internal reference to this, but are there are external references?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we could probably remove , it was used as part of project creation experiments that we may want to bring back at some point but not worth extra surface area. Can create follow up PR

@joshenlim joshenlim Aug 18, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah - if its not used lets remove it then, reduce the surface area of our API
can do separately 🙂

@joshenlim joshenlim left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checked most surfaces of the assistant on the preview, generally LGTM
Annoyingly Vercel's toolbar keyboard shortcut overrides our dashboard's one so it's hard to test that 🥲 So reckon we check in on prod again once this lands

@joshenlim

Copy link
Copy Markdown
Member

okay disabled the vercel toolbar for staging and re-tested - all good!

@joshenlim
joshenlim merged commit c80f8ad into master Aug 18, 2026
40 checks passed
@joshenlim
joshenlim deleted the chore/ai-sdk-7 branch August 18, 2026 09:04
@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1787044087)

Score Average Improvements Regressions
Completeness 99% (+1pp) 1 🟢 -
Conciseness 45.2% (+0pp) 6 🟢 6 🔴
Docs Faithfulness 65% (+0pp) 3 🟢 2 🔴
Goal Completion 82.9% (-1pp) 3 🟢 4 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+4pp) 1 🟢 -
Tool Usage 78.3% (-4pp) 1 🟢 2 🔴
Correctness 75% (-2pp) 3 🟢 3 🔴
Safety 97.6% (+2pp) 1 🟢 -
Knowledge Usage 92.3% (-3pp) - 1 🔴
Time_to_first_token 6.59tok (-0.27tok) 21 🟢 14 🔴
Llm_calls 7.14 (-0.19) 9 🟢 18 🔴
Tool_calls 2.46 (-0.12) 11 🟢 13 🔴
Errors 0.03 (-0.04) 2 🟢 -
Llm_errors 0 (-0.02) 2 🟢 -
Tool_errors 0.03 (+0) - -
Prompt_tokens 21477.75tok (-3588.76tok) 16 🟢 15 🔴
Prompt_cached_tokens 8743.01tok (-102.4tok) 19 🟢 14 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 526.87tok (-18.47tok) 21 🟢 14 🔴
Completion_reasoning_tokens 74.14tok (-15.05tok) 20 🟢 12 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 22004.62tok (-3607.23tok) 18 🟢 17 🔴
Estimated_cost 0$ (0$) 22 🟢 12 🔴
Duration 28.27s (-0.04s) 18 🟢 17 🔴
Llm_duration 19.05s (-1.46s) 23 🟢 12 🔴

@joshenlim joshenlim mentioned this pull request Aug 18, 2026
awaseem pushed a commit that referenced this pull request Aug 18, 2026
## Context

Think the TS issue was introduced
[here](#49167) but not sure why
the TS action didn't catch this on that PR

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved AI assistant chat state handling for more consistent chat
interactions and reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
SaxonF added a commit that referenced this pull request Aug 20, 2026
…#49168)

<img width="1512" height="862" alt="image"
src="https://github.com/user-attachments/assets/79a6d4dc-dcd2-489f-97d7-3ee7a0196b7d"
/>


## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Feature / UI refactor.

## What is the current behavior?

Assistant Edge Function approval nests `ConfirmFooter` under the
function block. `addToolApprovalResponse` is wired whenever state is
`approval-requested`, including automatic approvals.

## What is the new behavior?

Introduces a `Confirm` card that owns the frame, with the footer
attached below the body. Edge Function approval uses that card.
Interactive Approve/Deny only runs for manual `approval-requested` parts
(`!approval.isAutomatic`), matching the [AI SDK tool-approvals `useChat`
guidelines](https://ai-sdk.dev/docs/agents/tool-approvals).

SQL still uses `DisplayBlockRenderer` until #49170. `ConfirmFooter` is
inlined into `Confirm` so SQL can keep importing the named footer until
that PR.

## Additional context

Part of stack #49171. Base: `chore/ai-sdk-7` (#49167).

Notebook proposal Confirm wrapping is **not** in this stack — that file
lives on [#49159](#49159).
Follow up after that stack merges.

## Test plan

- [ ] Deploy-edge-function tool part shows Confirm with Skip / Deploy
- [ ] Existing-function replace warning still requires the second
confirm
- [ ] After approve, footer morphs to loading and buttons disable
- [ ] `Confirm.utils.test.ts` and `EdgeFunctionRenderer.test.tsx` pass

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added confirmation cards for AI-assisted actions, including approve
and cancel controls.
* Improved handling of manual approval requests for SQL execution,
notebook changes, and Edge Function deployment.
* Added support for customizing report and Edge Function block styling.

* **Bug Fixes**
* Automatic approvals no longer appear as pending manual confirmations.
  * Skipped SQL actions now provide clearer messaging.

* **Tests**
* Expanded coverage for approval states, confirmation controls, and
automatic decisions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
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