-
Notifications
You must be signed in to change notification settings - Fork 145
feat(ai-sdk): upgrade to AI SDK v6 with embedding model support #1865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ItsWendell
wants to merge
8
commits into
temporalio:main
Choose a base branch
from
ItsWendell:feat/ai-sdk-v3-embedding-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(ai-sdk): upgrade to AI SDK v6 with embedding model support #1865
ItsWendell
wants to merge
8
commits into
temporalio:main
from
ItsWendell:feat/ai-sdk-v3-embedding-support
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR upgrades the ai-sdk package to support AI SDK v6 and adds embedding model support for RAG pipelines in Temporal workflows. ## Changes ### AI SDK v6 Upgrade - Upgrade from AI SDK v5 (`@ai-sdk/provider` v2 types) to AI SDK v6 (v3 types) - Update peer dependencies to `@ai-sdk/provider@^3.0.0`, `ai@^6.0.0`, `@ai-sdk/mcp@^1.0.0` ### Embedding Model Support - Add `TemporalEmbeddingModel` class implementing `EmbeddingModelV3` - Add `invokeEmbeddingModel` activity for durable embedding generation - Add `InvokeEmbeddingModelArgs` and `InvokeEmbeddingModelResult` types - Implement `embeddingModel()` method on `TemporalProvider` ### Enhanced Provider Options - Add `TemporalProviderOptions` interface for per-model activity configuration - Support separate `ActivityOptions` for language vs embedding models - Default options can be overridden by model-specific options ### Type Re-exports - Re-export common AI SDK types from `@ai-sdk/provider` for convenience - Includes `LanguageModelV3*`, `EmbeddingModelV3*`, and `ProviderV3` types ### Other Improvements - Fix timestamp validation in language model response handling - Remove debug logging from MCP client - Use `ToolExecutionOptions` instead of `ToolCallOptions`
4cdbc98 to
be8bf08
Compare
Updates all AI SDK tests to use v3 types and adds comprehensive tests for the new embedding model functionality. ## Changes ### Test Infrastructure Updates - Update `TestModel` and `TestProvider` to implement v3 interfaces - Add `TestEmbeddingModel` class for mocking embedding responses - Update `TestProvider` to support both language and embedding models - Fix tool call response format (`args` instead of `input`) ### New Embedding Model Tests - Add `embeddingWorkflow` to test workflows - Add `embeddingGenerator` for mock embedding responses - Add test case 'Embedding model generates embeddings' - Verify `invokeEmbeddingModel` activity is called correctly ### Dependency Updates - Update `@ai-sdk/provider` to `^3.0.0` - Update `ai` to `^6.0.0` - Update `@ai-sdk/openai` to `^1.0.0` - Update `@ai-sdk/mcp` to `^1.0.0` ### Type Updates - Update middleware type from `LanguageModelV2Middleware` to `LanguageModelV3Middleware` - Update tool definition from `inputSchema` to `parameters`
Updates test files to match AI SDK v6 type requirements: - Use LanguageModelV3FinishReason object format with `unified` and `raw` fields - Use nested LanguageModelV3Usage structure with inputTokens/outputTokens objects - Use `input` property for LanguageModelV3ToolCall (not `args`) - Add required `warnings` field to EmbeddingModelV3Result - Add `specificationVersion: 'v3'` to LanguageModelV3Middleware - Use `inputSchema` property in tool() (not `parameters`) - Cast OpenAI provider to ProviderV3 for remote tests Also updates pnpm-workspace.yaml to allow new AI SDK packages in minimumReleaseAgeExclude.
ItsWendell
commented
Dec 23, 2025
tconley1428
reviewed
Dec 23, 2025
tconley1428
reviewed
Dec 23, 2025
- Remove unnecessary `as any` casts in activities.ts and load-polyfills.ts - Remove AI SDK type re-exports from index.ts (users should import directly) - Fix misleading supportsParallelCalls comment in provider.ts - Update @ai-sdk/openai to v3 for native ProviderV3 support (removes casts) - Revert pnpm-workspace.yaml minimumReleaseAgeExclude workaround
- Use FlexibleSchema<unknown> for inputSchema instead of any - Rename args to input in CallToolArgs (AI SDK v6 convention) - Replace manual symbol hacks with proper jsonSchema() helper - Change clientArgs and other any types to unknown The jsonSchema() helper is the same approach used by @ai-sdk/mcp internally. MCP test passes locally.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR upgrades the
@temporalio/ai-sdkpackage to support AI SDK v6 and adds embedding model support for building RAG pipelines in Temporal workflows.Key Changes
@ai-sdk/providerv2 types) to AI SDK v6 (@ai-sdk/providerv3 types)TemporalEmbeddingModelclass andinvokeEmbeddingModelactivity for durable embedding generation in workflowsTemporalProviderOptionsinterface allows configuring separateActivityOptionsfor language vs embedding modelsjsonSchema()helper instead of manual symbol hacks, properFlexibleSchematypingMotivation
The current ai-sdk package uses AI SDK v5 and lacks embedding model support. This limits its use in modern AI applications that require:
Breaking Changes
This is a breaking change that requires updating peer dependencies:
@ai-sdk/provider^2.0.0^3.0.0ai^5.0.91^6.0.0@ai-sdk/mcp^0.0.8^1.0.0Usage Examples
Embedding Models in Workflows
Per-Model Activity Options
Test Results ✅
All AI SDK tests pass:
Test Plan
TestModelandTestProviderto v3 interfacesTestEmbeddingModelfor mock embedding responsesembeddingWorkflow)invokeEmbeddingModelactivity schedulinginputSchemainstead ofparameters)LanguageModelV3MiddlewarejsonSchema()helper