[PR #1882] [Engine] serve: /v1/models also gives the context size as max_model_len and context_length #3734

Open
opened 2026-11-07 15:30:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1882
Author: @LeGeRyChEeSe
Created: 10/10/2026
Status: 🔄 Open

Base: main ← Head: pr/models-context-len


📝 Commits (1)

  • aae2852 serve: /v1/models also gives the context size as max_model_len and context_length, the names vLLM and OpenRouter use

📊 Changes

2 files changed (+5 additions, -1 deletions)

View changed files

📝 serve/server.py (+4 -1)
📝 serve/test_server.py (+1 -0)

📄 Description

Problem and result

/v1/models gives the context size only as meta.n_ctx (llama-server's name). Clients that size their context window from the model list read other keys: max_model_len (vLLM's) or context_length (OpenRouter's). Without them they fall back to their own default, so they compact too early or send more than the server takes. v0.2.2 has neither key.

After the change the same value (svc.reported_ctx()) is under all three names. meta.n_ctx is unchanged.

No open issue or pull request found (searched 2026-10-22: max_model_len, context_length, /v1/models). #2618 (closed) adds more keys to the same meta dict; the two do not overlap.
This pull request was closed in the 0.2.0-beta tracker reset; it is rebased on v0.2.4.1 and unchanged in content.

Approach

One line in the /v1/models handler plus a comment: two more keys on the model entry (and on each alias entry, which copies it). Nothing is removed or renamed, so existing clients are unaffected.

Validation

Revision: main 8183c6b6 (v0.2.4.1) plus this one commit; the first runs were on v0.2.2 (011c9e60). Environment: Windows 11, Python 3.13, RTX 4070 SUPER.

Passed:

  • Rebased on main 8183c6b6 (v0.2.4.1): python -m unittest serve.test_server passes (353 tests, 3 skipped, Windows 11); test_model_discovery_and_props checks the two new keys.
  • The earlier Linux CI failure of this pull request was test_responses.NoLeakedSampler.test_server_close_ends_the_sampler (1 != 2); it passes locally on this branch and the change touches no sampler code, so it looks like a flaky test, to be confirmed by the new CI run.
  • grep -rn max_model_len serve/*.py on v0.2.2: no match (the keys are absent before the change).
  • python -m pytest serve -q on this branch: 912 passed, 17 skipped. test_model_discovery_and_props checks the two new keys next to meta.n_ctx.
  • A server built from v0.2.2 plus this change (and #1881, #1883), started with two different model files: GET /v1/models returned "max_model_len": 131072 and "context_length": 131072 for both, with --max-context 131072.

Failed:
none observed.

Not run:

  • The vLLM and OpenRouter clients themselves: the key names come from their documented model-list format, and no such client was run against the server.
  • Linux and macOS: the change is a dictionary entry in Python with no platform code.
  • Engine builds (CUDA, HIP, SYCL, Metal): no engine file is touched.

Limits

Only the context size is added; other llama-server meta facts are not part of this change.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1882 **Author:** [@LeGeRyChEeSe](https://github.com/LeGeRyChEeSe) **Created:** 10/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/models-context-len` --- ### 📝 Commits (1) - [`aae2852`](https://github.com/Niko1221/Strata/commit/aae2852f513386503ce4fd070c0ad498f97dd7f5) serve: /v1/models also gives the context size as max_model_len and context_length, the names vLLM and OpenRouter use ### 📊 Changes **2 files changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+4 -1) 📝 `serve/test_server.py` (+1 -0) </details> ### 📄 Description ## Problem and result `/v1/models` gives the context size only as `meta.n_ctx` (llama-server's name). Clients that size their context window from the model list read other keys: `max_model_len` (vLLM's) or `context_length` (OpenRouter's). Without them they fall back to their own default, so they compact too early or send more than the server takes. v0.2.2 has neither key. After the change the same value (`svc.reported_ctx()`) is under all three names. `meta.n_ctx` is unchanged. ## Related discussion No open issue or pull request found (searched 2026-10-22: `max_model_len`, `context_length`, `/v1/models`). #2618 (closed) adds more keys to the same `meta` dict; the two do not overlap. This pull request was closed in the 0.2.0-beta tracker reset; it is rebased on v0.2.4.1 and unchanged in content. ## Approach One line in the `/v1/models` handler plus a comment: two more keys on the model entry (and on each alias entry, which copies it). Nothing is removed or renamed, so existing clients are unaffected. ## Validation Revision: `main` `8183c6b6` (v0.2.4.1) plus this one commit; the first runs were on v0.2.2 (`011c9e60`). Environment: Windows 11, Python 3.13, RTX 4070 SUPER. **Passed:** - Rebased on `main` `8183c6b6` (v0.2.4.1): `python -m unittest serve.test_server` passes (353 tests, 3 skipped, Windows 11); `test_model_discovery_and_props` checks the two new keys. - The earlier Linux CI failure of this pull request was `test_responses.NoLeakedSampler.test_server_close_ends_the_sampler` (`1 != 2`); it passes locally on this branch and the change touches no sampler code, so it looks like a flaky test, to be confirmed by the new CI run. - `grep -rn max_model_len serve/*.py` on v0.2.2: no match (the keys are absent before the change). - `python -m pytest serve -q` on this branch: 912 passed, 17 skipped. `test_model_discovery_and_props` checks the two new keys next to `meta.n_ctx`. - A server built from v0.2.2 plus this change (and #1881, #1883), started with two different model files: `GET /v1/models` returned `"max_model_len": 131072` and `"context_length": 131072` for both, with `--max-context 131072`. **Failed:** none observed. **Not run:** - The vLLM and OpenRouter clients themselves: the key names come from their documented model-list format, and no such client was run against the server. - Linux and macOS: the change is a dictionary entry in Python with no platform code. - Engine builds (CUDA, HIP, SYCL, Metal): no engine file is touched. ## Limits Only the context size is added; other llama-server `meta` facts are not part of this change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3734
No description provided.