Skip to content

Conversation

@tconley1428
Copy link
Contributor

@tconley1428 tconley1428 commented Oct 2, 2025

What was changed

Added a new AiSDKPlugin to support running AI SDK in workflows. The plugin registers new activities for model invocation and optionally MCP tools. Workflows can then use temporalProvider to create models in workflows.

Why?

Checklist

  1. Closes

  2. How was this tested:
    Added a new test suite with local model coverage. AI_SDK_REMOTE_TESTS env variable is available to run against a real endpoint.

  3. Any docs updates needed?

@tconley1428 tconley1428 changed the title Ai/initial Integration with AI SDK Nov 13, 2025
@tconley1428 tconley1428 marked this pull request as ready for review November 17, 2025 18:34
@tconley1428 tconley1428 requested a review from a team as a code owner November 17, 2025 18:34
*
* @experimental The AI SDK integration is an experimental feature; APIs may change without notice.
*/
export const createActivities = (provider: ProviderV2, mcpClientFactory?: (_: any) => Promise<MCPClient>): object => {
Copy link
Contributor

Choose a reason for hiding this comment

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

A few things:

  • Prefer the function syntax rather than the const lambda form unless there's a reason for the later;
  • Make a named type definition for McpClientFactory.
  • Make the arg's type unknown rather than any.
Suggested change
export const createActivities = (provider: ProviderV2, mcpClientFactory?: (_: any) => Promise<MCPClient>): object => {
// In mcp.ts
type McpClientFactory = (args: unknown) => Promise<MCPClient>;
export function createActivities(provider: ProviderV2, mcpClientFactory?: McpClientFactory): object {

*/
export const createActivities = (provider: ProviderV2, mcpClientFactory?: (_: any) => Promise<MCPClient>): object => {
const activities = {
async invokeModel(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not namespace those activities somehow, to avoid eventual conflicts with user defined activities, or those from other plugins? Could be something like e.g. __ai_temporal_invokeModel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We didn't in Python, and it does come with the downside of being UI clutter since the name is shown there.

) {}

async tools(): Promise<ToolSet> {
const tools: Record<string, ListToolResult> = await workflow
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it the way you did this in Python? I mean, listTools being an activity call, which is call everytime tools() is called?

A few things that can be considered to make this more efficient:

  • Cache tools after the first call
  • Make listTools a local activity call instead of a regular activity;
  • Extract the list of tools at bundle time and inject it as a static value into the workflow bundle (so no activity call needed to list tools).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is one of the implementations we provided. Caching is a potential addition, but tools() is generally called once.

Extract the list of tools at bundle time and inject it as a static value into the workflow bundle (so no activity call needed to list tools).

I don't believe this is valid as the tool list is not known to be static.

Copy link
Contributor

@mjameswh mjameswh left a comment

Choose a reason for hiding this comment

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

See my previous comments.

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.

4 participants