mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4370] [GUI] Report each native model's context window in /v1/models (n_ctx) #5025
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#5025
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/4370
Author: @msalsas
Created: 10/27/2026
Status: 🔄 Open
Base:
main← Head:feat/native-models-nctx📝 Commits (1)
4b223b3Native serving reports each loaded model's context window: /v1/models gains meta.n_ctx, the key the control server already uses, left out when unknown rather than 0 (#3931)📊 Changes
3 files changed (+72 additions, -1 deletions)
View changed files
📝
apps/host/server/index.mjs(+2 -1)➕
apps/host/server/native-models.mjs(+9 -0)➕
apps/host/tests/native-models.test.mjs(+61 -0)📄 Description
The problem
When the app serves native models,
GET /v1/modelslists each ready model with its id, GPUs, label and aliases, but not its context size (#3931). A client that reads the list can't tell how many tokens a model accepts. So it has to guess the size or ask the user to type it in.What the change does
Each entry in the native
/v1/modelslist now hasmeta.n_ctx, the model's context window in tokens.serve/server.pyalready uses this key, so clients that work with it there also work here.The value comes from two places, in this order:
metrics.engine.max_context).context), if the engine has not reported one.Only a positive integer counts. If neither value is known, the key is left out and not set to 0. A window of 0 makes some clients think there is no room, and then they send nothing (#351). A missing key lets them fall back to their own default. The other keys in each entry are the same as before.
The approach
The list is now built by a small pure function,
nativeModelEntriesinapps/host/server/native-models.mjs.index.mjscalls it in place of the inline map. The function does not change its input, so it can be tested without a running engine.It checks the two values in the same order as
index.mjs(the instance summary andcontextMax) andoversize.mjs: the engine value first, then the config. All three places agree on which number is the window. One small difference: those places use??, so a 0 would win there, while here a 0 is skipped as unknown.Validation
Passed:
apps/host/tests/native-models.test.mjspass on Node 22 (Linux arm64). They cover the config value, the engine value winning, a fallback when the engine value is unusable, the key being left out when the value is unknown, only ready instances being listed in order, empty input, the input not being changed, andn_ctxbeing the only new key.Host suite (
npm testinapps/host), run on a Raspberry Pi:mainand on this branch.Not run:
curlagainst/v1/models. The test machine has no native engine.Known limits
meta.contextand does not addn_ctx.serve/server.pyreportsn_ctx: 0when the window is unknown. This change leaves the key out instead. So the two servers still differ in that one case.Fixes #3931
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.