Skip to content

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

Open
tbrandenburg wants to merge 3 commits into
synergycodes:mainfrom
tbrandenburg:issue-144-ai-agent-model-provider
Open

tbrandenburg wants to merge 3 commits into
synergycodes:mainfrom
tbrandenburg:issue-144-ai-agent-model-provider

Conversation

@tbrandenburg

Copy link
Copy Markdown

Issues fixed

Closes #144 — AI Agent node: per-node/workflow model configuration with optional direct-provider routing

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.

* feat(execution-worker): per-node AI model/provider resolution (synergycodes#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.

* chore(execution-worker): fix formatting

* fix(root): scope ajv override to fix hoisting regression from new AI 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 ajv@8.12.0
started winning over the catalog's ajv@8.18.0). 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).

---------

Co-authored-by: Tom Brandenburg <t_bh@gmx.de>
@tbrandenburg
tbrandenburg deleted the issue-144-ai-agent-model-provider branch September 14, 2026 14:36
@tbrandenburg
tbrandenburg restored the issue-144-ai-agent-model-provider branch September 14, 2026 15:35
@tbrandenburg tbrandenburg reopened this Sep 14, 2026
Tom Brandenburg added 2 commits September 15, 2026 13:05
The worker service only forwards vars explicitly listed in
docker-compose.yml's environment: block; docker compose does not pass
through arbitrary host/.env vars. Without these entries, an operator
setting e.g. ANTHROPIC_API_KEY in deploy/ai-studio/.env would never
reach the container, so ai-agent's direct-provider routing was
silently non-functional in the production stack.
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.

AI Agent node: per-node/workflow model configuration with optional direct-provider routing

1 participant