fix(codegen): lazy-load @agentic-kit/ollama in embedder template#1252
Draft
yyyyaaa wants to merge 1 commit into
Draft
fix(codegen): lazy-load @agentic-kit/ollama in embedder template#1252yyyyaaa wants to merge 1 commit into
yyyyaaa wants to merge 1 commit into
Conversation
The generated CLI loads every command at boot; the eager top-level @agentic-kit/ollama import crashed the CLI with MODULE_NOT_FOUND when the optional package was absent. Defer to a memoized dynamic import inside the embedder closure with a friendly error. createOllamaEmbedder/resolveEmbedder/buildEmbedder stay synchronous; --auto-embed behavior preserved. Fixes the constructive-hub cli-e2e boot crash.
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.
Summary
The generated CLI embedder module eagerly imports
@agentic-kit/ollamaat module top level. Because the generated CLI statically loads every command at boot (commands.ts→agent/agent-skill→embedder), this crashes the entire CLI withMODULE_NOT_FOUNDwhenever the optional@agentic-kit/ollamapackage isn't installed — even for plain CRUD commands. This broke constructive-hub'scli-e2ejob after the latest SDK regeneration shipped the eager import into the committed CLI.Fix
Defer the provider import in the codegen template (
graphql/codegen/src/core/codegen/templates/embedder.ts): remove the top-levelimport OllamaClient from '@agentic-kit/ollama'and move it to a memoized dynamicimport('@agentic-kit/ollama')inside the embedder closure, throwing a friendly "install @agentic-kit/ollama" error only if the ollama embedder is actually invoked.createOllamaEmbedder/resolveEmbedder/buildEmbedderstay synchronous (no signature change → no ripple into generatedagent-skillcallers)baseUrl/model/generateEmbedding(text, model)/result.embeddingpreserved--auto-embedbehavior unchanged; matches the existingawait import()idiom in the codegenVerification
pnpm --filter @constructive-io/graphql-codegen buildpasses (tsc CJS + ESM +copy:templates); the shippeddisttemplate has no top-level@agentic-kit/ollamaimport. Cross-checked against the package's actualexport default OllamaClientandgenerateEmbedding(text, model?)signature.Follow-up
After this is published (new
@constructive-io/graphql-codegen> 4.47.0), constructive-db regeneratessdk/constructive-cli/(and adds@agentic-kit/ollamatooptionalDependencies), which lets constructive-hub remove its temporarycli-e2eskip.🤖 Generated with Claude Code