From 5d8214711d7cd007e4332846da1691e3adeba0ae Mon Sep 17 00:00:00 2001 From: kert Date: Wed, 11 Nov 2026 15:01:59 -0500 Subject: [PATCH] feat(llm): LLM_INSTRUCT_MODEL overrides the instruct model per run Lets eval-tags --live compare judge models (14b vs 32b on the rig) without editing stack.toml. --- src/llm/config.py | 4 +++- tests/llm/test_config.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/llm/config.py b/src/llm/config.py index 59077c2..7e1cf1f 100644 --- a/src/llm/config.py +++ b/src/llm/config.py @@ -4,6 +4,7 @@ Env contract: LLM_OLLAMA_HOSTS comma-separated Ollama base URLs, each optionally annotated with declared VRAM: ``http://rig:11434@24`` (beats [llm].ollama) + LLM_INSTRUCT_MODEL beats [llm].instruct_model (judge/model comparisons) LLM_PG_HOST beats [llm].pg_host (containers set this to "postgres") LLM_DB_PASSWORD required for pg_url(); lives in .env, never stack.toml LLM_BUILD_ANN_INDEX beats [llm].build_ann_index ("1"/"true"/"yes" = True) @@ -121,7 +122,8 @@ def load() -> LlmConfig: ollama_hosts=tuple(url for url, _ in pairs), host_vram={url: vram for url, vram in pairs}, embed_model=str(section.embed_model), - instruct_model=str(section.instruct_model), + instruct_model=os.environ.get("LLM_INSTRUCT_MODEL") + or str(section.instruct_model), instruct_model_large=str(_opt(section, "instruct_model_large", "")), large_min_vram_gb=float(_opt(section, "large_min_vram_gb", 20.0)), chat_num_ctx=int(_opt(section, "chat_num_ctx", 8192)), diff --git a/tests/llm/test_config.py b/tests/llm/test_config.py index caa0024..4283d86 100644 --- a/tests/llm/test_config.py +++ b/tests/llm/test_config.py @@ -143,3 +143,13 @@ def test_iom_companion_max_defaults_to_four(): pg_user="u", ) assert cfg.iom_companion_max == 4 + + +def test_instruct_model_env_override(monkeypatch): + # Judge-model comparisons (14b vs 32b) without editing stack.toml. + from llm.config import load + + monkeypatch.setenv("LLM_INSTRUCT_MODEL", "qwen2.5:32b") + assert load().instruct_model == "qwen2.5:32b" + monkeypatch.delenv("LLM_INSTRUCT_MODEL") + assert load().instruct_model == "qwen2.5:14b"