Skip to content

Winston/update ai sdk#397

Open
ElasticBottle wants to merge 3 commits intomainfrom
winston/update-ai-sdk
Open

Winston/update ai sdk#397
ElasticBottle wants to merge 3 commits intomainfrom
winston/update-ai-sdk

Conversation

@ElasticBottle
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 15, 2026 16:04
@gemini-code-assist
Copy link

Summary of Changes

Hello @ElasticBottle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on a significant upgrade of the AI SDK and its associated provider packages to their latest major versions. This upgrade necessitated widespread refactoring to adapt to API changes, particularly in how structured outputs are generated from AI models and how tool schemas are defined. The changes streamline AI agent implementations, improve JSON parsing, and introduce more detailed UI feedback for AI tool interactions, ensuring compatibility and leveraging new features of the updated SDK.

Highlights

  • AI SDK Major Version Upgrade: Upgraded the core 'ai' SDK from version 5.x to 6.x, and related AI SDK packages (e.g., @ai-sdk/react, @ai-sdk/anthropic, @ai-sdk/google, @ai-sdk/openai) from version 2.x to 3.x across multiple applications and packages.
  • Simplified Tool Schema Definitions: Refactored AI tool input and output schema definitions to directly use schema objects (e.g., createArticleInputSchema) instead of the jsonSchema utility and toJsonSchema() method, simplifying tool declarations.
  • Transition to generateText with Structured Output: Replaced direct usage of generateObject with generateText combined with Output.object({ schema: ... }) for generating structured JSON outputs from AI models, aligning with the new AI SDK API.
  • Removal of Custom JSON Parsing Utility: Eliminated the custom llmParseJson utility function, indicating that the updated AI SDK now provides more robust or integrated mechanisms for handling JSON parsing from model outputs.
  • Asynchronous Agent Initialization and Message Conversion: Updated AI agent creation functions (e.g., createStrategistAgent, createWriterAgent) and message conversion utilities (convertToModelMessages) to be asynchronous, reflecting changes in the AI SDK's lifecycle management.
  • Updated AI Model Identifiers: Adjusted AI model identifiers used in various workflows and agents, such as updating gemini-2.5-flash to gemini-3-flash-preview and gpt-5-mini to gpt-5.1-codex-mini.
  • Enhanced AI Tool UI States: Enabled and refined additional UI states for AI tool execution, including 'approval-requested', 'approval-responded', and 'output-denied', providing more granular feedback on tool interactions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .changeset/config.json
    • Updated the 'contact' entry to 'seo-contact' in the access array.
  • apps/seo/package.json
    • Updated @ai-sdk/react dependency from ^2.0.98 to ^3.0.88.
    • Updated ai dependency from ^5.0.112 to ^6.0.86.
  • packages/api-seo/package.json
    • Updated @ai-sdk/anthropic dependency from ^2.0.56 to ^3.0.44.
    • Updated @ai-sdk/google dependency from ^2.0.46 to ^3.0.29.
    • Updated @ai-sdk/openai dependency from ^2.0.85 to ^3.0.29.
    • Updated ai dependency from ^5.0.112 to ^6.0.86.
  • packages/api-seo/src/lib/ai/strategist-agent.ts
    • Changed createStrategistAgent function to be asynchronous and updated its return type.
    • Awaited the convertToModelMessages function call.
  • packages/api-seo/src/lib/ai/tools/create-article-tool.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definition to directly use createArticleInputSchema.
  • packages/api-seo/src/lib/ai/tools/data-analysis-agent-tool.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definition to directly use dataAnalysisAgentInputSchema.
  • packages/api-seo/src/lib/ai/tools/dataforseo-tool.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definitions for various tools (e.g., getRankedKeywordsForSite, getRankedPagesForSite, getKeywordSuggestions, getKeywordOverview, getSerpForKeyword).
  • packages/api-seo/src/lib/ai/tools/file-tool.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definitions for various file tools (e.g., ls, cat, rm, mv, writeFile).
  • packages/api-seo/src/lib/ai/tools/image-tools.ts
    • Removed generateObject, JSONSchema7, and jsonSchema imports from 'ai', and added Output import.
    • Replaced generateObject with generateText using Output.object for structured output.
    • Updated access to generated object properties from object.index to output.index.
    • Simplified inputSchema definitions for generateImage and findStockImage.
    • Simplified inputSchema definition for captureScreenshotTool.
  • packages/api-seo/src/lib/ai/tools/internal-links-tool.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definition for internalLinks tool.
  • packages/api-seo/src/lib/ai/tools/planner-tools.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definitions for askQuestions and createPlan tools.
  • packages/api-seo/src/lib/ai/tools/settings-tools.ts
    • Removed generateObject, JSONSchema7, and jsonSchema imports from 'ai', and added Output and generateText imports.
    • Simplified inputSchema definition for manageSettings tool.
    • Removed schemaToUse variable and dynamically applied Output.object with specific schemas.
    • Updated access to generated object properties from object to output.
  • packages/api-seo/src/lib/ai/tools/skill-tools.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definitions for readSkills and useSkills tools.
  • packages/api-seo/src/lib/ai/tools/strategy-tools.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definition for getStrategyDetailsTool.
  • packages/api-seo/src/lib/ai/tools/todo-tool.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definition for manageTodo tool by removing JSON string manipulation.
  • packages/api-seo/src/lib/ai/tools/web-tools.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definitions for webFetch and webSearch tools.
    • Replaced experimental_output with output in generateText calls.
  • packages/api-seo/src/lib/ai/utils/llm-parse-json.ts
    • Removed the entire llmParseJson utility file.
  • packages/api-seo/src/lib/ai/writer-agent.ts
    • Changed createWriterAgent function to be asynchronous and updated its return type.
    • Awaited the convertToModelMessages function call.
  • packages/api-seo/src/lib/chat/handle-title-generation.ts
    • Awaited the convertToModelMessages function call.
  • packages/api-seo/src/routes/chat.sendMessage.ts
    • Changed the agent creation block to be asynchronous and awaited createWriterAgent and createStrategistAgent calls.
    • Wrapped result.consumeStream in Promise.resolve() for waitUntil.
  • packages/api-seo/src/workflows/onboarding-workflow.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Replaced experimental_output with output in generateText calls.
    • Simplified schema definitions within Output.object.
  • packages/api-seo/src/workflows/planner-workflow.ts
    • Added openai import to @ai-sdk/openai.
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Replaced experimental_output with output in generateText calls.
    • Changed model from google("gemini-3-flash-preview") to openai("gpt-5.1-codex-mini") for a specific generateText call.
    • Simplified schema definitions within Output.object.
  • packages/api-seo/src/workflows/strategy-phase-generation-workflow.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Removed PhaseSuggestion type definition.
    • Replaced experimental_output with output in generateText calls.
    • Simplified schema definitions within Output.object.
  • packages/api-seo/src/workflows/strategy-suggestions-workflow.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Replaced experimental_output with output in generateText calls.
    • Simplified schema definitions within Output.object.
  • packages/api-seo/src/workflows/writer-workflow.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Replaced experimental_output with output in generateText calls.
    • Simplified schema definitions within Output.object.
    • Removed todoTool.tools from the tools object in a generateText call for review.
  • packages/api-user-vm/package.json
    • Updated @ai-sdk/google dependency from ^2.0.46 to ^3.0.29.
    • Updated ai dependency from ^5.0.112 to ^6.0.86.
  • packages/api-user-vm/src/lib/ai.ts
    • Updated the default AI model ID from gemini-2.5-flash to gemini-3-flash-preview.
  • packages/api-user-vm/src/routes/content.ts
    • Changed the route handler function to be asynchronous.
    • Awaited the convertToModelMessages function call.
  • packages/db/package.json
    • Updated ai dependency from ^5.0.112 to ^6.0.86.
  • packages/task/package.json
    • Updated @ai-sdk/google dependency from ^2.0.46 to ^3.0.29.
    • Updated @ai-sdk/openai dependency from ^2.0.85 to ^3.0.29.
    • Updated ai dependency from ^5.0.112 to ^6.0.86.
  • packages/task/src/lib/ai-tools/get-site-data.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema and outputSchema definitions for the get-sites-data tool.
  • packages/task/src/lib/ai-tools/llm-parse-json.ts
    • Removed the entire llmParseJson utility file.
  • packages/task/src/lib/ai-tools/search-site.ts
    • Removed JSONSchema7 and jsonSchema imports from 'ai'.
    • Simplified inputSchema definition for the search-sites tool.
  • packages/task/src/trigger/understand-site-llm.ts
    • Removed llmParseJson import and usage.
    • Added Output import to 'ai'.
    • Configured generateText to use Output.object for structured output.
    • Replaced text variable with output for accessing generated content.
  • packages/task/src/trigger/understand-site.ts
    • Removed llmParseJson import and usage.
    • Added Output import to 'ai'.
    • Updated the AI model from google("gemini-2.5-flash") to google("gemini-3-flash-preview").
    • Configured generateText to use Output.object for structured output.
    • Replaced websiteInfo variable with output for accessing generated content.
  • packages/ui/package.json
    • Updated ai dependency from ^5.0.112 to ^6.0.86.
  • packages/ui/src/components/ai-elements/image.tsx
    • Replaced Experimental_GeneratedImage type with GeneratedFile from 'ai'.
  • packages/ui/src/components/ai-elements/tool.tsx
    • Enabled and updated labels and icons for approval-requested, approval-responded, and output-denied tool states.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 15, 2026

Open in StackBlitz

pnpm add https://pkg.pr.new/rectangular-labs/monorepo/@rectangular-labs/emails@397
pnpm add https://pkg.pr.new/rectangular-labs/monorepo/@rectangular-labs/loro-file-system@397
pnpm add https://pkg.pr.new/rectangular-labs/monorepo/@rectangular-labs/result@397

commit: f502136

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR updates the AI SDK and related dependencies to newer versions. The changes correctly adapt the codebase to the new APIs, such as using Output.object with generateText for structured output, removing the jsonSchema helper, and handling async convertToModelMessages. The removal of the llm-parse-json.ts utility is a great simplification. I've added a couple of suggestions for minor code quality improvements. Overall, this is a solid update.

Comment on lines +85 to +124
const output = await (async () => {
if (settingToUpdate === "businessBackground") {
const result = await generateText({
model: openai("gpt-5.1-codex-mini"),
output: Output.object({
schema: businessBackgroundSchema,
}),
prompt,
});
return result.output;
}
if (settingToUpdate === "imageSettings") {
const result = await generateText({
model: openai("gpt-5.1-codex-mini"),
output: Output.object({
schema: imageSettingsSchema,
}),
prompt,
});
return result.output;
}
if (settingToUpdate === "writingSettings") {
const result = await generateText({
model: openai("gpt-5.1-codex-mini"),
output: Output.object({
schema: writingSettingsSchema,
}),
prompt,
});
return result.output;
}
const result = await generateText({
model: openai("gpt-5.1-codex-mini"),
output: Output.object({
schema: publishingSettingsSchema,
}),
prompt,
});
return result.output;
})();

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, consider refactoring this series of if statements into a switch statement. This is a more conventional way to handle logic that branches on the value of a single variable like settingToUpdate.

      const output = await (async () => {
        switch (settingToUpdate) {
          case "businessBackground": {
            const { output } = await generateText({
              model: openai("gpt-5.1-codex-mini"),
              output: Output.object({ schema: businessBackgroundSchema }),
              prompt,
            });
            return output;
          }
          case "imageSettings": {
            const { output } = await generateText({
              model: openai("gpt-5.1-codex-mini"),
              output: Output.object({ schema: imageSettingsSchema }),
              prompt,
            });
            return output;
          }
          case "writingSettings": {
            const { output } = await generateText({
              model: openai("gpt-5.1-codex-mini"),
              output: Output.object({ schema: writingSettingsSchema }),
              prompt,
            });
            return output;
          }
          case "publishingSettings": {
            const { output } = await generateText({
              model: openai("gpt-5.1-codex-mini"),
              output: Output.object({ schema: publishingSettingsSchema }),
              prompt,
            });
            return output;
          }
        }
      })();

