Skip to content

fix(k8s): devops-review has deployments with three windows and no max_input_tokens, so a long prompt can be cut #2825

Description

@dan-petty

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:30b on ollama-48gib-fast: 262144.
  • qwen3-coder:30b on ollama-64gib-standard: 160000.
  • gpt-oss:20b on ollama-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-chat and of devops-review: send prompts of 100000, 140000 and 200000 tokens to each group and read prompt_eval_count of the reply (a cut prompt shows a count equal to num_ctx).
  • If a long devops-review prompt reaches a small deployment, fix it at the cause: for example one devops-review group 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_fallbacks rules from devops-chat to devops-coder and devops-reasoning. These targets have the same window (262144) and are not larger, so the fallback cannot help.

Evidence

Acceptance criteria

  • A test or a documented measurement shows which window each deployment of devops-chat and devops-review applies.
  • A prompt longer than the smallest window of devops-review never reaches a deployment that would cut it.
  • The two useless context_window_fallbacks rules are removed, or they point at a larger window.
  • uv run devops ci passes.

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

  1. added
    source/agent
    type/bug
    scope/k8s
    status/new
    value/medium
    effort/medium
    on Oct 31, 2026
  2. dan-petty commented on Oct 31, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/k8s. The (k8s) scope of the title gives the scope.
    • Priority: P2-Medium. Silent prompt truncation produces wrong review output, but only for prompts of 140000 tokens or more routed to the smallest deployment.
    • Value: Medium. A truncated prompt gives a review that is missing its start or end, which corrupts the output for long reviews.
    • Effort: Medium. Requires a live gateway test, a routing strategy decision, a config update, and removal of stale fallback rules.
    • Related: feat(k8s): raise the context length of the condor and hawk Ollama tiers to what their GPUs hold #2822, which asks for a different change. 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.
  3. added
    priority/p2-medium
    on Oct 31, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 31, 2026
  5. devops-cli-service commented on Oct 31, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 8028319 (see proposed design in issue body).

  6. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Oct 31, 2026
  7. removed
    status/in-review
    on Oct 31, 2026
  8. added a commit that references this issue on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions