diff --git a/src/models.c b/src/models.c index 4f69385..8ddef25 100644 --- a/src/models.c +++ b/src/models.c @@ -500,7 +500,10 @@ int j_models_patch_list(const char *json, size_t len, char **out, size_t *out_le if (!j_rule_is_virtual_chain(r)) continue; const char *name = r->model_glob; if (!j_model_allowed(name)) continue; - if (json_has_model_id(json, len, name)) continue; + /* The same name can appear in more than one rule (a virtual rule and a + * ctx-overflow rule). The list must contain it once. */ + if (json_has_model_id(json, len, name) || + json_has_model_id(extra, eo, name)) continue; long ctx = j_models_effective_limit(name, 0); long outlim = j_models_effective_limit(name, 1); /* Kein Modell nennt eine Ausgabegrenze? Dann ist der effektive Kontext die diff --git a/tests/virtual-models.sh b/tests/virtual-models.sh index 5ee4937..43d1cbc 100644 --- a/tests/virtual-models.sh +++ b/tests/virtual-models.sh @@ -50,6 +50,9 @@ endpoint big { base http://127.0.0.1:$VB/v1; context 100000; timeout 10; idle_ti req path "/v1/models" check none pass worker req for "vm-chain" judge every 1 judge as "jm" cache off pass worker as "wm" req for "vm-chain" ctx >2000 pass big +# Zweite virtuelle Regel mit demselben Namen: /v1/models darf den Eintrag nur +# einmal enthalten (ein Alias mit eigenem Ziel). +req for "vm-chain" ctx >100000 pass big as "bm" req for "*" pass big CFG ./junction --config "$TMP/vm1.conf" > "$TMP/vm1.log" 2>&1 & @@ -64,6 +67,9 @@ for i in $(seq 1 100); do done VM=$(curl -s -m 10 "http://127.0.0.1:$V1/v1/models") +VMCOUNT=$(printf '%s' "$VM" | grep -o '"id":"vm-chain"' | wc -l) +[ "$VMCOUNT" = "1" ] && ok "a duplicate rule name produces one /v1/models entry" \ + || bad "vm-chain is listed $VMCOUNT times" if python3 - "$VM" <<'PY' import json, sys d = json.loads(sys.argv[1])