Skip to content

upgrade package for ai-chat-sdk to v6#8864

Open
Light2Dark wants to merge 8 commits intomainfrom
sham/upgrade-ai-chat-sdk
Open

upgrade package for ai-chat-sdk to v6#8864
Light2Dark wants to merge 8 commits intomainfrom
sham/upgrade-ai-chat-sdk

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented Mar 25, 2026

📝 Summary

We aren't using any of the newer features, so it's pretty straightforward

  1. Installed the new package
  2. Ran vercel's codemod to upgrade (no changes)
  3. Fixed type errors
  4. Tested

Upgraded recommended dep to 1.52.0 as that is when v6 support was properly implemented in pydantic-ai. Not doing so would break the validation

Screenshot 2026-03-25 at 4 30 18 PM Screenshot 2026-03-25 at 4 35 10 PM Screenshot 2026-03-25 at 4 35 37 PM

🔍 Description of Changes

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Tests have been added for the changes made.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Pull request title is a good summary of the changes - it will be used in the release notes.

Copilot AI review requested due to automatic review settings March 25, 2026 08:37
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Mar 27, 2026 11:29am

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Bundle Report

Changes will decrease total bundle size by 792.93kB (-3.1%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
marimo-esm 24.8MB -792.93kB (-3.1%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: marimo-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/cells-*.js 5.83kB 688.74kB 0.85%
assets/index-*.js -12.02kB 606.53kB -1.94%
assets/chunk-*.js -23.85kB 442.35kB -5.11%
assets/edit-*.js 61 bytes 371.63kB 0.02%
assets/index-*.css 80 bytes 360.62kB 0.02%
assets/dist-*.js -4.31kB 11.91kB -26.57%
assets/dist-*.js -4.48kB 16.21kB -21.64%
assets/dist-*.js -6.09kB 20.69kB -22.73%
assets/dist-*.js -840 bytes 26.78kB -3.04%
assets/dist-*.js -30.69kB 27.62kB -52.64%
assets/dist-*.js (New) 58.31kB 58.31kB 100.0% 🚀
assets/JsonOutput-*.js 733 bytes 307.33kB 0.24%
assets/ai-*.js -18.01kB 248.36kB -6.76%
assets/add-*.js 88 bytes 55.42kB 0.16%
assets/add-*.js 10.18kB 192.63kB 5.58% ⚠️
assets/cell-*.js 11 bytes 182.74kB 0.01%
assets/agent-*.js 10 bytes 158.24kB 0.01%
assets/layout-*.js 50 bytes 129.43kB 0.04%
assets/PTSans-*.woff2 (New) 113.56kB 113.56kB 100.0% 🚀
assets/PTSans-*.woff2 (New) 116.14kB 116.14kB 100.0% 🚀
assets/Lora-*.woff2 (New) 83.69kB 83.69kB 100.0% 🚀
assets/FiraMono-*.woff2 (New) 62.68kB 62.68kB 100.0% 🚀
assets/FiraMono-*.woff2 (New) 67.4kB 67.4kB 100.0% 🚀
assets/FiraMono-*.woff2 (New) 62.3kB 62.3kB 100.0% 🚀
assets/panels-*.js 431 bytes 48.5kB 0.9%
assets/file-*.js 169 bytes 47.04kB 0.36%
assets/textarea-*.js (New) 38.25kB 38.25kB 100.0% 🚀
assets/context-*.js -182 bytes 33.61kB -0.54%
assets/chat-*.js 1 bytes 32.39kB 0.0%
assets/chat-*.js 5.97kB 14.65kB 68.86% ⚠️
assets/chat-*.js (New) 8.68kB 8.68kB 100.0% 🚀
assets/form-*.js 4 bytes 26.27kB 0.02%
assets/react-*.browser.esm-Dmf4Xg1J.js (New) 25.64kB 25.64kB 100.0% 🚀
assets/session-*.js -116 bytes 24.94kB -0.46%
assets/vega-*.browser-W8QXhYr5.js (New) 24.8kB 24.8kB 100.0% 🚀
assets/micromark-*.js (New) 24.12kB 24.12kB 100.0% 🚀
assets/MarimoErrorOutput-*.js 36 bytes 23.57kB 0.15%
assets/useNotebookActions-*.js -22 bytes 22.99kB -0.1%
assets/home-*.js 43 bytes 21.73kB 0.2%
assets/VisuallyHidden-*.js (New) 18.23kB 18.23kB 100.0% 🚀
assets/command-*.js -28 bytes 9.81kB -0.28%
assets/app-*.js 45 bytes 11.43kB 0.4%
assets/CellStatus-*.js 1 bytes 11.37kB 0.01%
assets/switch-*.js -239 bytes 11.24kB -2.08%
assets/run-*.js -28 bytes 10.55kB -0.26%
assets/useCellActionButton-*.js 5 bytes 9.48kB 0.05%
assets/scratchpad-*.js -28 bytes 8.39kB -0.33%
assets/react-*.esm-BJVxNhcA.js (New) 8.37kB 8.37kB 100.0% 🚀
assets/azure-*.js -38.25kB 6.06kB -86.33%
assets/useBoolean-*.js -4 bytes 5.77kB -0.07%
assets/markdown-*.js -11.9kB 5.12kB -69.95%
assets/RenderHTML-*.js -32 bytes 4.95kB -0.64%
assets/floating-*.js -32 bytes 4.79kB -0.66%
assets/emotion-*.esm-C7Gs50yh.js (New) 4.37kB 4.37kB 100.0% 🚀
assets/mermaid-*.core-hTN4xwYK.js (New) 2.38kB 2.38kB 100.0% 🚀
assets/state-*.js -487 bytes 744 bytes -39.56%
assets/createReducer-*.js 157 bytes 1.04kB 17.68% ⚠️
assets/maps-*.js -8.36kB 793 bytes -91.34%
assets/sparkles-*.js (New) 494 bytes 494 bytes 100.0% 🚀
assets/fileToBase64-*.js (New) 479 bytes 479 bytes 100.0% 🚀
assets/events-*.js (New) 341 bytes 341 bytes 100.0% 🚀
assets/SelectionIndicator-*.js (New) 324 bytes 324 bytes 100.0% 🚀
assets/message-*.js (New) 241 bytes 241 bytes 100.0% 🚀
assets/kiosk-*.js 2 bytes 200 bytes 1.01%
assets/PTSans-*.ttf (Deleted) -288.34kB 0 bytes -100.0% 🗑️
assets/PTSans-*.ttf (Deleted) -278.61kB 0 bytes -100.0% 🗑️
assets/Lora-*.ttf (Deleted) -212.0kB 0 bytes -100.0% 🗑️
assets/FiraMono-*.ttf (Deleted) -201.71kB 0 bytes -100.0% 🗑️
assets/FiraMono-*.ttf (Deleted) -170.2kB 0 bytes -100.0% 🗑️
assets/FiraMono-*.ttf (Deleted) -169.06kB 0 bytes -100.0% 🗑️
assets/react-*.browser.esm-DDRqG5ui.js (Deleted) -25.64kB 0 bytes -100.0% 🗑️
assets/vega-*.browser-BJ9oKrvH.js (Deleted) -24.8kB 0 bytes -100.0% 🗑️
assets/emotion-*.esm-D7FeWASw.js (Deleted) -4.37kB 0 bytes -100.0% 🗑️
assets/mermaid-*.core-CdM8D_p_.js (Deleted) -2.38kB 0 bytes -100.0% 🗑️
assets/mode-*.js (Deleted) -533 bytes 0 bytes -100.0% 🗑️

Files in assets/add-*.js:

  • ./src/components/chat/chat-utils.ts → Total Size: 4.74kB

  • ./src/core/ai/staged-cells.ts → Total Size: 7.11kB

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Upgrades the frontend Vercel AI SDK dependencies to v6 (and @ai-sdk/react v3) and adjusts code to compile and handle newly introduced stream chunk types, aligning marimo’s chat/AI tooling with the new SDK event schema.

Changes:

  • Bumped frontend dependencies ai to ^6.0.129 and @ai-sdk/react to ^3.0.131 (plus lockfile updates).
  • Updated backend constant to emit Vercel AI SDK v6-compatible stream chunks (AI_SDK_VERSION = 6).
  • Updated frontend types/logging to accommodate new stream chunk types and updated SDK type exports.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pnpm-lock.yaml Lockfile updates reflecting the AI SDK major version upgrade and transitive dependency changes.
marimo/_plugins/ui/_impl/chat/chat.py Switches backend stream encoding to AI SDK schema version 6.
frontend/src/core/ai/staged-cells.ts Handles additional AI SDK v6 stream chunk types in the staged-cells stream switch.
frontend/src/components/chat/chat-utils.ts Updates SDK type usage for tool output plumbing (ChatAddToolOutputFunction).
frontend/package.json Upgrades ai and @ai-sdk/react dependency versions.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

frontend/src/components/chat/chat-utils.ts:131

  • toolCall.input is typed as Record<string, never>, but frontend tools (e.g. edit_notebook_tool) have non-empty argument schemas. This type forces unsafe casts at call sites and can hide real mismatches. Consider changing the type to unknown (and validating/narrowing before sending) or Record<string, unknown> so tool args are accurately represented.
  invokeAiTool: (request: InvokeAiToolRequest) => Promise<InvokeAiToolResponse>;
  addToolOutput: ChatAddToolOutputFunction<UIMessage>;
  toolCall: {
    toolName: string;
    toolCallId: string;
    input: Record<string, never>;
  };

Comment on lines 23 to 25
"dependencies": {
"@ai-sdk/react": "^2.0.125",
"@ai-sdk/react": "^3.0.131",
"@anywidget/types": "^0.2.0",
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

PR checklist/description states that tests were added, but this PR only shows dependency/version updates and type fixes (no test file changes). If no tests were actually added, please update the checklist/description; otherwise, point to the new/updated tests.

Copilot uses AI. Check for mistakes.
mscolnick
mscolnick previously approved these changes Mar 25, 2026
@Light2Dark Light2Dark added the internal A refactor or improvement that is not user facing label Mar 25, 2026
@Light2Dark Light2Dark marked this pull request as ready for review March 25, 2026 14:16
@Light2Dark Light2Dark requested a review from akshayka as a code owner March 25, 2026 14:16
"ruff>=0.14.0,<0.15.2", # TODO: remove upper bound once we fix the ruff issues
# For AI
"pydantic-ai-slim[openai]>=1.52.0",
"pydantic-ai-slim[openai]>=1.71.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this required? does this mean if a user has an old pydantic-ai-slim that the frontend could break?

Copy link
Copy Markdown
Collaborator Author

@Light2Dark Light2Dark Mar 25, 2026

Choose a reason for hiding this comment

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

I've only upgraded the test deps in this change.

But I think we should recommend upgrading pydantic-ai-slim with maybe 1.64.0, I can test it. 1.52.0

Copy link
Copy Markdown
Collaborator Author

@Light2Dark Light2Dark Mar 25, 2026

Choose a reason for hiding this comment

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

It does break with the older example notebook in this repo

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so should we hold off on this if it could break old notebooks?

)

DependencyManager.pydantic_ai.require_at_version(
"for Vercel AI SDK support", min_version="1.52.0"
Copy link
Copy Markdown
Contributor

@mscolnick mscolnick Mar 26, 2026

Choose a reason for hiding this comment

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

something to call out in changelog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

changelog*

mscolnick
mscolnick previously approved these changes Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants