Skip to content

feat(embeddings): store knowledge bases at five vector widths and add Ollama - #7472

Merged
waleedlatif1 merged 5 commits into
stagingfrom
staging-v104
Sep 4, 2026
Merged

feat(embeddings): store knowledge bases at five vector widths and add Ollama#7472
waleedlatif1 merged 5 commits into
stagingfrom
staging-v104

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • Knowledge bases were pinned to one 1536-dimension pgvector column, so only models emitting exactly that width could index one. embedding now has a column per storable width — 384, 768, 1024, 1536, 3072 — and a base records which one it uses at creation
  • New EMBEDDING_OUTPUT_DIMS picks that width. A value the deployment can't store, or one the configured model can't emit, warns and falls back to 1536 rather than failing knowledge-base creation
  • KB_EMBEDDING_MODEL accepts ollama/<model>, so a self-hosted deployment can index against its own Ollama with no API key and nothing billed
  • The Embeddings block gains Ollama: the model list is read live off the configured server, filtered to embedding-capable models, with each one's vector width in the label. No API key field, and no task-type or dimension controls, since the API accepts neither
  • pgvector only indexes vector up to 2,000 dimensions, so the 3072 column is indexed through a halfvec cast. Queries have to repeat that exact cast to use the index, so the distance expression for every width comes from one place
  • Cross-KB search now rejects mixed widths as well as mixed models — vectors are only comparable at the same size, and two bases on the same model at different widths live in different columns
  • sim-setup gains Gemini and Ollama options, and sim-setup status now reports the one family KB_EMBEDDING_MODEL actually selects instead of every provider a key exists for. Gemini previously displayed as "OpenAI"

Type of Change

  • New feature

Testing

Tested manually against a local Postgres (pgvector 0.8.0) and a real Ollama:

  • All five widths end to end — embed, store, retrieve through executeKnowledgeSearch in hybrid and vector mode — with ollama/nomic-embed-text (768), ollama/all-minilm (384), text-embedding-3-large (3072 and 1024), and text-embedding-3-small (1536)
  • EXPLAIN confirms each width hits its own HNSW index, and that 3072 without the halfvec cast falls to a sequential scan
  • embedding_width_check rejects rows with no vector and rows with two; the migration applies from the pre-migration shape and is replay-safe
  • A model returning a different width than the base stores fails with both numbers named
  • Block path verified through the registered in-process tool handler; the selector filters chat models out
  • Full suite green (40,960 tests in apps/sim, all packages), turbo type-check, bun run lint, check:audits (45 audits), docs-manifest:check, block-registry check, and check:migrations origin/staging

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 4, 2026 7:54pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR expands knowledge-base embedding storage to five vector widths and adds Ollama support for knowledge-base indexing and the Embeddings block.

  • Adds dimension-specific vector columns, indexes, constraints, and centralized query expressions.
  • Records each knowledge base’s embedding model and width and prevents incompatible cross-base searches.
  • Adds Ollama model discovery, embedding execution, setup configuration, documentation, and tests.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains in the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/db/migrations/0321_multi_width_embeddings.sql Adds width-specific vector columns, a one-vector-per-row constraint, and matching HNSW indexes, including the 3072-dimensional halfvec expression index.
apps/sim/lib/knowledge/vector-columns.ts Centralizes vector-column writes and distance expressions for all supported widths.
apps/sim/lib/knowledge/application/search.ts Resolves the stored embedding target, rejects incompatible multi-base searches, and routes query vectors to the matching column.
apps/sim/lib/embeddings/client.ts Extends embedding execution to support Ollama and dimension-aware knowledge-base targets.
apps/sim/lib/embeddings/ollama-model-catalog.server.ts Discovers locally available Ollama models and extracts embedding capabilities and vector widths.
apps/sim/blocks/blocks/embeddings.ts Adds Ollama as a keyless Embeddings block provider with a live model selector.
packages/sim-setup/src/capability-config.ts Adds setup options for Ollama and Gemini knowledge-base embedding configurations.

Sequence Diagram

sequenceDiagram
  participant User
  participant API as Knowledge API
  participant Provider as Embedding Provider
  participant DB as PostgreSQL/pgvector
  User->>API: Create knowledge base
  API->>Provider: Resolve model and vector width
  API->>DB: Store model and width
  User->>API: Upload document
  API->>Provider: Generate embeddings
  API->>DB: Write width-specific vector column
  User->>API: Search compatible knowledge bases
  API->>Provider: Generate query embedding
  API->>DB: Compare through matching vector expression/index
  DB-->>API: Ranked chunks
  API-->>User: Search results
