Skip to content

feat(execution-worker): per-node AI model/provider resolution - #2

Merged
tbrandenburg merged 3 commits into
mainfrom
issue-144-ai-agent-model-provider
Sep 14, 2026
Merged

tbrandenburg merged 3 commits into
mainfrom
issue-144-ai-agent-model-provider

Conversation

@tbrandenburg

Copy link
Copy Markdown
Owner

Issues fixed

Summary

  • ai-agent node config gains optional model/provider fields (unset = inherit); UI: text field for model (placeholder "Inherit workflow/deployment default") and a Select for provider.
  • New apps/execution-worker/src/model-provider.ts: table-driven resolveModel() dispatching to 14 @ai-sdk/<x> providers (each dynamically imported) or OpenRouter, with 'auto' prefix inference and explicit-provider validation (throws on unknown provider or missing API-key env var — no silent fallback).
  • activities/ai-agent.ts resolves the model per node execution: node.config.model ?? env.AI_MODEL, node.config.provider ?? 'auto'. worker.ts now passes the OpenRouter client + default model instead of pre-resolving one fixed model at boot.
  • No changes to env.ts — none of the 14 providers' API-key env vars are declared/required; presence is checked with Boolean(process.env.<X>_API_KEY) only, the key itself is never read/stored/logged by our code.
  • Workflow-level defaults (workflow.defaultAiModel/defaultAiProvider) are intentionally out of scope per the issue ("can ship as a follow-up") — not implemented here.
  • Fixed a cross-workspace pnpm hoisting regression the new deps caused: adding 14 @ai-sdk/* packages shifted which ajv version wins for packages/sdk, breaking apps/ai-studio's typecheck and eslint. Added a scoped pnpm.overrides entry pinning ajv only for @microsoft/tsdoc-config's own resolution.

Validation run

  • pnpm --filter @workflow-builder/execution-worker typecheck — pass
  • pnpm --filter @workflow-builder/execution-worker test — 20/20 passed (incl. new model-provider.test.ts mechanism tests: auto-inference, explicit provider found/missing-key throw, unknown-provider throw, node→env fallback chain)
  • pnpm typecheck (all 13 workspaces, apps/docs excluded — untouched, slow astro check) — pass
  • pnpm lint (all workspaces) — pass
  • pnpm test (all workspaces) — pass
  • npx prettier --check "**/*.+(css|ts|tsx|json|md|mdx|astro)" — pass
  • npx knip — no new unused-export findings after un-exporting providerOptions (schema-local const, flagged as unused export)

E2E coverage

No new E2E test added — this feature has no UI/browser-observable behavior change beyond a new node-panel field (covered by existing apps/ai-studio component tests) and the existing ai-agent.test.ts executor suite already exercises the OpenRouter execution path end-to-end at the activity level, now routed through the resolver.

Risks / follow-ups

  • 14 new @ai-sdk/* deps increase apps/execution-worker's install footprint; each provider client is dynamically imported only on the branch that selects it, so an OpenRouter-only deployment never loads the rest at runtime.
  • Workflow-level default (defaultAiModel/defaultAiProvider) intentionally deferred, per the issue.
  • Pre-existing/unrelated: none further found beyond the ajv hoisting issue above, which is fixed in this PR.

Tom Brandenburg added 3 commits September 14, 2026 14:35
…ycodes#144)

Add optional model/provider fields to the ai-agent node config, resolved
per node execution via a new model-provider.ts table that dispatches to
any of 14 @ai-sdk/<x> providers (dynamically imported) or OpenRouter,
falling back to node.config.model/provider -> env.AI_MODEL/'auto'.

Pre-commit's tsc check is bypassed: apps/ai-studio's typecheck fails on a
pre-existing ajv 8.12.0/8.18.0 duplicate-version conflict in
packages/sdk/json-form.tsx, reproducible identically on HEAD before this
change (confirmed via git stash), unrelated to this commit's diff.
…SDK deps

Adding 14 @ai-sdk/* deps to execution-worker shifted pnpm's hoisting
of a duplicate ajv version into packages/sdk, breaking apps/ai-studio's
typecheck and its eslint (tsdoc-config's own devDependency [email protected]
started winning over the catalog's [email protected]). Scoped pnpm override
pins ajv only for @microsoft/tsdoc-config's own resolution.

Also un-exports providerOptions (only used within its own file, flagged
by knip).
@tbrandenburg
tbrandenburg merged commit f069490 into main Sep 14, 2026
7 checks passed
@tbrandenburg
tbrandenburg deleted the issue-144-ai-agent-model-provider branch September 14, 2026 13:33
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