mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2909] [CLOSED] serve: an opt-in strict_model that refuses a request naming another model #4327
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4327
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2909
Author: @BoogeAI
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:serve-strict-model📝 Commits (1)
6f33127serve: an opt-in "strict_model" that refuses a request naming another model📊 Changes
2 files changed (+87 additions, -0 deletions)
View changed files
📝
serve/server.py(+27 -0)📝
serve/test_server.py(+60 -0)📄 Description
Title
serve: an opt-in
strict_modelthat refuses a request naming another modelIssue: Refs #2717
Summary
The three client routes answer any model name with whatever is loaded, and the reply's own
modelis theserver's, so a client pointed at another local model (a fine-tune vs the base, two configs on one port) cannot
tell it is being answered by the wrong weights.
/propshas always refused an unknown name; this makes thatopt-in for the routes a client actually talks to, so a mismatch fails loudly instead of silently.
"strict_model": trueinstrata-<model>.json: a request whose"model"is neither the served name nor analias is refused with the 404
/propsalready uses. Absent orfalsekeeps today's path exactly as it is; arequest with no
model, an empty one or a non-string is still accepted, because every route has always readthat as "this server's model" (
Service.model_for).What changed
serve/server.py(+27)Service.strict_model(defaultFalse) andService.model_is_served(req):Falseonly when the requestnames a non-empty string that is not in
model_names().begin_request:404with{"error": {"type": "invalid_request_error", "code": "model_not_found", "message": "model not found"}}(
responses_error_body(...)on/v1/responses, as that route already shapes its errors), and one line inthe log naming the asked and the served models.
main()readsstrict_model(a non-boolean stops the start, likereasoning_close_retry) and prints oneline when it is on.
serve/test_server.py(+60): aStrictModelcase over all three routes - the default still answers anyname, the opt-in refuses another name, and the served name / no model / an empty model are accepted.
Extra Notes
How I checked. Measured against a real server (0.1.45 prebuilt CUDA 13.0, RTX 5080 16 GB, Windows 11
26200, a Qwen3.8-Flash-Next fine-tune loaded):
modelstrict_modeloff (before)/v1/chat/completions,/v1/messages,/v1/responses)modelfield /"model": ""The 404 body on the chat and Anthropic routes is the one above; on
/v1/responsesit is{"error": {"message": "model not found", "type": "invalid_request_error", "param": null, "code": "model_not_found"}}.What it leaves alone. The engine, the kernels, setup,
/propsand/v1/load|unload(which alreadychecked), and the behaviour of every request when the config does not set the key - no name is looked at then.
/v1/messages/count_tokensis deliberately not gated: it does not answer with weights.In the field. A front-end that declares both local models on one route and a picker that says "the
fine-tune" while the base model is loaded: with the key on, that pick now returns 404 instead of an answer from
the wrong weights (this is what prompted the issue).
Not tested. AMD HIP and SYCL (CUDA only here); an aliased model (the configs I have carry no
aliases, somodel_is_servedonly ever sees the name) - the alias case is covered by usingmodel_names()unchanged.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.