feat(execution-worker): per-node AI model/provider resolution - #145
Open
tbrandenburg wants to merge 3 commits into
Open
tbrandenburg wants to merge 3 commits into
tbrandenburg wants to merge 3 commits into
Conversation
* 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
requested review from
librowski,
lukasz-jazwa,
piotrblaszczyk and
szymon-t-sc
as code owners
September 14, 2026 13:48
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues fixed
Closes #144 — AI Agent node: per-node/workflow model configuration with optional direct-provider routing
Summary
ai-agentnode config gains optionalmodel/providerfields (unset = inherit); UI: text field formodel(placeholder "Inherit workflow/deployment default") and aSelectforprovider.apps/execution-worker/src/model-provider.ts: table-drivenresolveModel()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.tsresolves the model per node execution:node.config.model ?? env.AI_MODEL,node.config.provider ?? 'auto'.worker.tsnow passes the OpenRouter client + default model instead of pre-resolving one fixed model at boot.env.ts— none of the 14 providers' API-key env vars are declared/required; presence is checked withBoolean(process.env.<X>_API_KEY)only, the key itself is never read/stored/logged by our code.workflow.defaultAiModel/defaultAiProvider) are intentionally out of scope per the issue ("can ship as a follow-up") — not implemented here.@ai-sdk/*packages shifted whichajvversion wins forpackages/sdk, breakingapps/ai-studio's typecheck and eslint. Added a scopedpnpm.overridesentry pinningajvonly for@microsoft/tsdoc-config's own resolution.Validation run
pnpm --filter @workflow-builder/execution-worker typecheck— passpnpm --filter @workflow-builder/execution-worker test— 20/20 passed (incl. newmodel-provider.test.tsmechanism tests: auto-inference, explicit provider found/missing-key throw, unknown-provider throw, node→env fallback chain)pnpm typecheck(all 13 workspaces,apps/docsexcluded — untouched, slow astro check) — passpnpm lint(all workspaces) — passpnpm test(all workspaces) — passnpx prettier --check "**/*.+(css|ts|tsx|json|md|mdx|astro)"— passnpx knip— no new unused-export findings after un-exportingproviderOptions(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-studiocomponent tests) and the existingai-agent.test.tsexecutor suite already exercises the OpenRouter execution path end-to-end at the activity level, now routed through the resolver.Risks / follow-ups
@ai-sdk/*deps increaseapps/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.defaultAiModel/defaultAiProvider) intentionally deferred, per the issue.