refactor(workflow-executor): drop direct @langchain dependency#1638
Merged
Scra3 merged 2 commits intoJun 9, 2026
Merged
Conversation
ServerAiAdapter now builds its model through AiClient.getModel (passing a single openai config whose fetch is rewritten to the Forest AI proxy) instead of instantiating ChatOpenAI directly. The remaining BaseChatModel type imports are routed through the @forestadmin/ai-proxy facade, which already re-exports the langchain types the executor needs. This removes @langchain/openai from the package's dependencies — the executor no longer imports from @langchain/* at all; ai-proxy owns the langchain coupling. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (2)
🛟 Help
|
…context build failure The StepExecutorFactory catch returned a generic "An unexpected error occurred." for every construction failure, discarding the userMessage carried by domain errors (e.g. AiModelPortError, StepStateError) thrown while building the execution context — mirroring base-step-executor's existing handling. Also strengthen ServerAiAdapter tests: assert the delegation arguments (loadRemoteTools/closeConnections), the load-bearing apiKey placeholder and the config name, and reset mocks per test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 new issue
|
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.

Why
The executor declared and imported
@langchain/openaidirectly, while@forestadmin/ai-proxyalready owns the langchain coupling (model construction, message/tool types). This removes that duplicated dependency edge.What
ServerAiAdapterno longer instantiatesChatOpenAIitself. It builds a single syntheticopenaiAiConfigurationwhoseconfiguration.fetchis rewritten to hit the Forest AI proxy (/liana/v1/ai-proxy) withforest-secret-key, hands it to theAiClientit already owns, and delegatesgetModel()toAiClient.getModel()(→createBaseChatModel). Runtime behavior is identical; the provider/model is still chosen server-side.BaseChatModeltype imports (server-ai-adapter,ai-client-adapter,always-error-ai-model-port,ports/ai-model-port) now come from the@forestadmin/ai-proxyfaçade, which already re-exports it.@langchain/openairemoved frompackages/workflow-executor/package.json. The executor now imports from@langchain/*zero times —grep -rn "@langchain" srcis empty.Notes
yarn.lockis unchanged:@langchain/openaiis still pulled transitively byai-proxy, so only the workspace dependency edge is dropped.server-ai-adapter.test.tsreworked: it now asserts the config handed toAiClient(provider/model/maxRetries + the fetch redirect to the proxy withforest-secret-key) and thatgetModel()delegates to the client.Verification
yarn workspace @forestadmin/workflow-executor build✅yarn workspace @forestadmin/workflow-executor lint✅ (7 pre-existing warnings)yarn workspace @forestadmin/workflow-executor test→ 967 passed ✅yarn workspace @forestadmin/ai-proxy test→ 443 passed ✅🤖 Generated with Claude Code
Note
Remove direct
@langchain/openaidependency fromworkflow-executorin favor of@forestadmin/ai-proxy@langchain/openaifrom package.json and re-sourcesBaseChatModeland related types through@forestadmin/ai-proxy.ServerAiAdapterto instantiateAiClient(fromai-proxy) with a pre-built proxy configuration via a newbuildProxyConfigurationstatic method, replacing directChatOpenAIconstruction.getModelnow delegates toAiClient.getModel()rather than constructing the model inline; the proxy URL rewriting and header swap (Authorization→forest-secret-key) move into the configuration builder.Changes since #1638 opened
StepExecutorFactory.createfactory method to return executors that surfaceWorkflowExecutorError.userMessageinstepOutcome.errorwhen factory construction fails with aWorkflowExecutorError, replacing the previous generic error message [45c47af]AiClientmocking infrastructure in test files to use explicitjest.fnmocks for constructor argument capture and method delegation [45c47af]StepExecutorFactory.createsurfacesuserMessagefromWorkflowExecutorErrorinstances instepOutcome.error[45c47af]Macroscope summarized b5cbae2.