Skip to content

fix: pass embedding kwargs (trust_remote_code) in preload_embedding()#1508

Open
hurtdidit wants to merge 1 commit intoagent0ai:mainfrom
hurtdidit:fix/preload-embedding-kwargs
Open

fix: pass embedding kwargs (trust_remote_code) in preload_embedding()#1508
hurtdidit wants to merge 1 commit intoagent0ai:mainfrom
hurtdidit:fix/preload-embedding-kwargs

Conversation

@hurtdidit
Copy link
Copy Markdown
Contributor

Bug

preload_embedding() in preload.py calls models.get_embedding_model() without forwarding the kwargs from the embedding config object. This causes HuggingFace models that require trust_remote_code=True (e.g., nomic-ai/nomic-bert-2048) to fail during startup preloading with:

Error in preload_embedding: nomic-ai/nomic-bert-2048 ... Please pass trust_remote_code=True

Root Cause

The config schema supports a kwargs field, and get_embedding_model() already accepts **kwargs and passes them through — but preload_embedding() never forwards them. The feature is half-implemented.

Fix

Extract kwargs from the config object with a safe default and forward them:

emb_kwargs = getattr(emb_cfg, "kwargs", {}) or {}
emb_mod = models.get_embedding_model("huggingface", emb_cfg.name, **emb_kwargs)

Two-line change to preload.py.

Impact

  • Fully backward compatible — **{} is a no-op for configs without kwargs
  • No config changes required
  • Affects any HuggingFace embedding model requiring trust_remote_code (increasingly common)

Testing

Deployed and verified across 5 production Agent Zero instances (Docker). All instances show successful preload with All keys matched successfully and zero Error in preload_embedding messages.

Bug: preload_embedding() calls models.get_embedding_model() without
forwarding kwargs from the embedding config object. This causes
HuggingFace models requiring trust_remote_code=True (e.g.
nomic-ai/nomic-bert-2048) to fail during startup preloading.

Fix: Extract kwargs with getattr(emb_cfg, "kwargs", {}) and forward
them via **emb_kwargs. Fully backward compatible - empty dict is a
no-op for configs without kwargs.
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.

1 participant