Skip to content

feat(workflow-executor): server-side AI fallback #1530

Open
Scra3 wants to merge 1 commit intofeat/prd-214-setup-workflow-executor-packagefrom
feature/prd-271-server-side-ai-fallback
Open

feat(workflow-executor): server-side AI fallback #1530
Scra3 wants to merge 1 commit intofeat/prd-214-setup-workflow-executor-packagefrom
feature/prd-271-server-side-ai-fallback

Conversation

@Scra3
Copy link
Copy Markdown
Member

@Scra3 Scra3 commented Apr 3, 2026

Summary

When aiConfigurations is empty or not provided, the executor automatically falls back to the Forest Admin server AI proxy via ChatOpenAI with a custom baseURL.

What changes

  • aiConfigurations becomes optional in ExecutorOptions
  • If absent: creates an AiConfiguration with baseURL pointing to {forestServerUrl}/liana/v1
  • JWT signed with envSecret used as apiKey for auth
  • Zero changes in ai-proxy — the fallback is a standard config

What doesn't change

  • Executors — still call model.invoke() / model.bindTools() transparently
  • Tool execution — stays 100% local on client infra
  • Privacy — server only sees tool definitions and messages, never client data

Dependency

Requires PRD-270 (server route POST /liana/v1/chat/completions)

Test plan

  • yarn workspace @forestadmin/workflow-executor test — 427 tests pass
  • yarn workspace @forestadmin/workflow-executor tsc --noEmit — compiles

fixes PRD-271

🤖 Generated with Claude Code

Note

Add server-side AI proxy fallback to workflow executor

  • Introduces a new AiModelPort interface in ai-model-port.ts to abstract AI model acquisition, replacing direct AiClient usage throughout the executor.
  • Adds ServerAiAdapter in server-ai-adapter.ts, which routes LLM calls through the Forest Admin server proxy (/liana/v1/ai-proxy) using per-step signed JWTs containing envId, userId, runId, and stepIndex.
  • Adds AiClientAdapter in ai-client-adapter.ts wrapping the existing AiClient for when aiConfigurations are explicitly provided.
  • buildCommonDependencies in build-workflow-executor.ts selects AiClientAdapter when aiConfigurations are provided, and falls back to ServerAiAdapter otherwise; aiConfigurations is now optional.
  • Behavioral Change: PendingStepExecution now requires a new envId field; callers constructing step executions must provide it.

Macroscope summarized dfd2d3e.

@linear
Copy link
Copy Markdown

linear bot commented Apr 3, 2026

@Scra3 Scra3 force-pushed the feature/prd-271-server-side-ai-fallback branch 3 times, most recently from 4e447cf to fb8c9f3 Compare April 3, 2026 10:00
@qltysh
Copy link
Copy Markdown

qltysh bot commented Apr 3, 2026

1 new issue

Tool Category Rule Count
qlty Structure Function with high complexity (count = 16): stop 1

@Scra3 Scra3 force-pushed the feature/prd-271-server-side-ai-fallback branch 8 times, most recently from 4970993 to 9c5ad21 Compare April 3, 2026 14:05
@qltysh
Copy link
Copy Markdown

qltysh bot commented Apr 3, 2026

Qlty

Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (4)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
packages/workflow-executor/src/runner.ts100.0%
Coverage rating: B Coverage rating: B
packages/workflow-executor/src/build-workflow-executor.ts100.0%
New file Coverage rating: A
packages/workflow-executor/src/adapters/server-ai-adapter.ts100.0%
New file Coverage rating: A
packages/workflow-executor/src/adapters/ai-client-adapter.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@Scra3 Scra3 changed the title feat(workflow-executor): server-side AI fallback (PRD-271) feat(workflow-executor): server-side AI fallback Apr 3, 2026
@Scra3 Scra3 force-pushed the feature/prd-271-server-side-ai-fallback branch from 9c5ad21 to d6fa215 Compare April 3, 2026 14:19
Introduce AiModelPort interface (same pattern as AgentPort, WorkflowPort)
with two implementations:
- AiClientAdapter: wraps AiClient for user-provided aiConfigurations
- ServerAiAdapter: ChatOpenAI with baseURL pointing to FA server,
  JWT per step with userId/runId/stepIndex for monitoring

aiConfigurations becomes optional in ExecutorOptions. Zero changes
in ai-proxy — all fallback logic stays in workflow-executor.

fixes PRD-271

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Scra3 Scra3 force-pushed the feature/prd-271-server-side-ai-fallback branch from d6fa215 to dfd2d3e Compare April 3, 2026 15:29
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