Loading

Reviews (5): Last reviewed commit: "fix(embeddings): one rule for a configur..." | Re-trigger Greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 77 files

Re-trigger cubic

Comment thread packages/db/migrations/0321_multi_width_embeddings.sql
Comment thread apps/sim/lib/knowledge/documents/service.ts Outdated
Comment thread apps/sim/lib/embeddings/catalog.ts
Comment thread apps/sim/lib/embeddings/client.ts
Comment thread packages/deployment-config/src/env-capabilities.ts
Comment thread packages/sim-setup/src/capability-config.ts
Comment thread apps/docs/content/docs/integrations/embeddings.mdx Outdated
Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.ts Outdated
Comment thread apps/sim/app/api/v1/knowledge/search/route.ts Outdated
Comment thread packages/deployment-config/src/env-capabilities.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

12 issues found across 78 files

Confidence score: 2/5

  • apps/sim/lib/knowledge/embeddings.ts records Ollama models at a hard-coded width when lookup fails or returns an unsupported width, while the runtime returns the model’s native width; this can produce incorrect embedding-dimension handling across embeddings — preserve the native width or fail clearly.
  • packages/deployment-config/src/env-capabilities.ts and packages/sim-setup/src/capability-config.ts can classify or preserve incompatible model values when credentials contain whitespace or users switch providers, causing status to misreport the active provider or setup transitions to fail — normalize IDs and reset provider-specific defaults.
  • apps/sim/lib/internal/embeddings/operations.ts turns selected-model inspection failures into a misleading “missing model” 400 and performs an uncached full-catalog scan for every Ollama request; this can obscure upstream outages and add avoidable latency — preserve upstream errors and inspect or cache only the selected model.
  • apps/sim/blocks/blocks/embeddings.ts can carry stale keyed-provider credentials into Ollama workflows, while apps/sim/lib/knowledge/embeddings.test.ts removes direct billing-attribution coverage; clear both credential fields and retain tests for usage, cost, and threshold billing before relying on the provider transition.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/deployment-config/src/integrations.json">

<violation number="1" location="packages/deployment-config/src/integrations.json:7463">
P2: After adding Ollama to this catalog description, the integration page still tells users to paste an Embeddings API key. Add provider-aware auth copy (or model this entry as supporting multiple auth modes) so Ollama users are told to configure `OLLAMA_URL` instead.</violation>
</file>

<file name="apps/sim/lib/knowledge/embeddings.test.ts">

<violation number="1" location="apps/sim/lib/knowledge/embeddings.test.ts:27">
P2: This rewrite removes the only direct behavioral test for `recordSearchEmbeddingUsage` (billing attribution, cost calculation, and threshold billing), and the function is still in production unchanged. The two remaining references to it are both mocked imports, so a regression in that billing path would now pass CI undetected. Add coverage for `recordSearchEmbeddingUsage` (e.g. a separate describe block in this file) alongside the new `getConfiguredKbEmbedding` tests.</violation>
</file>

<file name="apps/docs/content/docs/platform/self-hosting/troubleshooting.mdx">

<violation number="1" location="apps/docs/content/docs/platform/self-hosting/troubleshooting.mdx:253">
P2: When `OPENROUTER_API_KEY` is the only configured embedding credential, the knowledge-base fallback can serve OpenAI-family models, but this troubleshooting list omits it and directs operators to another provider. Document the OpenRouter fallback and keep the `KB_EMBEDDING_MODEL`/`EMBEDDING_OUTPUT_DIMS` guidance alongside it.

