no_endpoint: ctx_tokens in Antwort und Log

Wenn alle Ziele am Kontext scheitern, war bisher nur need_tokens sichtbar.
Die 503-Antwort und die Logzeile nennen jetzt auch die Prompt-Schätzung, damit
"context context context" nicht mehr raten lässt, wie groß der Request war.
This commit is contained in:
Hermes committed 2026-11-17 08:23:11 +00:00
1 parent e302d1bc01
commit f74e9e9e8f
1 file changed
+7 -5
+7 -5
View File
@@ -3725,15 +3725,17 @@ static void handle_client(j_conn *client)
if (head_sent) {
/* the caller holds a 200 by now, so the failure has to be an event */
char msg[512];
snprintf(msg, sizeof msg, "no endpoint available (need=%ld, rule line %d, tried:%s)",
need, rule->line, attempts[0] ? attempts : " none");
snprintf(msg, sizeof msg, "no endpoint available (need=%ld, ctx=%ld, rule line %d, tried:%s)",
need, ctx, rule->line, attempts[0] ? attempts : " none");
sse_error(client, 503, msg);
jlog("no_endpoint", "path=%s attempts=%s", rq.path, attempts[0] ? attempts + 1 : "none");
jlog("no_endpoint", "path=%s need=%ld ctx=%ld attempts=%s", rq.path, need, ctx,
attempts[0] ? attempts + 1 : "none");
} else {
char body[1024];
snprintf(body, sizeof body,
"{\"error\":\"no_endpoint_available\",\"need_tokens\":%ld,\"rule_line\":%d,\"attempts\":\"%s\"}",
need, rule->line, attempts[0] ? attempts + 1 : "none");
"{\"error\":\"no_endpoint_available\",\"need_tokens\":%ld,\"ctx_tokens\":%ld,"
"\"rule_line\":%d,\"attempts\":\"%s\"}",
need, ctx, rule->line, attempts[0] ? attempts + 1 : "none");
send_simple(client, 503, "Service Unavailable", body);
}