diff --git a/src/config.c b/src/config.c index 56bfd3e..712f5b5 100644 --- a/src/config.c +++ b/src/config.c @@ -1568,11 +1568,6 @@ int j_config_load(const char *path, j_config *cfg, char *err, size_t errlen) } if (!ep->kind[0]) snprintf(ep->kind, sizeof ep->kind, "remote"); } - /* max_context is a hard ceiling for every model, even one that advertises more. */ - if (cfg->max_context > 0) - for (int i = 0; i < cfg->endpoint_count; i++) - if (cfg->endpoints[i].context > cfg->max_context) - cfg->endpoints[i].context = cfg->max_context; if (cfg->ctx_fallback[0]) { int found = 0; for (int i = 0; i < cfg->pool_count; i++) diff --git a/src/config.h b/src/config.h index 30fe5a1..0cddac3 100644 --- a/src/config.h +++ b/src/config.h @@ -370,8 +370,9 @@ typedef struct { * Messung — deshalb steht er in der Konfiguration und nicht im Code. */ double ctx_chars_per_token; - /* Harte Obergrenze für alle Modelle, 0 = aus. Auch ein Modell, das mehr - * veröffentlicht, wird auf diesen Wert gekappt. */ + /* Obergrenze fuer die /v1/models-Metadaten, 0 = aus. Die Modelle selbst + * behalten ihre echten Grenzen; der Client setzt nur 131k, weil die Liste + * nicht mehr verspricht. */ long max_context; /* Modell-Politik. Sobald eine `models allow`-Zeile existiert, ist die Vorgabe diff --git a/src/models.c b/src/models.c index eb7918a..76ccaf2 100644 --- a/src/models.c +++ b/src/models.c @@ -155,8 +155,8 @@ int j_models_parse(j_endpoint *ep, const char *json, size_t len) return n; } -/* CFG.max_context is a hard ceiling: even a model that publishes more is - * treated as this small. 0 = no ceiling. */ +/* CFG.max_context caps only what /v1/models publishes; the engine keeps the + * model's real limits and does not refuse a request because of it. */ static long cap_context(long lim) { if (lim > 0 && CFG.max_context > 0 && lim > CFG.max_context) @@ -193,7 +193,7 @@ long j_models_limit(const j_endpoint *ep, const char *model, int which) } done: pthread_mutex_unlock(&g_models_lock); - return cap_context(found); + return found; } /* Ein Muster gegen die volle ID und, falls vorhanden, gegen die ID ohne @@ -377,7 +377,7 @@ static long effective_limit_for_rule(const j_rule *r, const char *model, int whi } } } - return cap_context(best); + return best; } long j_models_rule_limit(const j_rule *r, int which) @@ -576,6 +576,9 @@ int j_models_patch_list(const char *json, size_t len, char **out, size_t *out_le * sichere Obergrenze — nicht die Endpoint-Zahl eines einzelnen Ziels. */ if (outlim <= 0) outlim = ctx; if (ctx > 0 && outlim > ctx) outlim = ctx; + /* /v1/models must not promise more than the configured ceiling. */ + ctx = cap_context(ctx); + outlim = cap_context(outlim); /* nur ergänzen, wenn wir wenigstens eine Grenze kennen */ if (ctx <= 0 && outlim <= 0) continue; int need_comma = 0;