Skip to content

Update to AI SDK v7 - #358

Merged
brichet merged 8 commits into
jupyterlite:mainfrom
jtpio:update-ai-sdk-v7
Aug 12, 2026
Merged

Update to AI SDK v7#358
brichet merged 8 commits into
jupyterlite:mainfrom
jtpio:update-ai-sdk-v7

Conversation

@jtpio

@jtpio jtpio commented Jul 30, 2026

Copy link
Copy Markdown
Member

Reference: https://ai-sdk.dev/docs/migration-guides/migration-guide-7-0

  • Update dependencies
  • Adapt to some renames and deprecation notices
  • Update some other dev dependencies

type: 'http',
url: serverConfig.url
url: serverConfig.url,
fetch: globalThis.fetch.bind(globalThis)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like this may be a regression in @ai-sdk/mcp v2, but maybe we can live with it for now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Strangely, the default seems to already be the globalThis.fetch, according to the documentation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There seems to be a difference depending on whether this runs in node or in the browser. Will try to push a few commits to the branch to double check that.

@jtpio
jtpio marked this pull request as ready for review July 30, 2026 08:53

@brichet brichet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @jtpio for working on this. Works well on my side, I just have some minor comments.

It seems that it also fix some errors, like the system message and token count in the generateText method of the agent 👍

/**
* The stream result type produced by the agent.
*/
type AgentStreamResult = Awaited<

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Isn't there any type defined in ai-sdk that would natively handle the stream result ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The native type seems to be StreamTextResult<ToolMap, Context, never> but Context is not exported. So we would need to copy that type here too which may make it drift over time.

*/
export function createDiscoverCommandsTool(commands: CommandRegistry): ITool {
return tool({
title: 'Discover Commands',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we still provide the title with the providerMetadata argument ? Or is this useless ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like title is now deprecated and the tools calls were not using it anyway (showing discover_commands instead).

But maybe metadata can work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using metadata:

image

type: 'http',
url: serverConfig.url
url: serverConfig.url,
fetch: globalThis.fetch.bind(globalThis)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Strangely, the default seems to already be the globalThis.fetch, according to the documentation.

@jtpio

jtpio commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

37df312 without the fetch bind fix gives the following in the UI tests:

TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation

The following commit passes cfc184c. Probably an issue we could report in the ai-sdk repo at some point? But for now probably it's fine to keep that around?

@brichet

brichet commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks @jtpio, it looks good to me.

@brichet
brichet merged commit 8fa35a6 into jupyterlite:main Aug 12, 2026
10 checks passed
@jtpio
jtpio deleted the update-ai-sdk-v7 branch August 12, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants