Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Pin the decision model weights and recover from a bad download

agent-runner3538068934256a3
diff --git a/decision/README.md b/decision/README.md
index 53b6f0dcf..df186f4e3 100644
--- a/decision/README.md
+++ b/decision/README.md
@@ -137,8 +137,12 @@ downloads the checkpoint and its base model (about 17 GB) into `/models`.
`strands-decider serve`: it merges the checkpoint's LoRA adapter into the base
weights once at load, which on an L4 gives the same answers in 0.26 s instead
of 0.42 s for a typical room and about 3.9 decisions a second instead of 2.4.
-It's configured by env only (`STRANDS_CHECKPOINT`, `STRANDS_MODEL_NAME`,
-`STRANDS_MAX_BATCH`):
+It's configured by env only (`STRANDS_CHECKPOINT`, `STRANDS_REVISION`,
+`STRANDS_BASE_REVISION`, `STRANDS_MODEL_NAME`, `STRANDS_MAX_BATCH`). The image
+pins the checkpoint and its base model to Hugging Face commits
+(`STRANDS_REVISION`, `STRANDS_BASE_REVISION`); the base revision must be the one
+the checkpoint records in its `provenance.json`, or the server refuses to
+start:
```
docker build -t switch-decision-strands decision/model-servers/strands/
@@ -152,8 +156,8 @@ docker run -d -p 8230:8230 \
The image pins `strands-decider==0.2.0` and every dependency by hash
(`model-servers/strands/requirements.txt`, compiled from `requirements.in`
-with the command at its top). `STRANDS_CHECKPOINT` and `STRANDS_MODEL_NAME`
-choose another checkpoint.
+with the command at its top). `STRANDS_CHECKPOINT`, the two revisions and
+`STRANDS_MODEL_NAME` choose another checkpoint.
Qwen3.5-4B on the llama.cpp server image:
diff --git a/decision/model-servers/strands/Dockerfile b/decision/model-servers/strands/Dockerfile
index f086600fb..d0c7d7ee5 100644
--- a/decision/model-servers/strands/Dockerfile
+++ b/decision/model-servers/strands/Dockerfile
@@ -11,7 +11,8 @@
#
# No weights in the image. The checkpoint and its base model download from
# Hugging Face on the first start into HF_HOME=/models, which is meant to be a
-# volume, so later starts only load them. The E4B checkpoint is built on
+# volume, so later starts only load them. Both are pinned to commits
+# (STRANDS_REVISION, STRANDS_BASE_REVISION; serve.py). The E4B checkpoint is built on
# google/gemma-4-E4B-it (about 16 GB in bf16), whose Gemma terms apply; the
# weights are fetched by whoever deploys, never redistributed in this image.
# Set HF_TOKEN for a gated checkpoint or higher Hub rate limits.
@@ -51,6 +52,8 @@ ENV PATH="/opt/strands/bin:$PATH" \
HF_HOME=/models \
HF_HUB_DISABLE_TELEMETRY=1 \
STRANDS_CHECKPOINT=StrandsAgents/strands-decider-E4B-gemma4-v1-2610 \
+ STRANDS_REVISION=1344d44397c457f3be34b8ff15c593b41248c6bf \
+ STRANDS_BASE_REVISION=ee0ef6023621cff504d758262d4e04895a5af4a2 \
STRANDS_MODEL_NAME=strands-decider-E4B
USER 10001:10001
WORKDIR /home/decision
diff --git a/decision/model-servers/strands/serve.py b/decision/model-servers/strands/serve.py
index c3cc753a6..00530bf9e 100644
--- a/decision/model-servers/strands/serve.py
+++ b/decision/model-servers/strands/serve.py
@@ -3,9 +3,17 @@ adapter merged into the base weights.
python serve.py
-Reads STRANDS_CHECKPOINT, STRANDS_MODEL_NAME, STRANDS_PORT (default 8400),
-STRANDS_HOST (default 0.0.0.0), STRANDS_DEVICE (default cuda) and
-STRANDS_MAX_BATCH (default 32, requests evaluated together).
+Reads STRANDS_CHECKPOINT, STRANDS_REVISION, STRANDS_BASE_REVISION,
+STRANDS_MODEL_NAME, STRANDS_PORT (default 8400), STRANDS_HOST (default
+0.0.0.0), STRANDS_DEVICE (default cuda) and STRANDS_MAX_BATCH (default 32,
+requests evaluated together).
+
+STRANDS_REVISION is the Hugging Face commit of the checkpoint to download, and
+STRANDS_BASE_REVISION the commit of its base model, so a new push to either
+repo changes nothing that runs. The loader takes the base model's revision
+from the checkpoint itself (its config, else its provenance.json), so the
+server checks that the checkpoint names STRANDS_BASE_REVISION and refuses to
+start otherwise, then downloads the base at that commit before loading.
`strands-decider serve` keeps the adapter separate and applies it on every
forward pass. Merging it once at load gives the same answers (15/15, 36/40 and
@@ -23,10 +31,19 @@ import uvicorn
from fastapi import FastAPI, HTTPException
from fastapi.responses import JSONResponse
from strands_decider.infer import EngineConfig, SystemOneEngine
-from strands_decider.modeling import StrandsDeciderModel
+from huggingface_hub import snapshot_download
+from strands_decider.modeling import (
+ StrandsDeciderConfig,
+ StrandsDeciderModel,
+ base_revision,
+ checkpoint_dir,
+ config_path,
+)
from strands_decider.schema import SystemOneRequest
CHECKPOINT = os.environ["STRANDS_CHECKPOINT"]
+REVISION = os.environ["STRANDS_REVISION"]
+BASE_REVISION = os.environ["STRANDS_BASE_REVISION"]
MODEL_NAME = os.environ["STRANDS_MODEL_NAME"]
PORT = int(os.environ.get("STRANDS_PORT", "8400"))
HOST = os.environ.get("STRANDS_HOST", "0.0.0.0")
@@ -34,9 +51,27 @@ DEVICE = os.environ.get("STRANDS_DEVICE", "cuda")
MAX_BATCH = int(os.environ.get("STRANDS_MAX_BATCH", "32"))
+def pinned_checkpoint() -> str:
+ """The checkpoint at REVISION, downloaded, with its base model downloaded at
+ BASE_REVISION: the local directory to load."""
+ path = checkpoint_dir(CHECKPOINT, revision=REVISION)
+ config = StrandsDeciderConfig.from_json(config_path(path))
+ recorded = base_revision(path, config)
+ if recorded != BASE_REVISION:
+ raise RuntimeError(
+ f"{CHECKPOINT}@{REVISION} loads {config.base_model} at revision "
+ f"{recorded or 'main (none recorded)'}, but STRANDS_BASE_REVISION is "
+ f"{BASE_REVISION}. Set STRANDS_BASE_REVISION to the revision the "
+ "checkpoint records in its provenance.json, or pin a checkpoint "
+ "revision that records the base you want."
+ )
+ snapshot_download(config.base_model, revision=BASE_REVISION)
+ return path
+
+
def load_engine() -> SystemOneEngine:
started = time.monotonic()
- model = StrandsDeciderModel.load(CHECKPOINT)
+ model = StrandsDeciderModel.load(pinned_checkpoint())
if not hasattr(model.torso, "merge_and_unload"):
raise RuntimeError(
f"{CHECKPOINT} has no LoRA adapter to merge; this server expects a "
@@ -45,7 +80,8 @@ def load_engine() -> SystemOneEngine:
model.torso = model.torso.merge_and_unload()
model.torso.to(DEVICE, dtype=torch.bfloat16)
print(
- f"loaded {CHECKPOINT} as {MODEL_NAME} on {DEVICE} with the adapter merged, "
+ f"loaded {CHECKPOINT}@{REVISION} (base at {BASE_REVISION}) as "
+ f"{MODEL_NAME} on {DEVICE} with the adapter merged, "
f"in {time.monotonic() - started:.0f}s",
flush=True,
)
@@ -72,6 +108,8 @@ def health() -> dict:
"status": "ok",
"model": MODEL_NAME,
"checkpoint": CHECKPOINT,
+ "revision": REVISION,
+ "base_revision": BASE_REVISION,
"adapter": "merged",
}
diff --git a/deploy/local/docker-compose.yml b/deploy/local/docker-compose.yml
index fab947943..c173fdcf2 100644
--- a/deploy/local/docker-compose.yml
+++ b/deploy/local/docker-compose.yml
@@ -158,9 +158,15 @@ services:
profiles: ["decision", "decision-gpu"]
# The fresh named volume is root's.
user: "0:0"
+ # Pinned to a Hugging Face commit and checked against its SHA-256, as in
+ # the Helm chart. A file that fails the check is deleted (and, if it was
+ # already on the volume, downloaded again), so a bad file never sticks.
+ # To try another model, set DECISION_MODEL_URL, _FILE and _SHA256
+ # together (an empty _SHA256 skips the check).
environment:
- MODEL_URL: ${DECISION_MODEL_URL:-https://huggingface.co/unsloth/Qwen3.5-4B-GGUF/resolve/main/Qwen3.5-4B-Q4_K_M.gguf}
+ MODEL_URL: ${DECISION_MODEL_URL:-https://huggingface.co/unsloth/Qwen3.5-4B-GGUF/resolve/e87f176479d0855a907a41277aca2f8ee7a09523/Qwen3.5-4B-Q4_K_M.gguf}
MODEL_FILE: ${DECISION_MODEL_FILE:-Qwen3.5-4B-Q4_K_M.gguf}
+ MODEL_SHA256: ${DECISION_MODEL_SHA256-00fe7986ff5f6b463e62455821146049db6f9313603938a70800d1fb69ef11a4}
# Only for a gated model (one whose licence your Hugging Face account
# has accepted).
HF_TOKEN: ${HF_TOKEN:-}
@@ -170,12 +176,22 @@ services:
- |
set -eu
target="/models/$$MODEL_FILE"
- if [ -s "$$target" ]; then echo "have $$MODEL_FILE"; exit 0; fi
+ verify() { [ -z "$$MODEL_SHA256" ] || echo "$$MODEL_SHA256 $$target" | sha256sum -c -; }
+ if [ -s "$$target" ]; then
+ if verify; then echo "have $$MODEL_FILE"; exit 0; fi
+ echo "$$MODEL_FILE on the volume fails its checksum; deleting it and downloading it again" >&2
+ rm -f "$$target"
+ fi
echo "downloading $$MODEL_URL"
set -- -fsSL --retry 5 --retry-delay 10 -C - -o "$$target.partial"
if [ -n "$$HF_TOKEN" ]; then set -- "$$@" -H "Authorization: Bearer $$HF_TOKEN"; fi
curl "$$@" "$$MODEL_URL"
mv "$$target.partial" "$$target"
+ if ! verify; then
+ echo "the downloaded $$MODEL_FILE fails its checksum; deleted it, so the next start downloads it again" >&2
+ rm -f "$$target"
+ exit 1
+ fi
volumes:
- decision-models:/models
@@ -258,6 +274,10 @@ services:
profiles: ["decision-strands-gpu"]
environment:
HF_TOKEN: ${HF_TOKEN:-}
+ # The checkpoint's and its base model's Hugging Face commits, as in the
+ # Helm chart (decision.modelServer.strands.revision / baseRevision).
+ STRANDS_REVISION: 1344d44397c457f3be34b8ff15c593b41248c6bf
+ STRANDS_BASE_REVISION: ee0ef6023621cff504d758262d4e04895a5af4a2
volumes:
- decision-hf:/models
deploy:
diff --git a/deploy/remote/helm/switch/README.md b/deploy/remote/helm/switch/README.md
index 76ef1c371..05b49777a 100644
--- a/deploy/remote/helm/switch/README.md
+++ b/deploy/remote/helm/switch/README.md
@@ -333,9 +333,24 @@ no further setup.
probe allows 30 minutes (`decision.modelServer.strands.startupProbe`), and
the decision service reports not ready until then. Later starts only load
the weights, a few minutes. For Qwen, an init container downloads the GGUF
- file (`decision.modelServer.llamacpp.model`: URL, file name, optional
- SHA-256) first. `decision.modelServer.hfTokenSecret` names a Secret with a
- Hugging Face token, for a gated checkpoint or higher Hub rate limits.
+ file (`decision.modelServer.llamacpp.model`: URL, file name, SHA-256) first.
+ `decision.modelServer.hfTokenSecret` names a Secret with a Hugging Face
+ token, for a gated checkpoint or higher Hub rate limits.
+- **Pinned weights.** Every model is downloaded at a fixed Hugging Face
+ commit, so a new push upstream changes nothing that runs:
+ - Qwen's URL names a commit (`…/resolve/<commit>/…`), and the init container
+ checks the file's SHA-256 (`model.sha256`). A file already on the volume
+ that fails the check is deleted and downloaded again; a fresh download
+ that fails it is deleted before the init container exits non-zero, so the
+ next start downloads it again rather than failing on every restart.
+ - Strands Decider's checkpoint is downloaded at
+ `decision.modelServer.strands.revision` and its base model at
+ `baseRevision` (`STRANDS_REVISION`, `STRANDS_BASE_REVISION`). The base
+ revision must be the one the checkpoint records in its `provenance.json`,
+ the one it was trained on; the server refuses to start otherwise.
+
+ To move to a newer model, set the URL, file and SHA-256 together (or both
+ Strands revisions), from the model's Hugging Face page.
- **Licence.** Strands Decider is Apache-2.0, but its 4B checkpoint is built on
Google's Gemma 4 (`google/gemma-4-E4B-it`), whose terms apply to anyone
deploying it. The chart downloads the weights at deploy time from Hugging
diff --git a/deploy/remote/helm/switch/templates/decision/deployment.yaml b/deploy/remote/helm/switch/templates/decision/deployment.yaml
index db6e49c9a..5236003b1 100644
--- a/deploy/remote/helm/switch/templates/decision/deployment.yaml
+++ b/deploy/remote/helm/switch/templates/decision/deployment.yaml
@@ -50,8 +50,11 @@ spec:
{{- if eq $kind "llamacpp" }}
{{- $llama := $ms.llamacpp }}
initContainers:
- # Downloads the weights into the volume unless they are already there,
- # resuming a download a restart interrupted.
+ # Downloads the weights into the volume unless they are already there
+ # and pass their checksum, resuming a download a restart interrupted.
+ # A file that fails the checksum is deleted: one already on the volume
+ # is downloaded again at once; a fresh download that fails exits
+ # non-zero, and the next start downloads it again.
- name: download-model
image: {{ $llama.model.downloaderImage }}
command: ["sh", "-c"]
@@ -59,19 +62,28 @@ spec:
- |
set -eu
target="/models/$MODEL_FILE"
+ verify() {
+ [ -z "$MODEL_SHA256" ] || echo "$MODEL_SHA256 $target" | sha256sum -c -
+ }
if [ -s "$target" ]; then
- echo "have $MODEL_FILE"
- else
- echo "downloading $MODEL_URL"
- set -- -fsSL --retry 5 --retry-delay 10 -C - -o "$target.partial"
- if [ -n "${HF_TOKEN:-}" ]; then
- set -- "$@" -H "Authorization: Bearer $HF_TOKEN"
+ if verify; then
+ echo "have $MODEL_FILE"
+ exit 0
fi
- curl "$@" "$MODEL_URL"
- mv "$target.partial" "$target"
+ echo "$MODEL_FILE on the volume fails its checksum; deleting it and downloading it again" >&2
+ rm -f "$target"
fi
- if [ -n "$MODEL_SHA256" ]; then
- echo "$MODEL_SHA256 $target" | sha256sum -c -
+ echo "downloading $MODEL_URL"
+ set -- -fsSL --retry 5 --retry-delay 10 -C - -o "$target.partial"
+ if [ -n "${HF_TOKEN:-}" ]; then
+ set -- "$@" -H "Authorization: Bearer $HF_TOKEN"
+ fi
+ curl "$@" "$MODEL_URL"
+ mv "$target.partial" "$target"
+ if ! verify; then
+ echo "the downloaded $MODEL_FILE fails its checksum; deleted it, so the next start downloads it again" >&2
+ rm -f "$target"
+ exit 1
fi
env:
- name: MODEL_URL
@@ -177,8 +189,14 @@ spec:
env:
- name: STRANDS_CHECKPOINT
value: {{ required "decision.modelServer.strands.checkpoint is required" $st.checkpoint | quote }}
+ - name: STRANDS_REVISION
+ value: {{ required "decision.modelServer.strands.revision is required: the checkpoint's commit on Hugging Face" $st.revision | quote }}
+ - name: STRANDS_BASE_REVISION
+ value: {{ required "decision.modelServer.strands.baseRevision is required: the base model's commit the checkpoint records" $st.baseRevision | quote }}
- name: STRANDS_MODEL_NAME
value: {{ required "decision.modelServer.strands.modelName is required" $st.modelName | quote }}
+ - name: STRANDS_PORT
+ value: {{ $st.port | quote }}
{{- with include "switch.decisionHfToken" . }}
{{- . | trim | nindent 12 }}
{{- end }}
diff --git a/deploy/remote/helm/switch/values.yaml b/deploy/remote/helm/switch/values.yaml
index b5d248615..08ad5867e 100644
--- a/deploy/remote/helm/switch/values.yaml
+++ b/deploy/remote/helm/switch/values.yaml
@@ -939,6 +939,14 @@ decision:
# first start with its base model (google/gemma-4-E4B-it, about 16 GB,
# under the Gemma terms). Later starts only load it.
checkpoint: StrandsAgents/strands-decider-E4B-gemma4-v1-2610
+ # The commits of the checkpoint (STRANDS_REVISION) and of its base model
+ # (STRANDS_BASE_REVISION) to download, so a new push to either repo
+ # changes nothing here. The base revision must be the one the checkpoint
+ # records in its provenance.json (the one it was trained on): the server
+ # refuses to start otherwise. Bump both together, from the checkpoint's
+ # Hugging Face page.
+ revision: 1344d44397c457f3be34b8ff15c593b41248c6bf
+ baseRevision: ee0ef6023621cff504d758262d4e04895a5af4a2
# The name the server answers as, and DECISION_MODEL unless `model`
# above is set.
modelName: strands-decider-E4B
@@ -982,13 +990,15 @@ decision:
- "4"
- --jinja
# The weights, downloaded into the PVC by an init container when the
- # file is not there yet. Changing them downloads the new file on the
- # next start.
+ # file is not there yet, from a fixed Hugging Face commit. A file that
+ # fails its checksum is deleted and downloaded again; a download that
+ # fails it is deleted and the pod restarts, so a bad file never sticks.
+ # To change model, set url, file and sha256 together.
model:
- url: https://huggingface.co/unsloth/Qwen3.5-4B-GGUF/resolve/main/Qwen3.5-4B-Q4_K_M.gguf
+ url: https://huggingface.co/unsloth/Qwen3.5-4B-GGUF/resolve/e87f176479d0855a907a41277aca2f8ee7a09523/Qwen3.5-4B-Q4_K_M.gguf
file: Qwen3.5-4B-Q4_K_M.gguf
- # Optional hex SHA-256 of the file, checked after the download.
- sha256: ""
+ # Hex SHA-256 of the file. Empty skips the check (not recommended).
+ sha256: 00fe7986ff5f6b463e62455821146049db6f9313603938a70800d1fb69ef11a4
downloaderImage: curlimages/curl:8.11.1
# llama.cpp's /health is 503 until the model is loaded (seconds).
startupProbe:
diff --git a/docs/old/LOCAL_DEVELOPMENT.md b/docs/old/LOCAL_DEVELOPMENT.md
index f791e69a2..c0aaad018 100644
--- a/docs/old/LOCAL_DEVELOPMENT.md
+++ b/docs/old/LOCAL_DEVELOPMENT.md
@@ -230,7 +230,9 @@ Auto-route (the `decision_routing` feature flag) asks a decision service who
should answer an untagged message. `just decision-up` starts one beside the
stack: the decision service on `:8230` (`DECISION_PORT` to change it) and a
llama.cpp server for its model, Qwen3.5-4B in 4-bit, whose weights (about
-2.7 GB) download once into the `decision-models` volume. It is the compose
+2.7 GB) download once into the `decision-models` volume, from a fixed
+Hugging Face commit and checked against their SHA-256 (a file that fails is
+deleted and downloaded again). It is the compose
`decision` profile; `just decision-up gpu` is the `decision-gpu` profile, for
Linux with an NVIDIA GPU and the NVIDIA Container Toolkit.
diff --git a/scripts/check_chart_decision.py b/scripts/check_chart_decision.py
index 79dec2852..208d150cb 100755
--- a/scripts/check_chart_decision.py
+++ b/scripts/check_chart_decision.py
@@ -5,7 +5,8 @@ The decision service (auto-route) is optional in the chart. Off, nothing of it
renders and switch-core gets no endpoint. On, the chart runs it beside its
model server (Strands Decider by default, or Qwen on llama.cpp), points
switch-core at it and admits only switch-core to it, both by NetworkPolicy and
-by a bearer token the chart generates. An endpoint run elsewhere
+by a bearer token the chart generates. Its model weights are pinned to fixed
+revisions, the same in docker-compose. An endpoint run elsewhere
can be named instead, but not as well as the chart's own. These are the
promises deploy/remote/helm/switch/README.md makes about `decision.*`; a render
that breaks one fails here, before a cluster finds out.
@@ -18,6 +19,7 @@ Needs `helm` on PATH and PyYAML. Run from the repo root:
from __future__ import annotations
import base64
+import re
import subprocess
import sys
from collections.abc import Callable
@@ -26,6 +28,8 @@ from typing import Any
import yaml
CHART = "deploy/remote/helm/switch"
+COMPOSE = "deploy/local/docker-compose.yml"
+COMMIT = re.compile(r"^[0-9a-f]{40}$")
BASE = "deploy/remote/helm/render-check-values.yaml"
RELEASE = "rel"
FLAGS = [
@@ -188,10 +192,14 @@ def test_strands_decider_is_the_default_model_server() -> None:
# pinned it: either way, the strands model-server image.
repository = server["image"].split("@")[0].rsplit(":", 1)[0]
assert repository.rsplit("/", 1)[-1] == "switch-decision-strands", server["image"]
- assert env_of(server) == {
+ env = env_of(server)
+ assert env == {
"STRANDS_CHECKPOINT": "StrandsAgents/strands-decider-E4B-gemma4-v1-2610",
+ "STRANDS_REVISION": env["STRANDS_REVISION"],
+ "STRANDS_BASE_REVISION": env["STRANDS_BASE_REVISION"],
"STRANDS_MODEL_NAME": "strands-decider-E4B",
- }
+ "STRANDS_PORT": "8400",
+ }, env
assert [p["containerPort"] for p in server["ports"]] == [8400]
resources = server["resources"]
assert resources["limits"]["nvidia.com/gpu"] == 1
@@ -389,6 +397,94 @@ def test_an_existing_token_secret_replaces_the_generated_one() -> None:
assert secret_refs_of(core_container(docs))["DECISION_API_KEY"] == ref
+def _llama_init(docs: list[dict[str, Any]]) -> dict[str, Any]:
+ pod = decision_objects(docs)["Deployment"]["spec"]["template"]["spec"]
+ return pod["initContainers"][0]
+
+
+def test_the_qwen_weights_are_pinned_and_a_bad_file_is_deleted() -> None:
+ docs = render(
+ "--set", "decision.enabled=true", "--set", "decision.modelServer.kind=llamacpp"
+ )
+ init = _llama_init(docs)
+ env = env_of(init)
+ match = re.fullmatch(
+ r"https://huggingface\.co/unsloth/Qwen3\.5-4B-GGUF/resolve/([0-9a-f]{40})/"
+ r"Qwen3\.5-4B-Q4_K_M\.gguf",
+ env["MODEL_URL"],
+ )
+ assert match, env["MODEL_URL"]
+ assert re.fullmatch(r"[0-9a-f]{64}", env["MODEL_SHA256"]), env["MODEL_SHA256"]
+ script = init["args"][0]
+ # A file on the volume that fails is deleted and downloaded again; a
+ # download that fails is deleted before the container exits non-zero.
+ assert script.count('rm -f "$target"') == 2, script
+ after_download = script.split('mv "$target.partial" "$target"', 1)[1]
+ assert "if ! verify; then" in after_download
+ assert after_download.index('rm -f "$target"') < after_download.index("exit 1")
+
+
+def test_the_strands_checkpoint_and_base_are_pinned() -> None:
+ server = containers(
+ decision_objects(render("--set", "decision.enabled=true"))["Deployment"]
+ )["model-server"]
+ env = env_of(server)
+ assert COMMIT.match(env["STRANDS_REVISION"]), env["STRANDS_REVISION"]
+ assert COMMIT.match(env["STRANDS_BASE_REVISION"]), env["STRANDS_BASE_REVISION"]
+ assert env["STRANDS_REVISION"] != env["STRANDS_BASE_REVISION"]
+ assert "decision.modelServer.strands.revision is required" in render_error(
+ "--set",
+ "decision.enabled=true",
+ "--set",
+ "decision.modelServer.strands.revision=",
+ )
+ assert "decision.modelServer.strands.baseRevision is required" in render_error(
+ "--set",
+ "decision.enabled=true",
+ "--set",
+ "decision.modelServer.strands.baseRevision=",
+ )
+
+
+def test_compose_pins_the_same_weights_as_the_chart() -> None:
+ with open(COMPOSE, encoding="utf-8") as fh:
+ services = yaml.safe_load(fh)["services"]
+
+ def compose_default(value: str) -> str:
+ # ${NAME:-default} or ${NAME-default}
+ found = re.fullmatch(r"\$\{[A-Z0-9_]+:?-(.*)\}", value)
+ assert found, value
+ return found.group(1)
+
+ llama = env_of(
+ _llama_init(
+ render(
+ "--set",
+ "decision.enabled=true",
+ "--set",
+ "decision.modelServer.kind=llamacpp",
+ )
+ )
+ )
+ download = services["decision-model-download"]
+ assert compose_default(download["environment"]["MODEL_URL"]) == llama["MODEL_URL"]
+ assert (
+ compose_default(download["environment"]["MODEL_SHA256"])
+ == llama["MODEL_SHA256"]
+ )
+ script = download["entrypoint"][-1]
+ assert script.count('rm -f "$$target"') == 2, script
+
+ strands = env_of(
+ containers(
+ decision_objects(render("--set", "decision.enabled=true"))["Deployment"]
+ )["model-server"]
+ )
+ compose_strands = services["decision-model-strands"]["environment"]
+ for name in ("STRANDS_REVISION", "STRANDS_BASE_REVISION"):
+ assert compose_strands[name] == strands[name], name
+
+
def test_refuses_contradictions() -> None:
assert "Clear one of them" in render_error(
"--set",
@@ -431,6 +527,9 @@ TESTS: list[Callable[[], None]] = [
test_an_endpoint_elsewhere,
test_the_service_requires_a_token_that_switch_core_sends,
test_an_existing_token_secret_replaces_the_generated_one,
+ test_the_qwen_weights_are_pinned_and_a_bad_file_is_deleted,
+ test_the_strands_checkpoint_and_base_are_pinned,
+ test_compose_pins_the_same_weights_as_the_chart,
test_refuses_contradictions,
]