Agent Zero AI framework
Repair sentence-transformer embedding config aliases
Alessandro630bfc16f2cb
diff --git a/plugins/_model_config/AGENTS.md b/plugins/_model_config/AGENTS.mdindex faacef90f..c1e5fa146 100644--- a/plugins/_model_config/AGENTS.md+++ b/plugins/_model_config/AGENTS.md@@ -17,6 +17,7 @@- Keep provider metadata and API-key checks safe around secrets.- Coordinate OAuth-backed providers with `_oauth` instead of hardcoding provider-specific auth here.- Applying a model preset may inherit durable tuning such as context windows and rate limits, but must replace or clear per-slot `kwargs` so provider-specific extra params never leak across model providers.+- Repair provider-specific model-config aliases at the model-config read/build boundary; keep provider-specific repairs out of provider-agnostic core wrappers such as `models.py`.## Work Guidancediff --git a/plugins/_model_config/helpers/model_config.py b/plugins/_model_config/helpers/model_config.pyindex 175378d58..66ed32b70 100644--- a/plugins/_model_config/helpers/model_config.py+++ b/plugins/_model_config/helpers/model_config.py@@ -450,7 +450,25 @@ def get_utility_model_config(agent=None) -> dict:def get_embedding_model_config(agent=None) -> dict:"""Get embedding model config."""cfg = get_config(agent)- return cfg.get("embedding_model", {})+ model_cfg = deepcopy(cfg.get("embedding_model", {}))+ provider = str(model_cfg.get("provider") or "").strip().lower()+ name = str(model_cfg.get("name") or "").strip().strip('"').strip("'")++ if provider:+ model_cfg["provider"] = provider+ if name:+ model_cfg["name"] = name++ if name.startswith("huggingface/sentence-transformers/"):+ model_cfg["provider"] = "huggingface"+ model_cfg["name"] = name.removeprefix("huggingface/")+ elif name.startswith("sentence-transformers/") and provider in {"", "openai", "other"}:+ model_cfg["provider"] = "huggingface"+ elif provider == "huggingface" and name == "all-MiniLM-L6-v2":+ model_cfg["name"] = "sentence-transformers/all-MiniLM-L6-v2"++ return model_cfg+def is_chat_override_allowed(agent=None) -> bool:"""Check if per-chat model override is enabled."""@@ -566,7 +584,7 @@ def get_missing_api_key_providers(agent=None) -> list[dict]:checks = [("Chat Model", cfg.get("chat_model", {})),("Utility Model", cfg.get("utility_model", {})),- ("Embedding Model", cfg.get("embedding_model", {})),+ ("Embedding Model", get_embedding_model_config(agent)),]for label, model_cfg in checks:diff --git a/tests/test_model_config_api_keys.py b/tests/test_model_config_api_keys.pyindex bb9b6080b..1153630fd 100644--- a/tests/test_model_config_api_keys.py+++ b/tests/test_model_config_api_keys.py@@ -430,6 +430,70 @@ def test_local_provider_runtime_defaults_and_overrides(monkeypatch):assert custom_vllm_chat.kwargs["api_key"] == "real-local-key"+def test_embedding_config_repairs_sentence_transformer_aliases(monkeypatch):+ from plugins._model_config.helpers import model_config++ cases = [+ (+ {"provider": "", "name": "sentence-transformers/all-MiniLM-L6-v2"},+ ("huggingface", "sentence-transformers/all-MiniLM-L6-v2"),+ ),+ (+ {"provider": "openai", "name": "sentence-transformers/all-MiniLM-L6-v2"},+ ("huggingface", "sentence-transformers/all-MiniLM-L6-v2"),+ ),+ (+ {+ "provider": "other",+ "name": "huggingface/sentence-transformers/all-MiniLM-L6-v2",+ },+ ("huggingface", "sentence-transformers/all-MiniLM-L6-v2"),+ ),+ (+ {"provider": "huggingface", "name": "all-MiniLM-L6-v2"},+ ("huggingface", "sentence-transformers/all-MiniLM-L6-v2"),+ ),+ ]++ for raw_embedding, expected in cases:+ monkeypatch.setattr(+ model_config,+ "get_config",+ lambda *args, raw_embedding=raw_embedding, **kwargs: {+ "embedding_model": raw_embedding+ },+ )+ cfg = model_config.get_embedding_model_config_object()++ assert (cfg.provider, cfg.name) == expected++ monkeypatch.setattr(+ model_config,+ "get_config",+ lambda *args, **kwargs: {+ "embedding_model": {+ "provider": "openai",+ "name": "text-embedding-3-small",+ }+ },+ )+ cfg = model_config.get_embedding_model_config_object()++ assert (cfg.provider, cfg.name) == ("openai", "text-embedding-3-small")++ monkeypatch.setattr(+ model_config,+ "get_config",+ lambda *args, **kwargs: {+ "embedding_model": {+ "provider": "openai",+ "name": "sentence-transformers/all-MiniLM-L6-v2",+ }+ },+ )+ assert model_config.get_missing_api_key_providers() == []++def test_docker_compose_maps_host_docker_internal_for_local_models():import yaml