Skip to content

[embedding] Local model download hardcodes huggingface.co and ignores HF_ENDPOINT, preventing first-run setup on restricted networks #459

Description

@sisttri

Short description

The local embedding provider always downloads from https://huggingface.co/, even when HF_ENDPOINT points to an approved Hugging Face mirror. This prevents first-run model initialization on networks where Hugging Face is blocked but a mirror or corporate endpoint is available.

What happened?

Magic Context local embeddings use the bundled Transformers.js runtime. Its runtime configuration sets the model cache directory, but the download host remains hardcoded to https://huggingface.co/

The host does not honor the standard HF_ENDPOINT environment variable. HF_ENDPOINT is the conventional way to route Hugging Face-compatible downloads, but setting it does not change the request destination.

Expected behavior: Respect HF_ENDPOINT when resolving Hugging Face model assets; or expose a documented Magic Context configuration option for the Transformers remote host / mirror endpoint.

Suggested fix

When initializing the local Transformers runtime, set its remote host from an explicit configuration value, falling
back to HF_ENDPOINT, then finally to the existing https://huggingface.co/ default.

Example precedence:

  1. embedding.local_remote_host in magic-context.jsonc
  2. HF_ENDPOINT
  3. https://huggingface.co/

Keep the current persistent model cache behavior unchanged.

A configuration-only alternative is also acceptable, as long as it supports a Hugging Face-compatible mirror without requiring a code patch or manual cache prewarming.

Diagnostics

- Harness: OMP 18.2.1
- Plugin: `@cortexkit/pi-magic-context` 0.42.5
- Platform: Linux x64
- Runtime: Bun 1.4.2
- Embedding provider: `local`
- Model: `Xenova/paraphrase-multilingual-MiniLM-L12-v2`
- Dtype: `q8`

Plugin version

No response

OpenCode version

No response

Platform

Linux x64

Client

Pi

Log output (optional)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions