Repository navigation
Description
What happened
While I checked the gateway routes against the new tier context lengths of #2822, I found a route whose window the gateway does not enforce.
devops-review has three deployments with three windows (after #2822):
qwen3-coder:30bonollama-48gib-fast: 262144.qwen3-coder:30bonollama-64gib-standard: 160000.gpt-oss:20bonollama-16gib-fast: 131072.
None of them has max_input_tokens, and enable_pre_call_checks is on. The router sends each request to the deployment with the fewest requests in flight. A prompt of 140000 tokens can therefore land on gpt-oss:20b. Ollama cuts a prompt that is longer than num_ctx without an error, so the review reads a prompt that is missing its start or its end. The same holds for devops-coder/devops-reasoning/qwen3-coder:30b only if a second deployment is added; today each has one.
The comments in k8s/llm/gateway/config.yaml say why the key is missing: LiteLLM writes the model_info of a deployment into the cost-map entry that every deployment of the same model reads. devops-chat still carries two different values (262144 and 160000) for qwen3.8:27b, so I could not tell from the file which value each deployment uses at run time.
What should happen
- Find out with a test against the live gateway which window the router applies to each deployment of
devops-chatand ofdevops-review: send prompts of 100000, 140000 and 200000 tokens to each group and readprompt_eval_countof the reply (a cut prompt shows a count equal tonum_ctx). - If a long
devops-reviewprompt reaches a small deployment, fix it at the cause: for example onedevops-reviewgroup per window class, or the smallest window as the group's limit. State the choice in the proposal. - The same test covers the two
context_window_fallbacksrules fromdevops-chattodevops-coderanddevops-reasoning. These targets have the same window (262144) and are not larger, so the fallback cannot help.
Evidence
k8s/llm/gateway/config.yamlafter feat(k8s): raise the context length of the condor and hawk Ollama tiers to what their GPUs hold #2822 anddevops ai gateway render, which shows no difference, because it only changes keys that exist.- A check of every deployment against the tier lengths, run on 2026-10-31.
Acceptance criteria
- A test or a documented measurement shows which window each deployment of
devops-chatanddevops-reviewapplies. - A prompt longer than the smallest window of
devops-reviewnever reaches a deployment that would cut it. - The two useless
context_window_fallbacksrules are removed, or they point at a larger window. -
uv run devops cipasses.
Proposed design
Problem statement
The devops-review gateway group routes requests across three deployments with different context windows using least-busy routing. None has max_input_tokens, so a prompt longer than 131072 tokens can reach the gpt-oss:20b deployment. Ollama truncates the prompt without an error, and the review reads a prompt missing its start or end. Two context_window_fallbacks rules point at targets with the same window and cannot help.
Acceptance criteria
Requirement: Window measurement documented
A documented measurement SHALL show which context window the router applies to each deployment of devops-chat and devops-review.
Scenario: Measurement recorded in change folder
- WHEN Prompts of 100000, 140000, and 200000 tokens are sent to each group and prompt_eval_count is read from the reply
- THEN The measured window for each deployment is recorded in the change folder
Requirement: No truncated prompt reaches a small deployment
A prompt longer than the smallest window of devops-review SHALL NOT reach a deployment whose num_ctx is smaller than the prompt length.
Scenario: Oversized prompt is not routed to a small deployment
- WHEN A prompt of 140000 tokens is sent to devops-review
- THEN The prompt is not routed to a deployment with num_ctx less than 140000
Requirement: Useless fallback rules removed
The context_window_fallbacks rules that point at targets with the same window SHALL be removed.
Scenario: Config has no useless fallback rules
- WHEN The context_window_fallbacks list is read from the rendered gateway config
- THEN No rule points from devops-chat to devops-coder or devops-reasoning, and no rule points from devops-coder to devops-reasoning
Requirement: CI passes
uv run devops ci SHALL pass on the change branch.
Scenario: CI green
- WHEN uv run devops ci is run on the change branch
- THEN All checks pass with no failures
Existing Tool Considered
No check has run. LiteLLM provides max_input_tokens, routing_groups, and context_window_fallbacks. Its cost-map sharing writes a deployment's model_info into the shared entry for that model string. Per-deployment max_input_tokens is unreliable because of this.
Key questions
- Which context window does the router apply to each deployment of devops-chat and devops-review?: This requires a live measurement. Send prompts of 100000, 140000, and 200000 tokens to each group and read prompt_eval_count. A cut prompt shows a count equal to num_ctx. [sources: k8s/llm/gateway/config.yaml, tests/test_k8s_llm_gateway.py]
- How should the devops-review routing be fixed so a long prompt never reaches a deployment that would cut it?: Remove gpt-oss:20b from the devops-review pool and set max_input_tokens to 160000 on the remaining qwen3-coder:30b deployments. This eliminates the 131072 window and sets a hard limit at the smallest remaining window. The cost-map side effect limits devops-coder, devops-reasoning, and the pinned qwen3-coder:30b group to 160000. (best practice) [sources: k8s/llm/gateway/config.yaml, k8s/README.md]
- Rejected: Smallest window as group limit (131072). Most restrictive. Limits all qwen3-coder:30b and gpt-oss:20b deployments to 131072, a 50 percent reduction for devops-coder and devops-reasoning.
- Chosen: Remove gpt-oss:20b and set limit to 160000. Eliminates the 131072 window. Sets a hard limit at the smallest remaining window. Less restrictive than 131072.
- Rejected: One group per window class. Does not solve the cost-map sharing problem because all groups share the same model string.
- What should happen to the two context_window_fallbacks rules?: Remove both rules. The targets have the same window as the source, so the fallback cannot help. (best practice) [sources: k8s/llm/gateway/config.yaml]
- Chosen: Remove the rules. The targets have the same window, so the fallback is useless.
- Rejected: Point them at a larger window. No deployment has a window larger than 262144.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 31, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(k8s)scope of the title gives the scope.Silent prompt truncation produces wrong review output, but only for prompts of 140000 tokens or more routed to the smallest deployment.A truncated prompt gives a review that is missing its start or end, which corrupts the output for long reviews.Requires a live gateway test, a routing strategy decision, a config update, and removal of stale fallback rules.Both work on Ollama tier context lengths in k8s; #2822 raised the limits, and this candidate fixes the routing gap that the new limits exposed.devops-cli-service commentedon Oct 31, 2026
Status set to Ready at 8028319 (see proposed design in issue body).
chore(main): release 0.26.0 (#2837)