[PR #7432] [MERGED] fix(capability): forward the embedding input type from packages #7730

Closed
opened 2026-10-24 04:06:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7432
Author: @SpicyMarinara
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/capability-embed-input-type


📝 Commits (3)

  • 8ba43ba fix(capability): forward the embedding input type from packages
  • 5567be4 docs(capability): name Snowflake Arctic Embed v2 as a query-prefix model
  • 22dcdf0 test(capability): cap the embedding fixture's request body

📊 Changes

7 files changed (+117 additions, -11 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/optional-agent-packages.md (+24 -3)
📝 packages/server/src/services/capability-packages/capability-embedding.service.ts (+3 -2)
📝 packages/shared/src/schemas/capability-package.schema.ts (+4 -1)
📝 packages/shared/src/types/capability-runtime.ts (+5 -1)
➕ scripts/regressions/capability-embedding-input-type.regression.ts (+76 -0)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+4 -4)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7429

Thanks to @Promansis for the report, the code trace and the minimal fix this PR follows.

Why this change

  • Packages such as Long-Term Memory embed both stored memories and search queries through the capability embeddings host, but the host had no way to say which is which. The configured host called source.embed(texts, signal), so the memory-recall source defaulted every text to "document".
  • Embedding models with a prefix profile then gave a package's search queries the document prefix: passage: instead of query: on e5 / multilingual-e5, search_document: instead of search_query: on nomic-embed-text, and no prefix instead of query: on Snowflake Arctic Embed v2. Recall is weaker, silently, in any language. The Engine's own chat memory recall already passes the input type; only the package path lost it.

What changed

  • CapabilityEmbeddingHost.embed(texts, signal?, inputType?) in packages/shared/src/types/capability-runtime.ts takes an optional third positional argument, "query" | "document".
  • The configured host in capability-embedding.service.ts forwards it as inputType === "query" ? "query" : "document", so anything other than "query" stays a document, as before.
  • The built-in MiniLM host ignores the argument. Verified: all-MiniLM-L6-v2 is on the plain profile (no query or document prefix), and the Engine's own memory recall also calls the local embedder without an input type.
  • A positional argument, not an options object, as the issue explains: older Engines pass the second argument straight to the provider (AbortSignal.any([signal, timeoutSignal])), so { signal, inputType } would throw there, while an extra positional argument is ignored. Packages can pass it without a version gate.
  • spaceId does not change and nothing needs re-embedding: stored vectors were embedded as documents and stay documents.
  • Capability API bumped to 1.68, following the repo's convention that every additive capability seam gets its own minor (1.67 openCharacter was a soft seam with its own bump too). It is a soft seam: packages do not need to declare 1.68. The version-history comment in capability-package.schema.ts and the version pins in capability-package-lifecycle.regression.ts move with it.
  • docs/development/optional-agent-packages.md: the 1.15 section now lists embed(texts, signal?, inputType?), and a new Capability API 1.68: embed search queries as queries section explains the argument, the default and why it is positional. It names the prefix models as the Engine resolves them in resolveMemoryRecallEmbeddingInputProfile: e5 and nomic-embed-text prefix both queries and documents, Snowflake Arctic Embed v2 prefixes only queries, and the rest, including MiniLM, get no prefix.
  • New regression scripts/regressions/capability-embedding-input-type.regression.ts: a configured connection with intfloat/multilingual-e5-large against a local fixture endpoint; "query" sends query: …, and the default and "document" send passage: …. It fails on staging (the query is sent as passage: Where is the lighthouse?) and passes with this change.
  • CHANGELOG.md entry under [Unreleased].

Package-side follow-up

This PR only changes the Engine host. Long-Term Memory itself must pass "query" for its recall queries, which is tracked in the package repository: Pasta-Devs/Marinara-Agents#1302. Until that ships, LTM's behavior does not change.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Commands the agent ran locally (results as reported by the commands, not a substitute for the boxes above):

  • pnpm check: exit 0
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/capability-embedding-input-type.regression.ts: passed; with the host change stashed it failed as expected
  • node ./scripts/run-regressions.mjs --filter for capability-package-lifecycle, capability-package-chat-controls, memory-recall-revectorize, semantic-summary-settings and prompt: each passed
  • node ./scripts/run-regressions.mjs --filter capability: 19/19 passed
  • coderabbit review --agent --committed --base-commit $(git merge-base HEAD origin/staging): review completed with 0 findings, so nothing was rejected
  • After the review follow-up below: pnpm check exit 0 again, and capability-embedding-input-type, capability-package-lifecycle, memory-recall-revectorize, semantic-summary-settings and prompt each passed again

Review follow-up

  • Fixed: the 1.68 doc section said every model other than e5 and nomic-embed-text gets no prefix, but Snowflake Arctic Embed v2 gets query: on queries (resolveMemoryRecallEmbeddingInputProfile, packages/server/src/services/memory-recall-embedding.ts). The section now names it as a query-only prefix model. This is a wording fix to docs only; the behavior it describes is already pinned by the Snowflake v2 query/document assertions in scripts/regressions/prompt.regression.ts, so no new regression was added. Local CodeRabbit was not re-run for this docs-only wording change.

Manual verification notes

  • Manually verify with a connection whose embedding model is intfloat/multilingual-e5-large (or nomic-embed-text on Ollama) and a package that calls embeddings.embed([query], signal, "query"): the embeddings endpoint log or a proxy shows the query starting with query: (search_query: for nomic), and stored texts still starting with passage: (search_document: ). With a Snowflake Arctic Embed v2 model, the query starts with query: and stored texts have no prefix.
  • Manually verify that Long-Term Memory as published today (without Pasta-Devs/Marinara-Agents#1302) still saves and recalls memories as before.
  • Manually verify that a package on the built-in MiniLM embedder still embeds and recalls normally when it passes "query".

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/development/optional-agent-packages.md exists in every translation pack on docs-i18n; the follow-up issue is #7433. No app version bump; the capability API minor moves to 1.68.

UI evidence (if applicable)

No UI changes.

Summary by CodeRabbit

  • New Features
    • Embedding packages can distinguish search queries from documents, allowing compatible models to apply the appropriate text prefix. Text defaults to document input when no type is specified; older Engines ignore the optional input type.
    • Long-Term Memory uses query-aware embedding with Capability API 1.68.
  • Documentation
    • Updated the optional agent package guidance with input types, compatibility details, and usage examples.
  • Tests
    • Added regression coverage for query and document embedding prefixes.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7432 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/capability-embed-input-type` --- ### 📝 Commits (3) - [`8ba43ba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8ba43ba6fe363c9473e9e85336e4cf567bed408a) fix(capability): forward the embedding input type from packages - [`5567be4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5567be405e36bf03aea8d8c2345fbd542e70bea2) docs(capability): name Snowflake Arctic Embed v2 as a query-prefix model - [`22dcdf0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/22dcdf0b1a43b0df00f971d8bc38142c3936fbc9) test(capability): cap the embedding fixture's request body ### 📊 Changes **7 files changed** (+117 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/optional-agent-packages.md` (+24 -3) 📝 `packages/server/src/services/capability-packages/capability-embedding.service.ts` (+3 -2) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+4 -1) 📝 `packages/shared/src/types/capability-runtime.ts` (+5 -1) ➕ `scripts/regressions/capability-embedding-input-type.regression.ts` (+76 -0) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+4 -4) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7429 Thanks to @Promansis for the report, the code trace and the minimal fix this PR follows. ## Why this change - Packages such as Long-Term Memory embed both stored memories and search queries through the capability embeddings host, but the host had no way to say which is which. The configured host called `source.embed(texts, signal)`, so the memory-recall source defaulted every text to `"document"`. - Embedding models with a prefix profile then gave a package's search queries the document prefix: `passage: ` instead of `query: ` on e5 / multilingual-e5, `search_document: ` instead of `search_query: ` on nomic-embed-text, and no prefix instead of `query: ` on Snowflake Arctic Embed v2. Recall is weaker, silently, in any language. The Engine's own chat memory recall already passes the input type; only the package path lost it. ## What changed - `CapabilityEmbeddingHost.embed(texts, signal?, inputType?)` in `packages/shared/src/types/capability-runtime.ts` takes an optional third positional argument, `"query" | "document"`. - The configured host in `capability-embedding.service.ts` forwards it as `inputType === "query" ? "query" : "document"`, so anything other than `"query"` stays a document, as before. - The built-in MiniLM host ignores the argument. Verified: `all-MiniLM-L6-v2` is on the plain profile (no query or document prefix), and the Engine's own memory recall also calls the local embedder without an input type. - A positional argument, not an options object, as the issue explains: older Engines pass the second argument straight to the provider (`AbortSignal.any([signal, timeoutSignal])`), so `{ signal, inputType }` would throw there, while an extra positional argument is ignored. Packages can pass it without a version gate. - `spaceId` does not change and nothing needs re-embedding: stored vectors were embedded as documents and stay documents. - Capability API bumped to **1.68**, following the repo's convention that every additive capability seam gets its own minor (1.67 `openCharacter` was a soft seam with its own bump too). It is a soft seam: packages do not need to declare 1.68. The version-history comment in `capability-package.schema.ts` and the version pins in `capability-package-lifecycle.regression.ts` move with it. - `docs/development/optional-agent-packages.md`: the 1.15 section now lists `embed(texts, signal?, inputType?)`, and a new **Capability API 1.68: embed search queries as queries** section explains the argument, the default and why it is positional. It names the prefix models as the Engine resolves them in `resolveMemoryRecallEmbeddingInputProfile`: e5 and nomic-embed-text prefix both queries and documents, Snowflake Arctic Embed v2 prefixes only queries, and the rest, including MiniLM, get no prefix. - New regression `scripts/regressions/capability-embedding-input-type.regression.ts`: a configured connection with `intfloat/multilingual-e5-large` against a local fixture endpoint; `"query"` sends `query: …`, and the default and `"document"` send `passage: …`. It fails on `staging` (the query is sent as `passage: Where is the lighthouse?`) and passes with this change. - `CHANGELOG.md` entry under `[Unreleased]`. ### Package-side follow-up This PR only changes the Engine host. Long-Term Memory itself must pass `"query"` for its recall queries, which is tracked in the package repository: Pasta-Devs/Marinara-Agents#1302. Until that ships, LTM's behavior does not change. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Commands the agent ran locally (results as reported by the commands, not a substitute for the boxes above): - `pnpm check`: exit 0 - `node ./scripts/run-regressions.mjs --filter scripts/regressions/capability-embedding-input-type.regression.ts`: passed; with the host change stashed it failed as expected - `node ./scripts/run-regressions.mjs --filter` for `capability-package-lifecycle`, `capability-package-chat-controls`, `memory-recall-revectorize`, `semantic-summary-settings` and `prompt`: each passed - `node ./scripts/run-regressions.mjs --filter capability`: 19/19 passed - `coderabbit review --agent --committed --base-commit $(git merge-base HEAD origin/staging)`: review completed with 0 findings, so nothing was rejected - After the review follow-up below: `pnpm check` exit 0 again, and `capability-embedding-input-type`, `capability-package-lifecycle`, `memory-recall-revectorize`, `semantic-summary-settings` and `prompt` each passed again ### Review follow-up - Fixed: the 1.68 doc section said every model other than e5 and nomic-embed-text gets no prefix, but Snowflake Arctic Embed v2 gets `query: ` on queries (`resolveMemoryRecallEmbeddingInputProfile`, `packages/server/src/services/memory-recall-embedding.ts`). The section now names it as a query-only prefix model. This is a wording fix to docs only; the behavior it describes is already pinned by the Snowflake v2 query/document assertions in `scripts/regressions/prompt.regression.ts`, so no new regression was added. Local CodeRabbit was not re-run for this docs-only wording change. ### Manual verification notes - Manually verify with a connection whose embedding model is `intfloat/multilingual-e5-large` (or `nomic-embed-text` on Ollama) and a package that calls `embeddings.embed([query], signal, "query")`: the embeddings endpoint log or a proxy shows the query starting with `query: ` (`search_query: ` for nomic), and stored texts still starting with `passage: ` (`search_document: `). With a Snowflake Arctic Embed v2 model, the query starts with `query: ` and stored texts have no prefix. - Manually verify that Long-Term Memory as published today (without Pasta-Devs/Marinara-Agents#1302) still saves and recalls memories as before. - Manually verify that a package on the built-in MiniLM embedder still embeds and recalls normally when it passes `"query"`. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/development/optional-agent-packages.md` exists in every translation pack on `docs-i18n`; the follow-up issue is #7433. No app version bump; the capability API minor moves to 1.68. ## UI evidence (if applicable) No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Embedding packages can distinguish search queries from documents, allowing compatible models to apply the appropriate text prefix. Text defaults to document input when no type is specified; older Engines ignore the optional input type. * Long-Term Memory uses query-aware embedding with Capability API 1.68. * **Documentation** * Updated the optional agent package guidance with input types, compatibility details, and usage examples. * **Tests** * Added regression coverage for query and document embedding prefixes. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:56 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7730
No description provided.