(Based on your team's feedback about OpenRouter knowledge-base setup.)</violation>
</file>

<file name="packages/deployment-config/src/env-capabilities.ts">

<violation number="1" location="packages/deployment-config/src/env-capabilities.ts:1269">
P2: When `KB_EMBEDDING_MODEL` contains surrounding whitespace, `knowledgeEmbeddingFamily` selects Gemini or Ollama while the runtime rejects that raw ID and falls back to OpenAI’s default. Status can therefore report the non-OpenAI credentials as configured while embedding calls use the wrong model or fail; classify the raw value to match runtime routing.</violation>
</file>

<file name="apps/sim/lib/internal/embeddings/operations.ts">

<violation number="1" location="apps/sim/lib/internal/embeddings/operations.ts:95">
P2: When the selected model’s `/api/show` fails after `/api/tags` succeeds, this call makes the operation report the installed model as missing with HTTP 400. Preserve selected-model inspection failures as upstream errors (502), or query the selected model directly so transient Ollama failures are not presented as a pull request.</violation>

<violation number="2" location="apps/sim/lib/internal/embeddings/operations.ts:95">
P2: Every Ollama embedding request now performs an uncached full-catalog scan, adding O(number of installed models) network work and waiting on unrelated model probes. Query only the selected model or reuse a cached catalog with bounded refreshes so one unrelated `/api/show` cannot delay every embedding.</violation>
</file>

<file name="apps/sim/blocks/blocks/embeddings.ts">

<violation number="1" location="apps/sim/blocks/blocks/embeddings.ts:277">
P2: When a workflow switches from a keyed provider to Ollama, the generic executor preserves the stale `apiKey` and `openRouterApiKey` because this branch omits them. Clear both credential fields explicitly so they do not cross into and get serialized by the Ollama tool operation.</violation>
</file>

<file name="packages/sim-setup/src/capability-config.ts">

<violation number="1" location="packages/sim-setup/src/capability-config.ts:743">
P2: When an existing installation uses Gemini or Ollama, selecting an OpenAI-family option preserves that incompatible model value and the setup transition rejects the selection. Reset the model to an OpenAI default when switching families, or make the prompt provider-aware so the user is not required to discover and clear the stale value manually.</violation>
</file>

<file name="apps/docs/content/docs/integrations/embeddings.mdx">

<violation number="1" location="apps/docs/content/docs/integrations/embeddings.mdx:22">
P2: Recent Ollama builds accept `dimensions` for Matryoshka models; the adapter omits it for compatibility. Describe the block as not exposing this control, rather than claiming Ollama rejects it.</violation>

<violation number="2" location="apps/docs/content/docs/integrations/embeddings.mdx:22">
P2: Using Ollama avoids provider/API charges, but Sim still applies its base run charge. Replace “costs nothing” with “incurs no provider/API charge” to avoid misleading billing expectations.</violation>
</file>

<file name="apps/docs/content/docs/platform/self-hosting/environment-variables.mdx">

<violation number="1" location="apps/docs/content/docs/platform/self-hosting/environment-variables.mdx:202">
P3: When `EMBEDDING_OUTPUT_DIMS` is unset for Ollama, `getConfiguredKbEmbedding` reads `/api/show` and uses its reported width, so Sim does know the model width. Hosted unsupported values fall back to `1536`; only an explicitly mismatched Ollama width reaches document failure, so distinguish these paths here.</violation>
</file>

<file name="apps/sim/lib/knowledge/embeddings.ts">

<violation number="1" location="apps/sim/lib/knowledge/embeddings.ts:127">
P1: When Ollama width lookup fails or returns an unsupported width, this fallback records the same model at 1536. Ollama does not send a dimensions override, so fixed-width models return their native width and every embedding call then fails response validation; reject the target or choose a compatible model instead.</violation>
</file>

Re-trigger cubic

Comment thread apps/sim/lib/knowledge/embeddings.ts
Comment thread packages/deployment-config/src/integrations.json
Comment thread apps/docs/content/docs/integrations/embeddings.mdx Outdated
Comment thread apps/docs/content/docs/integrations/embeddings.mdx Outdated
Comment thread apps/sim/lib/knowledge/embeddings.test.ts Outdated
Comment thread apps/sim/lib/internal/embeddings/operations.ts
Comment thread apps/sim/lib/internal/embeddings/operations.ts
Comment thread apps/sim/blocks/blocks/embeddings.ts
Comment thread packages/sim-setup/src/capability-config.ts Outdated
Comment thread apps/docs/content/docs/platform/self-hosting/environment-variables.mdx Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@cubic review

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 78 files

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

Comment thread packages/sim-setup/src/capability-config.ts
Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.ts
Comment thread apps/sim/blocks/blocks/embeddings.ts
Comment thread apps/docs/content/docs/platform/self-hosting/environment-variables.mdx Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 78 files

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.ts
Comment thread apps/sim/blocks/blocks/embeddings.ts
Comment thread packages/deployment-config/src/env-capabilities.ts
Comment thread apps/sim/lib/knowledge/embeddings.ts Outdated
Comment thread packages/sim-setup/src/capability-config.ts
Comment thread apps/docs/content/docs/integrations/embeddings.mdx Outdated
Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.ts
Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.test.ts
Comment thread apps/docs/content/docs/platform/self-hosting/environment-variables.mdx Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 78 files

Requires human review: Auto-approval blocked by 15 unresolved issues from a previous review of this commit.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

Comment thread packages/sim-setup/src/capability-config.ts
Comment thread packages/sim-setup/src/capability-config.ts
Comment thread apps/docs/content/docs/platform/self-hosting/environment-variables.mdx Outdated
Comment thread apps/docs/content/docs/platform/self-hosting/environment-variables.mdx Outdated
Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.ts
Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.ts
Comment thread apps/sim/lib/embeddings/ollama-model-catalog.server.test.ts
Comment thread apps/docs/content/docs/integrations/embeddings.mdx Outdated
Comment thread apps/docs/content/docs/platform/self-hosting/environment-variables.mdx Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

… Ollama

Knowledge bases were pinned to one 1536-dimension pgvector column, so only
models that emit exactly that width could index one. The embedding table now
carries a column per storable width — 384, 768, 1024, 1536, 3072 — and a base
records which one it uses at creation, chosen with EMBEDDING_OUTPUT_DIMS.

Ollama becomes an embedding provider on both paths: KB_EMBEDDING_MODEL accepts
ollama/<model> for knowledge bases, and the Embeddings block offers the models
installed on the configured server, with no API key and nothing billed.
…amily gating

Round of review findings:

- Size the shared indexing batch for the widest storable width; the aggregate
  guard rejects rather than splits, so a 3,072-wide base past 1,064 chunks failed
- Resolve an unstated Ollama width from the server instead of defaulting to 1,536
- Substitute EMBEDDING_OUTPUT_DIMS alongside the model when evaluating the
  knowledge-embedding capability, so the chain is judged for the target at hand
- Classify the embedding family exactly as the runtime does, so an id the runtime
  rejects cannot report its family as configured
- Validate a capability field against the provider being configured, not the first
  one declaring the key, which rejected 384 in the Ollama wizard branch
- Give OpenRouter the OpenAI-family model and width fields it was missing
- Resolve model records by own property, so KB_EMBEDDING_MODEL=toString falls back
- Narrow a knowledge base's width only for query searches, not tag-only ones
- Report an unreachable Ollama as 502 rather than a missing model
- Correct the sim-setup command and scope, the Ollama filtering claims, and the
  unstorable-width troubleshooting advice in the docs
… path

Second round of review findings:

- Restore apps/sim/lib/knowledge/embeddings.test.ts, whose recordSearchEmbeddingUsage
  suite a whole-file write had destroyed; the new configuration tests move to a
  sibling file so the original's vi.spyOn wiring stays intact
- Refuse to create a knowledge base when an Ollama model's width cannot be
  established, rather than pinning it at 1536 where every document would fail
- Resolve an Ollama model through /api/show for that model alone instead of
  scanning the catalog, so one unrelated probe cannot delay or break an embedding,
  and a 404 stays a 400 while anything else is a 502
- Classify the raw KB_EMBEDDING_MODEL value, since the runtime does not trim it
- Clear apiKey and openRouterApiKey explicitly when switching a block to Ollama
- Offer the OpenAI-family embedding model as a choice, so switching families in
  the wizard cannot carry a Gemini or Ollama model forward
- Correct the docs on Ollama dimension support, run charges, the OpenRouter
  knowledge-base fallback, and what Sim can determine about a local model's width
… target

Third round of review findings:

- Require an explicit OLLAMA_URL before resolving a model's width, matching what
  the embedding client already demands, so a loopback server cannot produce a
  knowledge base every later call refuses to serve
- Validate EMBEDDING_OUTPUT_DIMS against the selected model rather than its
  family, since the family pattern accepted widths the model silently overrides
- Raise a validation error for a missing model or unreportable width, so the
  route renders 400 instead of a generic 500
- Stop the Embeddings block auto-persisting whichever model Ollama lists first
- Do not offer back a configured value that the provider being set up rejects,
  so switching families cannot carry the previous family's model forward
- Cancel the response body of a rejected Ollama probe
- Make the drop-on-inspection-failure test actually exercise that path
- Correct the setup provider list, the older-Ollama filtering caveat, and the
  Sim Cloud OLLAMA_URL claim in the docs
…rcing its width

Fourth round of review findings:

- Make the setup wizard's EMBEDDING_OUTPUT_DIMS optional and undefaulted for
  Ollama; requiring it suppressed the server-side width detection entirely, and
  its 768 default was wrong for a 384-wide model
- Replace three different notions of 'an Ollama server is configured' with one
  predicate shared by the selector, the width lookup, and the embedding client:
  self-hosted is served by the loopback default as the chat provider already is,
  and only hosted must be pointed at a server
- Document that an ollama/ model id is taken at face value rather than falling
  back, so a model absent from the server fails creation
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
waleedlatif1 merged commit f8d037a into staging Sep 4, 2026
31 checks passed
@waleedlatif1
waleedlatif1 deleted the staging-v104 branch September 4, 2026 20:12
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 existing issue remains and 3 new issues found across 78 files

Confidence score: 3/5

  • apps/sim/lib/embeddings/ollama-model-catalog.server.ts can classify a reachable non-Ollama endpoint returning 404 from /api/show as a missing model, obscuring the configuration or service error; preserve the response status in a typed error and only classify expected missing-model responses.
  • apps/docs/content/docs/integrations/embeddings.mdx may lead users on Ollama versions before 0.5 to select chat models because /api/show can omit capabilities while still providing embedding_length; document the 0.5 cutoff and the resulting selector behavior.
  • apps/docs/content/docs/platform/self-hosting/environment-variables.mdx does not clearly identify that an explicitly set EMBEDDING_OUTPUT_DIMS can allow knowledge-base creation with a missing Ollama model before failing during width discovery or document indexing; clarify the actual failure point.
  • packages/sim-setup/src/capability-config.ts advertises 3072 for the default text-embedding-3-small, even though final validation rejects that width; make the hint list widths for the selected model.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/docs/content/docs/integrations/embeddings.mdx">

<violation number="1" location="apps/docs/content/docs/integrations/embeddings.mdx:22">
P2: On Ollama versions older than 0.5, `/api/show` may omit capabilities while still reporting `embedding_length`, so the selector can include chat models without losing width labels. Name the 0.5 cutoff and tell users to verify the model or upgrade.

(Based on your team's feedback about the Ollama older-server caveat.)</violation>
</file>

<file name="packages/sim-setup/src/capability-config.ts">

<violation number="1" location="packages/sim-setup/src/capability-config.ts:777">
P3: When the operator keeps the default `text-embedding-3-small`, this hint advertises 3072 even though that model cannot emit it, so final setup validation rejects the value. Make the hint list widths per selected model.</violation>
</file>

<file name="apps/docs/content/docs/platform/self-hosting/environment-variables.mdx">

<violation number="1" location="apps/docs/content/docs/platform/self-hosting/environment-variables.mdx:193">
P2: When `EMBEDDING_OUTPUT_DIMS` is explicitly set, a missing Ollama model leaves the knowledge base created and fails later document indexing. Describe width discovery or document indexing as the failure point instead of claiming knowledge-base creation always fails.</violation>
</file>

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Fix all with cubic | Re-trigger cubic

Two things worth knowing before you build on it. Vectors are only comparable when they come from the same model at the same size, so changing either means re-embedding everything you intend to compare. And input longer than the model's limit is shortened to fit rather than rejected, with a warning in the run, so chunk long documents yourself when the tail matters.

Sim's knowledge bases embed separately, at a fixed vector width and from a smaller set of models. This block is for embedding text yourself inside a workflow.
Ollama is the exception to most of the above. It runs on your own deployment, so it needs no API key and adds no provider charge — Sim's own per-run charge still applies — and the model list is whatever you have pulled onto that server rather than a catalog Sim maintains. The block reads it live, drops the models that report a non-embedding capability, and shows each one's vector width next to its name where Ollama reports one. A server too old to report either will list its chat models too and label none of them, so check the model you pick. The block offers no task-type or dimension control for Ollama: task conditioning has no equivalent there, and while recent Ollama builds do accept a dimension override for Matryoshka models, older ones silently ignore it, so Sim uses each model's own width rather than one that may or may not take effect. Point Sim at the server with `OLLAMA_URL`. Sim Cloud runs no Ollama of its own, so without that variable the list comes back empty rather than dialling a loopback address that cannot answer — set it to a reachable server and Cloud will use it like any other deployment.

@cubic-dev-ai cubic-dev-ai Bot Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: On Ollama versions older than 0.5, /api/show may omit capabilities while still reporting embedding_length, so the selector can include chat models without losing width labels. Name the 0.5 cutoff and tell users to verify the model or upgrade.

(Based on your team's feedback about the Ollama older-server caveat.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/docs/content/docs/integrations/embeddings.mdx, line 22:

<comment>On Ollama versions older than 0.5, `/api/show` may omit capabilities while still reporting `embedding_length`, so the selector can include chat models without losing width labels. Name the 0.5 cutoff and tell users to verify the model or upgrade.

(Based on your team's feedback about the Ollama older-server caveat.) </comment>

<file context>
@@ -13,19 +13,21 @@ import { BlockInfoCard } from "@/components/ui/block-info-card"
 Two things worth knowing before you build on it. Vectors are only comparable when they come from the same model at the same size, so changing either means re-embedding everything you intend to compare. And input longer than the model's limit is shortened to fit rather than rejected, with a warning in the run, so chunk long documents yourself when the tail matters.
 
-Sim's knowledge bases embed separately, at a fixed vector width and from a smaller set of models. This block is for embedding text yourself inside a workflow.
+Ollama is the exception to most of the above. It runs on your own deployment, so it needs no API key and adds no provider charge — Sim's own per-run charge still applies — and the model list is whatever you have pulled onto that server rather than a catalog Sim maintains. The block reads it live, drops the models that report a non-embedding capability, and shows each one's vector width next to its name where Ollama reports one. A server too old to report either will list its chat models too and label none of them, so check the model you pick. The block offers no task-type or dimension control for Ollama: task conditioning has no equivalent there, and while recent Ollama builds do accept a dimension override for Matryoshka models, older ones silently ignore it, so Sim uses each model's own width rather than one that may or may not take effect. Point Sim at the server with `OLLAMA_URL`. Sim Cloud runs no Ollama of its own, so without that variable the list comes back empty rather than dialling a loopback address that cannot answer — set it to a reachable server and Cloud will use it like any other deployment.
+
+Sim's knowledge bases embed separately: a base fixes one model and one vector width when it is created, from a smaller set of models. This block is for embedding text yourself inside a workflow.
</file context>
Suggested change
Ollama is the exception to most of the above. It runs on your own deployment, so it needs no API key and adds no provider charge — Sim's own per-run charge still applies — and the model list is whatever you have pulled onto that server rather than a catalog Sim maintains. The block reads it live, drops the models that report a non-embedding capability, and shows each one's vector width next to its name where Ollama reports one. A server too old to report either will list its chat models too and label none of them, so check the model you pick. The block offers no task-type or dimension control for Ollama: task conditioning has no equivalent there, and while recent Ollama builds do accept a dimension override for Matryoshka models, older ones silently ignore it, so Sim uses each model's own width rather than one that may or may not take effect. Point Sim at the server with `OLLAMA_URL`. Sim Cloud runs no Ollama of its own, so without that variable the list comes back empty rather than dialling a loopback address that cannot answer — set it to a reachable server and Cloud will use it like any other deployment.
Ollama is the exception to most of the above. It runs on your own deployment, so it needs no API key and adds no provider charge — Sim's own per-run charge still applies — and the model list is whatever you have pulled onto that server rather than a catalog Sim maintains. The block reads it live, drops the models that report a non-embedding capability, and shows each one's vector width next to its name where Ollama reports one. Ollama only began reporting capabilities in version 0.5; older servers may leave chat models in the list, even when they still report widths, so verify the model you pick or upgrade. The block offers no task-type or dimension control for Ollama: task conditioning has no equivalent there, and while recent Ollama builds do accept a dimension override for Matryoshka models, older ones silently ignore it, so Sim uses each model's own width rather than one that may or may not take effect. Point Sim at the server with `OLLAMA_URL`. Sim Cloud runs no Ollama of its own, so without that variable the list comes back empty rather than dialling a loopback address that cannot answer — set it to a reachable server and Cloud will use it like any other deployment.
Fix with cubic

| Variable | Description |
|----------|-------------|
| `KB_EMBEDDING_MODEL` | Embedding model for new knowledge bases. Defaults to `text-embedding-3-small`; an unsupported value falls back to the default |
| `KB_EMBEDDING_MODEL` | Embedding model for new knowledge bases. Defaults to `text-embedding-3-small`; use `ollama/<model>` for a model on your own Ollama. An unrecognised hosted model id falls back to the default, but an `ollama/` id is taken at face value — if that model is not on the server, knowledge-base creation fails rather than falling back |

@cubic-dev-ai cubic-dev-ai Bot Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When EMBEDDING_OUTPUT_DIMS is explicitly set, a missing Ollama model leaves the knowledge base created and fails later document indexing. Describe width discovery or document indexing as the failure point instead of claiming knowledge-base creation always fails.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/docs/content/docs/platform/self-hosting/environment-variables.mdx, line 193:

<comment>When `EMBEDDING_OUTPUT_DIMS` is explicitly set, a missing Ollama model leaves the knowledge base created and fails later document indexing. Describe width discovery or document indexing as the failure point instead of claiming knowledge-base creation always fails.</comment>

<file context>
@@ -190,10 +190,43 @@ See [Observability](/platform/self-hosting/observability).
 | Variable | Description |
 |----------|-------------|
-| `KB_EMBEDDING_MODEL` | Embedding model for new knowledge bases. Defaults to `text-embedding-3-small`; an unsupported value falls back to the default |
+| `KB_EMBEDDING_MODEL` | Embedding model for new knowledge bases. Defaults to `text-embedding-3-small`; use `ollama/<model>` for a model on your own Ollama. An unrecognised hosted model id falls back to the default, but an `ollama/` id is taken at face value — if that model is not on the server, knowledge-base creation fails rather than falling back |
+| `EMBEDDING_OUTPUT_DIMS` | Vector width new knowledge bases are stored at: `384`, `768`, `1024`, `1536` (default), or `3072`. It must be a width the chosen model can emit; anything else falls back to `1536` with a warning |
 | `OPENROUTER_API_KEY` | Fallback route for the OpenAI embedding models — used when it is set and `OPENAI_API_KEY` is not the chosen path |
</file context>
Suggested change
| `KB_EMBEDDING_MODEL` | Embedding model for new knowledge bases. Defaults to `text-embedding-3-small`; use `ollama/<model>` for a model on your own Ollama. An unrecognised hosted model id falls back to the default, but an `ollama/` id is taken at face value — if that model is not on the server, knowledge-base creation fails rather than falling back |
| `KB_EMBEDDING_MODEL` | Embedding model for new knowledge bases. Defaults to `text-embedding-3-small`; use `ollama/<model>` for a model on your own Ollama. An unrecognised hosted model id falls back to the default, but an `ollama/` id is taken at face value — if that model is not on the server, width discovery or document indexing fails rather than falling back |
Fix with cubic

type: 'field',
key: 'EMBEDDING_OUTPUT_DIMS',
input: 'text',
hint: 'optional vector width for new knowledge bases: 768, 1024, 1536 (default), or 3072',

@cubic-dev-ai cubic-dev-ai Bot Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: When the operator keeps the default text-embedding-3-small, this hint advertises 3072 even though that model cannot emit it, so final setup validation rejects the value. Make the hint list widths per selected model.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/sim-setup/src/capability-config.ts, line 777:

<comment>When the operator keeps the default `text-embedding-3-small`, this hint advertises 3072 even though that model cannot emit it, so final setup validation rejects the value. Make the hint list widths per selected model.</comment>

<file context>
@@ -731,6 +731,54 @@ export const KNOWLEDGE_SETUP = defineCapabilitySetup(OCR_CAPABILITY, {
+    type: 'field',
+    key: 'EMBEDDING_OUTPUT_DIMS',
+    input: 'text',
+    hint: 'optional vector width for new knowledge bases: 768, 1024, 1536 (default), or 3072',
+    validate: true,
+  },
</file context>
Suggested change
hint: 'optional vector width for new knowledge bases: 768, 1024, 1536 (default), or 3072',
hint: 'optional vector width; small: 768, 1024, or 1536 (default); large: 768, 1024, 1536, or 3072',
Fix with cubic

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.

2 participants