From 584c622ed63e15caa9618e319ebd96148cce42d6 Mon Sep 17 00:00:00 2001 From: Hermes Date: Tue, 17 Nov 2026 20:46:44 +0000 Subject: [PATCH] judge: anthropic-version auch bei kind remote nicht verdoppeln MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/junction.c | 5 +++-- tests/judge.sh | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/junction.c b/src/junction.c index 378d15c..6ef76b3 100644 --- a/src/junction.c +++ b/src/junction.c @@ -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; diff --git a/tests/judge.sh b/tests/judge.sh index c9dcb5c..7fa10e5 100644 --- a/tests/judge.sh +++ b/tests/judge.sh @@ -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 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'"