[GH-ISSUE #12717] Consolidate embeddings truncation #8438

Closed
opened 2026-04-12 21:07:07 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @jmorganca on GitHub (Oct 21, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12717

Originally assigned to: @npardal on GitHub.

What is the issue?

Currently, when truncate is provided to the /api/embed endpoint, truncation happens in two locations:

  1. The /api/embed handler in server: https://github.com/ollama/ollama/blob/main/server/routes.go#L676
  2. In the Ollama and Llama runners

We should consolidate on 2, which would clean up a bunch of code in the EmbedHandler function.

This would entail a few steps:

  1. Pass the truncate value through to the runner
  2. Return the token usage from the runner back to the server handler
  3. Ensure context window errors are propagated from the runner back to the server handler

Relevant log output


OS

No response

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @jmorganca on GitHub (Oct 21, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12717 Originally assigned to: @npardal on GitHub. ### What is the issue? Currently, when `truncate` is provided to the `/api/embed` endpoint, truncation happens in two locations: 1. The `/api/embed` handler in `server`: https://github.com/ollama/ollama/blob/main/server/routes.go#L676 2. In the [Ollama](https://github.com/ollama/ollama/blob/main/runner/ollamarunner/runner.go#L133) and [Llama](https://github.com/ollama/ollama/blob/main/runner/llamarunner/runner.go#L127) runners We should consolidate on 2, which would clean up a bunch of code in the `EmbedHandler` function. This would entail a few steps: 1. Pass the `truncate` value through to the runner 2. Return the token usage from the runner back to the server handler 3. Ensure context window errors are propagated from the runner back to the server handler ### Relevant log output ```shell ``` ### OS _No response_ ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-04-12 21:07:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#8438