judge: anthropic-version auch bei kind remote nicht verdoppeln

Der OpenAI-kompatible Anthropic-Endpoint ist kind remote. Wenn der Client
eine anthropic-version schickt, darf die statische Version des Endpunkts
nicht zusätzlich angehängt werden. Der Test prüft den Judge-Turn auf genau
einen Header und darauf, dass der Client-Wert gewinnt.

Tests: 335 OK, 0 FAIL.
This commit is contained in:
Hermes committed 2026-11-17 20:46:44 +00:00
1 parent 00c88c588e
commit 584c622ed6
2 files changed
+13 -3

No files matched your search

+3 -2
View File
@@ -2762,8 +2762,9 @@ static int forward_step(j_conn *client, j_endpoint *ep, const j_req *rq,
used += (size_t)snprintf(req + used, HDR_BLOCK_MAX - used,
"Authorization: Bearer %s\r\n", inj_key);
char av[J_HDR_VALUE];
int have_av = anthropic_kind &&
j_hdrs_find(&rq->hdrs, "anthropic-version", av, sizeof av) == 0 &&
/* Also true for kind remote: the Anthropic OpenAI-compatible endpoint is a
* remote endpoint and must not receive the static version twice. */
int have_av = j_hdrs_find(&rq->hdrs, "anthropic-version", av, sizeof av) == 0 &&
av[0] != '\0';
for (int i = 0; i < ep->header_count; i++) {
if (strchr(ep->headers[i], '\r') || strchr(ep->headers[i], '\n')) continue;
+10 -1
View File
@@ -32,7 +32,7 @@ listen 127.0.0.1:$JP
queue_timeout 10
models allow "qwen-judged" "WORKER" "JUDGE"
endpoint worker { base http://127.0.0.1:$JW/v1; context 8000; timeout 10; idle_timeout 5 }
endpoint judge { base http://127.0.0.1:$JJ/v1; context 12000; timeout 10; idle_timeout 5 }
endpoint judge { base http://127.0.0.1:$JJ/v1; context 12000; timeout 10; idle_timeout 5; header "anthropic-version: 2023-06-01" }
req path "/v1/models" pass worker, judge
req for "qwen-judged" judge every 3 judge as "judge-model" cache 1h pass worker as "worker-model"
CFG
@@ -58,11 +58,14 @@ PY
judge_ask() { # judge_ask <port> <first-user> <last-user>
curl -s -D "$TMP/judge_h.txt" -o "$TMP/judge_b.txt" -m 20 \
-X POST -H 'Content-Type: application/json' \
-H 'anthropic-version: 2025-01-01' \
-d "$(judge_body "$2" "$3")" \
"http://127.0.0.1:$1/v1/chat/completions"
JNAME=$(tr -d '\r' < "$TMP/judge_h.txt" | sed -n 's/^X-Stub-Name: //p')
JCACHE=$(tr -d '\r' < "$TMP/judge_h.txt" | sed -n 's/^X-Stub-Cache-Control: //p')
JMODEL=$(tr -d '\r' < "$TMP/judge_h.txt" | sed -n 's/^X-Stub-Model: //p')
JAV=$(tr -d '\r' < "$TMP/judge_h.txt" | sed -n 's/^X-Stub-Anthropic-Version: //p')
JAVC=$(tr -d '\r' < "$TMP/judge_h.txt" | sed -n 's/^X-Stub-Anthropic-Versions: //p')
}
# Unterhaltung A: 3., 6., 9. … Anfrage geht an den Judge.
@@ -76,6 +79,12 @@ for i in 1 2 3 4 5 6; do
|| bad "turn $i: judge request had no cache_control"
[ "$JMODEL" = "judge-model" ] && ok "turn $i sends the judge model" \
|| bad "turn $i: judge saw model '$JMODEL'"
if [ "$i" = "3" ]; then
[ "$JAV" = "2025-01-01" ] && ok "the client's anthropic-version wins" \
|| bad "the judge saw anthropic-version '$JAV'"
[ "$JAVC" = "1" ] && ok "the static anthropic-version is not duplicated" \
|| bad "the judge saw $JAVC anthropic-version headers"
fi
else
[ "$JNAME" = "WORKER" ] && ok "turn $i stays on the worker" \
|| bad "turn $i should stay on the worker, got '$JNAME'"