Skip to content

Add support for defining model as a step function initializer in DurableAgent#346

Merged
TooTallNate merged 3 commits into
mainfrom
11-14-add_support_for_defining_model_as_a_step_function_initializer
Nov 16, 2025
Merged

Add support for defining model as a step function initializer in DurableAgent#346
TooTallNate merged 3 commits into
mainfrom
11-14-add_support_for_defining_model_as_a_step_function_initializer

Conversation

@TooTallNate
Copy link
Copy Markdown
Member

@TooTallNate TooTallNate commented Nov 14, 2025

Added support for defining model as a step function initializer in the AI workflow package.

What changed?

  • Modified the DurableAgent class to accept either a string model ID or a function that returns a LanguageModelV2 instance
  • Updated the doStreamStep function to handle both string model IDs and function initializers
  • Added proper error handling for invalid model initialization arguments

How to test?

Test both initialization methods:

  1. Using a string model ID:
const agent = new DurableAgent({
  model: 'anthropic/claude-opus',
  // other options
});
  1. Using a step function initializer:
import { xai } from "@ai-sdk/xai"

const agent = new DurableAgent({
  model: async () => {
    "use step";
    return xai("grok-4");
  },
  // other options
});

Why make this change?

This enhancement provides more flexibility in how language models are initialized and used within the workflow. By supporting function initializers, users can now:

  • Use custom model instances with specialized configurations
  • Implement more complex model initialization logic that wasn't possible with just string identifiers

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 14, 2025

🦋 Changeset detected

Latest commit: c9da9c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@workflow/ai Patch
@workflow/swc-plugin Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/sveltekit Patch
workflow Patch
@workflow/world-testing Patch
@workflow/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Nov 14, 2025

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

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 16, 2025 3:25am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 16, 2025 3:25am
example-workflow Ready Ready Preview Comment Nov 16, 2025 3:25am
workbench-astro-workflow Error Error Nov 16, 2025 3:25am
workbench-hono-workflow Ready Ready Preview Comment Nov 16, 2025 3:25am
workbench-nitro-workflow Ready Ready Preview Comment Nov 16, 2025 3:25am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 16, 2025 3:25am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 16, 2025 3:25am
workbench-vite-workflow Ready Ready Preview Comment Nov 16, 2025 3:25am
workflow-docs Ready Ready Preview Comment Nov 16, 2025 3:25am

@TooTallNate TooTallNate changed the title Add support for defining model as a step function initializer Add support for defining model as a step function initializer in DurableAgent Nov 14, 2025
@TooTallNate TooTallNate marked this pull request as ready for review November 14, 2025 19:26
@TooTallNate TooTallNate force-pushed the 11-14-add_support_for_defining_model_as_a_step_function_initializer branch from f21818c to c97f02c Compare November 14, 2025 19:29
@TooTallNate TooTallNate force-pushed the 11-14-add_support_for_step_functions_nested_inside_of_workflow_functions branch from 21d0fec to 99d30e5 Compare November 15, 2025 07:17
@TooTallNate TooTallNate force-pushed the 11-14-add_support_for_defining_model_as_a_step_function_initializer branch from 91f8e57 to fcddf9b Compare November 15, 2025 07:17
@TooTallNate TooTallNate force-pushed the 11-14-add_support_for_step_functions_nested_inside_of_workflow_functions branch 2 times, most recently from 78b6405 to 71cf4dd Compare November 15, 2025 07:35
@TooTallNate TooTallNate force-pushed the 11-14-add_support_for_defining_model_as_a_step_function_initializer branch from fcddf9b to 7836b5f Compare November 15, 2025 07:35
Copy link
Copy Markdown
Member

@VaguelySerious VaguelySerious left a comment

Choose a reason for hiding this comment

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

This PR seems to also contain changes from a different one changing SWC stuff - approving the DurableAgent changes specifically

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.

2 participants