Skip to content

Replace @inngest/ai adapter system with Vercel AI SDK#294

Draft
djfarrelly wants to merge 6 commits intomainfrom
task/ai-sdk-refactor
Draft

Replace @inngest/ai adapter system with Vercel AI SDK#294
djfarrelly wants to merge 6 commits intomainfrom
task/ai-sdk-refactor

Conversation

@djfarrelly
Copy link
Member

Swap out the custom @inngest/ai abstraction layer and per-provider adapters (OpenAI, Anthropic, Gemini, Azure, Grok) in favor of the Vercel AI SDK's generateText() and LanguageModelV1 interface. Users now pass AI SDK model instances directly instead of using re-exported factory functions.

  • Add ai package as dependency; remove @inngest/ai
  • Rewrite AgenticModel to use generateText() + step.run() instead of step.ai.infer() + raw HTTP calls
  • Add src/converters.ts for Message[] <-> CoreMessage[] bridging
  • Replace AiAdapter.Any with LanguageModelV1 across agent.ts and network.ts
  • Delete src/adapters/ directory and src/models.ts
  • Update tests to use mock LanguageModelV1 instead of fetch mocks

BREAKING CHANGE: Model configuration now requires Vercel AI SDK provider packages (e.g. @ai-sdk/openai) instead of @inngest/ai factory functions.

  Swap out the custom @inngest/ai abstraction layer and per-provider adapters
  (OpenAI, Anthropic, Gemini, Azure, Grok) in favor of the Vercel AI SDK's
  `generateText()` and `LanguageModelV1` interface. Users now pass AI SDK
  model instances directly instead of using re-exported factory functions.

  - Add `ai` package as dependency; remove `@inngest/ai`
  - Rewrite AgenticModel to use generateText() + step.run() instead of
    step.ai.infer() + raw HTTP calls
  - Add src/converters.ts for Message[] <-> CoreMessage[] bridging
  - Replace AiAdapter.Any with LanguageModelV1 across agent.ts and network.ts
  - Delete src/adapters/ directory and src/models.ts
  - Update tests to use mock LanguageModelV1 instead of fetch mocks

  BREAKING CHANGE: Model configuration now requires Vercel AI SDK provider
  packages (e.g. @ai-sdk/openai) instead of @inngest/ai factory functions.
@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

⚠️ No Changeset found

Latest commit: 9cde5df

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

if (step) {
result = (await step.ai.infer(stepID, {
const doInference = async (): Promise<SerializableResult> => {
const result = await generateText({
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the core change here - need to test for o11y

  - Fix mapToolChoice return type removing misleading "none" variant
  - Deduplicate identical system/user/assistant branches in messagesToCoreMessages
  - Remove type assertions in resultToMessages in favor of typed locals
  - Remove triplicate RoutingConstructor interface declaration in agent.ts
  - Add 24 unit tests covering all converter functions
  - Text-only response
  - Tool call response (with tool definitions passed)
  - Mixed text + tool call response
  - Error propagation from generateText() (the main medium-priority gap)
  - Non-Error exception propagation (e.g. thrown strings)
  - Verifies tools/toolChoice aren't passed when no tools provided
  - createAgenticModelFromLanguageModel factory function
  - Add try/catch around z.toJSONSchema() in toolsToAiTools so incompatible
    schemas (e.g. Zod v3 from MCP) fall back to an open object schema
    instead of crashing inference
  - Extract createMockModel into shared __tests__/test-helpers.ts, removing
    duplication across routing-with-done, network, and model test files
  - Add standalone agent.run() and withModel() tests (6 new tests)
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