[GH-ISSUE #7429] [Issue]: Capability embeddings host drops the query/document input type #4139

Closed
opened 2026-10-21 06:11:30 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Promansis on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7429

Originally assigned to: @SpicyMarinara on GitHub.

Summary

The configured capability embeddings host calls source.embed(texts, signal) without an input type. As a result, every text a package embeds is formatted as a document, including search queries. Long-Term Memory's recall queries never get the query prefix that E5, nomic-embed-text and Snowflake Arctic Embed v2 models expect. Chat memory recall inside the Engine already passes the input type; only the package path loses it.

Expected behavior

A package can say whether the texts are search queries or documents. The host passes that on to resolveMemoryRecallEmbeddingSource(...).embed(texts, signal, inputType), so formatMemoryRecallEmbeddingTexts applies the right prefix.

Actual behavior

  • CapabilityEmbeddingHost.embed(texts, signal?) has no input-type parameter (capability-runtime.ts L368).

  • The configured host calls source.embed(texts, signal) (capability-embedding.service.ts L36-L40),`` so the source's inputType falls back to "document".

  • resolveMemoryRecallEmbeddingInputProfile```` then gives package queries the document prefix:

    Model profile Query should get Query actually gets
    e5 / multilingual-e5 query: passage:
    nomic-embed-text search_query: search_document:
    snowflake-arctic-embed v2 query: no prefix
  • Models on the plain profile have empty prefixes for both, so they are not affected. That includes the built-in MiniLM, bge-m3, OpenAI and Gemini embedding models.

The effect is weaker semantic recall for packages that use these models, in any language. Nothing crashes and nothing is logged.

Steps to reproduce

  1. Give the connection Long-Term Memory uses an embedding model with a prefix profile, for example intfloat/multilingual-e5-large, or nomic-embed-text on Ollama. LTM uses the default connection, or the one set with Connections → apply to all agents.
  2. Install Long-Term Memory, save a few memories, and send chat messages until recall runs.
  3. Inspect the texts sent to the embeddings endpoint (provider log or proxy). The indexed chunks and the recall query both start with passage: (search_document: for nomic).

Environment

  • Marinara Engine version: 2.5.0 (staging at ecd62a2e4678d82fae753dd19f0f15cfbe48bba0)
  • Install type: source. Found by code inspection, not reproduced against a live provider.
  • OS + version: not applicable
  • Browser or app shell: not applicable

Logs, screenshots, or video

No logs, because the wrong prefix fails silently. Code path: CapabilityEmbeddingHost.embed → createConfiguredCapabilityEmbeddingHost → source.embed(texts, signal) → formatMemoryRecallEmbeddingTexts(texts, model, "document").

Additional context

Minimal fix

Add an optional third positional parameter and forward it. Nothing else changes.

// packages/shared/src/types/capability-runtime.ts (CapabilityEmbeddingHost)
embed(texts: string[], signal?: AbortSignal, inputType?: "query" | "document"): Promise<number[][] | null>;
// packages/server/src/services/capability-packages/capability-embedding.service.ts (configured host)
async embed(texts: string[], signal?: AbortSignal, inputType?: "query" | "document"): Promise<number[][] | null> {
  // ...existing limits...
  return source.embed(texts, signal, inputType === "query" ? "query" : "document");
},
  • The built-in MiniLM host can ignore the argument, since its profile has no prefixes.
  • Why a third positional argument and not an options object: older Engines pass the second argument straight to the provider, which calls AbortSignal.any([signal, timeoutSignal]) (base-provider.ts L741). A package passing { signal, inputType } would throw there. Older Engines ignore an extra positional argument, so packages can pass it without a version gate.
  • No spaceId change and no reindex. Stored vectors were embedded as documents, and documents stay documents.
  • Docs: extend the "Capability API 1.15: current embedding configuration" section of docs/development/optional-agent-packages.md to embed(texts, signal?, inputType?), where "query" is for search text and the default is "document". Whether this gets its own capability API minor is the maintainers' call; packages don't need to declare it.
  • Regression: assert that the configured host forwards the input type. For an e5-named model, "query" should produce query: and the default should produce passage: .
  • Pasta-Devs/Marinara-Agents#1302, the package side: LTM must pass "query" for recall.
  • Pasta-Devs/Marinara-Agents#1303 (LTM doesn't register the refresh hook from #7148) and Pasta-Devs/Marinara-Agents#1304 (show LTM's embedding source). These are the other LTM embedding fixes from the same review.
  • Pasta-Devs/Marinara-Agents#1295 (Korean recall report), section 4.
  • Out of scope, possibly worth its own issue: the profile table doesn't match Ollama's snowflake-arctic-embed2, and it treats multilingual-e5-large-instruct as plain e5. That model wants Instruct: …\nQuery: on queries and no document prefix. Fixing either changes spaceId for every Engine memory feature, and lorebooks then need a manual re-vectorize, so it should be handled separately from this fix.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 11, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7429 Originally assigned to: @SpicyMarinara on GitHub. ## Summary The configured capability embeddings host calls `source.embed(texts, signal)` without an input type. As a result, every text a package embeds is formatted as a document, including search queries. Long-Term Memory's recall queries never get the query prefix that E5, nomic-embed-text and Snowflake Arctic Embed v2 models expect. Chat memory recall inside the Engine already passes the input type; only the package path loses it. ## Expected behavior A package can say whether the texts are search queries or documents. The host passes that on to `resolveMemoryRecallEmbeddingSource(...).embed(texts, signal, inputType)`, so `formatMemoryRecallEmbeddingTexts` applies the right prefix. ## Actual behavior - `CapabilityEmbeddingHost.embed(texts, signal?)` has no input-type parameter ([capability-runtime.ts L368](https://github.com/Pasta-Devs/Marinara-Engine/blob/ecd62a2e4678d82fae753dd19f0f15cfbe48bba0/packages/shared/src/types/capability-runtime.ts#L368)). - The configured host calls `source.embed(texts, signal)` ([capability-embedding.service.ts L36-L40](``https://github.com/Pasta-Devs/Marinara-Engine/blob/ecd62a2e4678d82fae753dd19f0f15cfbe48bba0/packages/server/src/services/capability-packages/capability-embedding.service.ts#L36-L40)),`` so the source's `inputType` falls back to `"document"`. - [`resolveMemoryRecallEmbeddingInputProfile`](````https://github.com/Pasta-Devs/Marinara-Engine/blob/ecd62a2e4678d82fae753dd19f0f15cfbe48bba0/packages/server/src/services/memory-recall-embedding.ts#L104-L116)```` then gives package queries the document prefix: | Model profile | Query should get | Query actually gets | | --- | --- | --- | | e5 / multilingual-e5 | `query: ` | `passage: ` | | nomic-embed-text | `search_query: ` | `search_document: ` | | snowflake-arctic-embed v2 | `query: ` | no prefix | - Models on the plain profile have empty prefixes for both, so they are not affected. That includes the built-in MiniLM, bge-m3, OpenAI and Gemini embedding models. The effect is weaker semantic recall for packages that use these models, in any language. Nothing crashes and nothing is logged. ## Steps to reproduce 1. Give the connection Long-Term Memory uses an embedding model with a prefix profile, for example `intfloat/multilingual-e5-large`, or `nomic-embed-text` on Ollama. LTM uses the default connection, or the one set with Connections → apply to all agents. 2. Install Long-Term Memory, save a few memories, and send chat messages until recall runs. 3. Inspect the texts sent to the embeddings endpoint (provider log or proxy). The indexed chunks and the recall query both start with `passage: ` (`search_document: ` for nomic). ## Environment - Marinara Engine version: 2.5.0 (`staging` at `ecd62a2e4678d82fae753dd19f0f15cfbe48bba0`) - Install type: source. Found by code inspection, not reproduced against a live provider. - OS + version: not applicable - Browser or app shell: not applicable ## Logs, screenshots, or video No logs, because the wrong prefix fails silently. Code path: `CapabilityEmbeddingHost.embed` → `createConfiguredCapabilityEmbeddingHost` → `source.embed(texts, signal)` → `formatMemoryRecallEmbeddingTexts(texts, model, "document")`. ## Additional context ### Minimal fix Add an optional third positional parameter and forward it. Nothing else changes. ```ts // packages/shared/src/types/capability-runtime.ts (CapabilityEmbeddingHost) embed(texts: string[], signal?: AbortSignal, inputType?: "query" | "document"): Promise<number[][] | null>; ``` ```ts // packages/server/src/services/capability-packages/capability-embedding.service.ts (configured host) async embed(texts: string[], signal?: AbortSignal, inputType?: "query" | "document"): Promise<number[][] | null> { // ...existing limits... return source.embed(texts, signal, inputType === "query" ? "query" : "document"); }, ``` - The built-in MiniLM host can ignore the argument, since its profile has no prefixes. - **Why a third positional argument and not an options object:** older Engines pass the second argument straight to the provider, which calls `AbortSignal.any([signal, timeoutSignal])` ([base-provider.ts L741](https://github.com/Pasta-Devs/Marinara-Engine/blob/ecd62a2e4678d82fae753dd19f0f15cfbe48bba0/packages/server/src/services/llm/base-provider.ts#L741)). A package passing `{ signal, inputType }` would throw there. Older Engines ignore an extra positional argument, so packages can pass it without a version gate. - **No `spaceId` change and no reindex.** Stored vectors were embedded as documents, and documents stay documents. - **Docs:** extend the "Capability API 1.15: current embedding configuration" section of [`docs/development/optional-agent-packages.md`](https://github.com/Pasta-Devs/Marinara-Engine/blob/ecd62a2e4678d82fae753dd19f0f15cfbe48bba0/docs/development/optional-agent-packages.md#L237-L260) to `embed(texts, signal?, inputType?)`, where `"query"` is for search text and the default is `"document"`. Whether this gets its own capability API minor is the maintainers' call; packages don't need to declare it. - **Regression:** assert that the configured host forwards the input type. For an e5-named model, `"query"` should produce `query: ` and the default should produce `passage: `. ### Related - Pasta-Devs/Marinara-Agents#1302, the package side: LTM must pass `"query"` for recall. - Pasta-Devs/Marinara-Agents#1303 (LTM doesn't register the refresh hook from #7148) and Pasta-Devs/Marinara-Agents#1304 (show LTM's embedding source). These are the other LTM embedding fixes from the same review. - Pasta-Devs/Marinara-Agents#1295 (Korean recall report), section 4. - Out of scope, possibly worth its own issue: the profile table doesn't match Ollama's `snowflake-arctic-embed2`, and it treats `multilingual-e5-large-instruct` as plain e5. That model wants `Instruct: …\nQuery: ` on queries and no document prefix. Fixing either changes `spaceId` for every Engine memory feature, and lorebooks then need a manual re-vectorize, so it should be handled separately from this fix. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:11:30 +07:00
  • closed this issue
  • added the
    in-pr
    bug
    labels
Author
Owner

@SpicyMarinara commented on GitHub (Oct 11, 2026):

Working on this in branch fix/capability-embed-input-type (Claude Code agent for @SpicyMarinara).

<!-- gh-comment-id:6109494821 --> @SpicyMarinara commented on GitHub (Oct 11, 2026): Working on this in branch fix/capability-embed-input-type (Claude Code agent for @SpicyMarinara).
Author
Owner

@SpicyMarinara commented on GitHub (Oct 11, 2026):

Fixed on staging by #7432. The capability embeddings host now forwards an optional third argument, embed(texts, signal?, inputType?) (capability API 1.68), so package queries get the query prefix that e5, nomic-embed-text and Snowflake Arctic Embed v2 expect. The package side is Pasta-Devs/Marinara-Agents#1302. Thanks for the precise report, @Promansis!

<!-- gh-comment-id:6109915763 --> @SpicyMarinara commented on GitHub (Oct 11, 2026): Fixed on staging by #7432. The capability embeddings host now forwards an optional third argument, `embed(texts, signal?, inputType?)` (capability API 1.68), so package queries get the query prefix that e5, nomic-embed-text and Snowflake Arctic Embed v2 expect. The package side is Pasta-Devs/Marinara-Agents#1302. Thanks for the precise report, @Promansis!
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#4139
No description provided.