Comment on lines +248 to +256
Promise.resolve(
result.consumeStream({
onError: (error) => {
console.error("[chat.sendMessage] consumeStream onError", {
error,
});
},
}),
),

Choose a reason for hiding this comment

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

medium

The result.consumeStream() method is async and already returns a Promise. Wrapping it in Promise.resolve() is redundant and can be removed for cleaner code.

      result.consumeStream({
        onError: (error) => {
          console.error("[chat.sendMessage] consumeStream onError", {
            error,
          });
        },
      })

Copy link

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

This PR updates the Vercel AI SDK from v5 to v6 across the monorepo, along with all related AI SDK provider packages (@ai-sdk/google, @ai-sdk/openai, @ai-sdk/anthropic, @ai-sdk/react). The changes refactor code to use the new v6 API patterns, removing experimental features that have been stabilized.

Changes:

  • Upgraded AI SDK packages from v5.0.112 to v6.0.86 and provider packages to v3.x
  • Migrated from experimental_output to output API for structured outputs
  • Removed jsonSchema wrapper in favor of direct schema usage with tools
  • Deleted llmParseJson utility functions that are now redundant
  • Made convertToModelMessages async calls explicit with await
  • Updated UI components to support approval states (previously commented out)

Reviewed changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/ui/package.json Upgraded ai package to v6.0.86
packages/ui/src/components/ai-elements/tool.tsx Uncommented approval-related UI states for tool execution
packages/ui/src/components/ai-elements/image.tsx Updated type from Experimental_GeneratedImage to GeneratedFile
packages/task/package.json Upgraded ai and AI SDK provider packages to v6 and v3 respectively
packages/task/src/trigger/understand-site.ts Updated to use Output.object, changed model to gemini-3-flash-preview, removed llmParseJson
packages/task/src/trigger/understand-site-llm.ts Updated to use Output.object, changed model to gpt-5-mini, removed llmParseJson
packages/task/src/lib/ai-tools/search-site.ts Removed jsonSchema wrapper for inputSchema
packages/task/src/lib/ai-tools/llm-parse-json.ts Deleted entire utility file (100 lines)
packages/task/src/lib/ai-tools/get-site-data.ts Removed jsonSchema wrapper for input/output schemas
packages/db/package.json Upgraded ai package to v6.0.86
packages/api-user-vm/package.json Upgraded ai and @ai-sdk/google to v6 and v3
packages/api-user-vm/src/routes/content.ts Made handler async, added await for convertToModelMessages
packages/api-user-vm/src/lib/ai.ts Changed model to gemini-3-flash-preview
packages/api-seo/package.json Upgraded ai and AI SDK provider packages to v6 and v3 respectively
packages/api-seo/src/workflows/*.ts Updated 5 workflow files to use Output.object and direct schemas
packages/api-seo/src/routes/chat.sendMessage.ts Made agent creation async, wrapped consumeStream in Promise.resolve
packages/api-seo/src/lib/chat/handle-title-generation.ts Added await for convertToModelMessages
packages/api-seo/src/lib/ai/writer-agent.ts Made function async, added await for convertToModelMessages
packages/api-seo/src/lib/ai/strategist-agent.ts Made function async, added await for convertToModelMessages
packages/api-seo/src/lib/ai/utils/llm-parse-json.ts Deleted entire utility file (100 lines)
packages/api-seo/src/lib/ai/tools/*.ts Updated 12 tool files to remove jsonSchema wrappers and use direct schemas
packages/api-seo/src/lib/ai/tools/settings-tools.ts Replaced generateObject with generateText + Output.object, refactored to handle each schema type separately
apps/seo/package.json Upgraded ai and @ai-sdk/react to v6 and v3
.changeset/config.json Fixed typo in ignore list: contact → seo-contact

@github-actions
Copy link
Contributor

Cloudflare Preview URL for WWW 🎈 : https://pr-397.rectangularlabs.com (custom domain)
Cloudflare Preview URL for SEO 🎈 : https://pr-397.fluidposts.com (custom domain)
Cloudflare Preview URL for SEO WWW 🎈 : https://www-pr-397.fluidposts.com (custom domain)
Cloudflare Preview URL for SEO Contact 🎈 : https://contact-pr-397.fluidposts.com (custom domain)

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f502136442

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

) as JSONSchema7,
),
output: Output.object({
schema: inferArticleTypeSchema,

Choose a reason for hiding this comment

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

P2 Badge Keep Google-compatible enum schema for article type output

Using schema: inferArticleTypeSchema here drops the previous JSON-schema normalization for Google models, but articleTypeSchema is a literal union that serializes as anyOf/const entries rather than typed string enums. In Gemini structured-output calls this can fail schema validation; when that happens this function falls into the catch path and defaults to "other", so article-type-specific rules are silently skipped for generated drafts.

Useful? React with 👍 / 👎.

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.

1 participant