mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 19:04:50 +07:00
[PR #649] serve: expose context_length and max_output_tokens on /v1/models for generic client discovery #648
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#648
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/mw00/project-maya/pull/649
Author: @NorwinYu
Created: 10/29/2026
Status: 🔄 Open
Base:
main← Head:models-listing-capacities📝 Commits (1)
3c7b64bserve: list context_length and max_output_tokens on /v1/models for generic client discovery📊 Changes
2 files changed (+7 additions, -0 deletions)
View changed files
📝
serve/server.py(+5 -0)📝
serve/test_server.py(+2 -0)📄 Description
Summary
The
GET /v1/models(and/models) endpoint reports a model's context size only undermeta.n_ctx. Common OpenAI-compatible clients that discover model capacities from the model listing read different, de-facto-standard field names on each entry, and never readmeta.n_ctx. As a result such clients fall back to a hard-coded default for an unknown model. Concretely, DeepSeek Harness (itspi-aimodel discovery, used for self-hosted routes) readscontext_length/max_input_tokensfor the context window andmax_output_tokensfor the output cap, and assumes a 262144-token window when neither is present.This change adds the two standard names to each model entry, alongside the existing
meta.n_ctx(kept for backwards compatibility). It is a server JSON-shape change only: no engine, sampling, or GPU behaviour is affected.What changed
In
serve/server.py, each/v1/modelsand/modelsentry now also carries:context_length— the engine'smax_context(the combined request + response limit the engine enforces);max_output_tokens— the same value. Maya has no separate, lower fixed output cap: generation is clamped tomax_contextby the engine, so the output ceiling is the context window itself.meta.n_ctxis unchanged.Measured
GET /v1/modelsbefore:after:
Testing
serve/test_server.py: extended the/v1/modelsand/modelsassertions to cover the two new fields; the full server suite passes (101 tests OK).python tools/check_hip_compat.pypasses — no CUDA names were added or changed.python -m unittest discover -s tools -p 'test_*.py'passes (407 tests OK, 28 skipped;cmakemust be onPATHfor the HIP-arch tests).Compatibility
meta.n_ctxare unaffected.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.