Skip to content

fix(ai): bound the number of prewarm model label values #2742

Closed

Description

@dan-petty

Problem Description

The MCP tool ai_prewarm lets the calling model set model. devops ai prewarm uses that text in two telemetry records:

Reproduction Steps

  1. Use a temporary HOME, the null keyring, ai.provider set to ollama and a loopback listener.
  2. Call the MCP tool ai_prewarm many times with a different model value each time, through a FastMCP Client.
  3. Read the exported series of devops_cli_ai_prewarms_total and the attribute ai.model of the spans.

Expected vs Actual Behavior

Expected: the set of values of the label has a fixed upper bound, for example the configured model and the models that the configured servers report, and any other model shows as one value such as other. The span attribute holds the same bounded text.

Actual: each different model text makes a new series, and the span attribute holds the raw text.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The MCP tool ai_prewarm lets a calling model set any model name. The devops ai prewarm command uses that text in the metric label model of devops_cli_ai_prewarms_total and in the span attribute ai.model of the span ai.prewarm. PR #2737 bounds the length and characters of the label with bounded_label, but it does not bound the number of distinct values. A model that sends 10000 different names creates 10000 series. The span attribute still carries the raw text with no bound at all. The fix bounds the set of values to a fixed upper bound and applies the same bound to the span attribute.

Acceptance criteria

Requirement: Bounded metric label cardinality

The model label of devops_cli_ai_prewarms_total SHALL take at most one value per configured model plus one value per server-reported model plus the value other.

Scenario: Model name not in the allowed set

  • WHEN The target model differs from the configured model and is not in the server-reported model list
  • THEN The model label of the counter equals other

Requirement: Bounded span attribute

The span attribute ai.model of the span ai.prewarm SHALL hold the same bounded value as the model label of the counter.

Scenario: Model name not in the allowed set

  • WHEN The target model differs from the configured model and is not in the server-reported model list
  • THEN The span attribute ai.model equals other

Requirement: Configured model passes through

When the target model equals the configured model, the label and the span attribute SHALL hold that model name bounded by bounded_label.

Scenario: Target model equals configured model

  • WHEN The target model equals settings.ai.model
  • THEN The model label and the span attribute ai.model equal bounded_label of the configured model

Requirement: Server-reported model passes through

When the target model is in the list of models reported by the configured servers, the label and the span attribute SHALL hold that model name bounded by bounded_label.

Scenario: Target model is a server-reported model

  • WHEN The target model is in the list returned by client.list_models()
  • THEN The model label and the span attribute ai.model equal bounded_label of the target model

Requirement: Fallback when server list is unavailable

When client.list_models() fails, the allowed set SHALL fall back to the configured model only, and any other value SHALL map to other.

Scenario: Server list call raises an exception

  • WHEN client.list_models() raises an exception and the target model differs from the configured model
  • THEN The model label and the span attribute ai.model equal other

Existing Tool Considered

No check has run. No open-source library bounds the number of distinct values of a metric label. The OpenTelemetry SDK does not limit the cardinality of a counter attribute. The project already has bounded_label for character and length bounding (from #2676). The cardinality bound is project-specific: it requires knowing the configured model and the models the configured servers report. The project builds its own mapping function. Cost: about 300 tokens to write the function and update the two call sites in src/devops_cli/commands/ai.py.

Key questions

  • What is the allowed set of model values for the label and the span attribute?: The configured model (settings.ai.model) plus the models reported by the configured servers (via client.list_models()). Any other value maps to other. If list_models() fails, the allowed set is the configured model only. (best practice) [sources: src/devops_cli/commands/ai.py:852, openspec/changes/archive/2026-10-30-2676-prewarm-output-server-labels/design.md]
    • Rejected: Configured model only (bound of 2). Simplest, but a user who prewarms a different valid model sees other, losing information.
    • Chosen: Configured model plus server-reported models (bound of N+1). Matches the expected behavior stated in the issue body. The prewarm command already talks to the servers, so a list_models() call adds one round-trip. Falls back to the configured model only if the call fails.
  • How is the span attribute bounded?: The span attribute ai.model holds the same bounded value as the metric label. The same mapping function is applied before the trace_span call and before the emit call. (best practice) [sources: src/devops_cli/commands/ai.py:839]
    • Rejected: Apply bounded_label only (character and length bound). Does not bound cardinality. The span attribute still grows unbounded.
    • Chosen: Apply the same cardinality-bound value as the metric label. The issue body states the span attribute holds the same bounded text. One mapping function serves both call sites.
  • Where is the mapping function placed?: In src/devops_cli/telemetry/instruments.py, beside bounded_label, so that any future command that emits a model label can reuse it. (best practice) [sources: src/devops_cli/telemetry/instruments.py, openspec/changes/archive/2026-10-30-2676-prewarm-output-server-labels/tasks.md]
    • Rejected: Inline in src/devops_cli/commands/ai.py. Only one call site today, but the function is a telemetry concern, not a command concern.
    • Chosen: In src/devops_cli/telemetry/instruments.py beside bounded_label. The existing bounded_label lives there. A cardinality-bound function is the same kind of telemetry helper. Other commands can import it.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/ai
    status/new
    value/medium
    effort/medium
    on Oct 30, 2026
  2. dan-petty commented on Oct 30, 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/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. Unbounded cardinality can exhaust the metrics backend but does not break the prewarm function itself.
    • Value: Medium. Protects the metrics backend from series explosion but does not change user-facing behaviour.
    • Effort: Medium. Requires tracking allowed model values and bucketing the rest in both the counter and the span attribute.
    • Related: fix(ai): the prewarm output names each Ollama server by its configured URL #2676, which asks for a different change. Both work on the model label of the prewarm counter, but #2676 bounds length and characters while the candidate bounds the number of distinct values.
  3. added
    priority/p2-medium
    on Oct 30, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  5. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

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

  6. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/2742-bound-the-number-of-prewarm-model, draft pull request #3163. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Bound the prewarm model label and span attribute: 19872 tokens
  7. added 2 commits that reference this issue on Nov 2, 2026
  8. removed
    status/ready
    on Nov 2, 2026
  9. 4 remaining items

  10. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Stopped at group 1.

    Failure class: limit_reached.
    Action taken: none.
    Action left: raise_limit: raise the limit that the run went over.

    Step Status Attempts Tokens in/out Last failing command
    group 1 stopped 1 8128228/34432 -

    Reason:

    LimitReached: The step spent its budget `roadmap.implement.step_token_budget=8000000`.
    Refused commands: uv 1. Other retries: 5.
    

    Last message of the agent (a claim that no check verified): Now _ollama_models in ollama.py:

    The job discarded this work. The diff is cut to 20000 characters. Read it before you retry:

    diff --git a/src/devops_cli/ai/client/ollama.py b/src/devops_cli/ai/client/ollama.py
    index c0dd39f6..5c2b8b0f 100644
    --- a/src/devops_cli/ai/client/ollama.py
    +++ b/src/devops_cli/ai/client/ollama.py
    @@ -4,7 +4,7 @@ from __future__ import annotations
     
     import logging
     import time
    -from collections.abc import Callable, Generator
    +from collections.abc import Callable, Generator, Sequence
     from concurrent.futures import as_completed
     from typing import Any
     
    @@ -499,8 +499,15 @@ class OllamaProviderMixin(BaseLLMProviderMixin):
             )
             return [model_info["name"] for model_info in tags.get("models", [])]
     
    -    def _ollama_models(self) -> list[str]:
    -        candidates = self._get_ollama_urls_loop()
    +    def _ollama_models(self, urls: Sequence[str] | None = None) -> list[str]:
    +        """The tags of the first Ollama server that answers, from `urls` or the configured servers.
    +
    +        `urls` names the servers to ask, in order, and leaves the round-robin index of chat calls
    +        where it is. With none, the configured servers answer in round-robin order (#2742).
    +        """
    +        candidates = (
    +            self._get_ollama_urls_loop() if urls is None else list(enumerate(urls))
    +        )
             last_exc: Exception | None = None
     
             for _idx, candidate_url in candidates:
    diff --git a/src/devops_cli/ai/client/unified.py b/src/devops_cli/ai/client/unified.py
    index bc63e763..ded17a94 100644
    --- a/src/devops_cli/ai/client/unified.py
    +++ b/src/devops_cli/ai/client/unified.py
    @@ -4,7 +4,7 @@ from __future__ import annotations
     
     import logging
     import time
    -from collections.abc import Callable, Generator
    +from collections.abc import Callable, Generator, Sequence
     from functools import cached_property
     from typing import TYPE_CHECKING, Any
     
    @@ -1121,11 +1121,15 @@ class LLMClient(
             if r_tokens:
                 span_h.set_attribute("gen_ai.usage.reasoning.output_tokens", r_tokens)
     
    -    def list_models(self) -> list[str]:
    -        """List available models for the current provider."""
    +    def list_models(self, urls: Sequence[str] | None = None) -> list[str]:
    +        """List available models for the current provider.
    +
    +        For Ollama, `urls` names the servers to ask; with none, the configured servers answer in
    +        round-robin order, as a chat call does (#2742).
    +        """
             p = self._config.provider
             if p == "ollama":
    -            return self._ollama_models()
    +            return self._ollama_models(urls)
             if p in ("copilot", "openai", "gateway"):
                 return self._openai_models()
             return [self._config.model]
    diff --git a/src/devops_cli/commands/ai.py b/src/devops_cli/commands/ai.py
    index 539ea489..10ad2b75 100644
    --- a/src/devops_cli/commands/ai.py
    +++ b/src/devops_cli/commands/ai.py
    @@ -4,6 +4,7 @@ from __future__ import annotations
     
     import logging
     import math
    +from collections.abc import Sequence
     from pathlib import Path
     from typing import Annotated, Any
     
    @@ -82,7 +83,7 @@ from devops_cli.output import (
         write_text_file,
     )
     from devops_cli.output.serialization import emit_serialized, resolve_format
    -from devops_cli.telemetry.instruments import AI_PREWARMS_TOTAL, bounded_label, emit
    +from devops_cli.telemetry.instruments import AI_PREWARMS_TOTAL, bounded_model_label, emit
     from devops_cli.telemetry.tracer import trace_span
     
     logger = logging.getLogger(__name__)
    @@ -717,6 +718,29 @@ def render_prewarm_results(
     _render_prewarm_results = render_prewarm_results
     
     
    +def _prewarm_model_names(
    +    client: Any, provider: str, urls: Sequence[str], configured_model: str
    +) -> set[str]:
    +    """The models that the servers of the run report, and the configured `ai.model`.
    +
    +    Only an Ollama provider holds models that a server reports: every other provider's prewarm
    +    does nothing, so the run sends no request for a list of models (#2742). A server that fails
    +    the request adds no model, and the prewarm that follows reports its failure in the table.
    +    """
    +    from devops_cli.ai.client import AIClientError
    +    from devops_cli.exceptions import ConfigurationError
    +
    +    allowed = {configured_model}
    +    if (provider or "ollama").lower() != "ollama":
    +        return allowed
    +    for server in urls:
    +        try:
    +            allowed.update(client.list_models(urls=[server]))
    +        except (AIClientError, ConfigurationError):
    +            continue
    +    return allowed
    +
    +
     # =============================================================================
     # Command: devops ai prewarm
     # =============================================================================
    @@ -820,14 +844,18 @@ def prewarm(
             trace_span(
                 "ai.prewarm",
                 attributes={
    -                "ai.model": str(target_model),
                     "ai.evict": evict,
                     "ai.keep_alive": str(target_keep_alive),
                     "ai.all_nodes": all_nodes,
                 },
    -        ),
    +        ) as span,
         ):
             client = get_llm_client(settings=settings, cache_enabled=False)
    +        model_label = bounded_model_label(
    +            str(target_model),
    +            _prewarm_model_names(client, settings.ai.provider, urls, settings.ai.model),
    +        )
    +        span.set_attribute("ai.model", model_label)
             results = client.preload_models(
                 model=target_model,
                 keep_alive=target_keep_alive,
    @@ -847,7 +875,7 @@ def prewarm(
                 AI_PREWARMS_TOTAL,
                 1.0,
                 {
    -                "model": bounded_label(str(target_model)),
    +                "model": model_label,
                     "evict": str(evict).lower(),
                     "outcome": "ok" if success else "failed",
                 },
    diff --git a/src/devops_cli/config/constants.py b/src/devops_cli/config/constants.py
    index b03a5437..09849687 100644
    --- a/src/devops_cli/config/constants.py
    +++ b/src/devops_cli/config/constants.py
    @@ -977,6 +977,9 @@ CONST_AI_BACKEND_HOST_UNKNOWN = "unknown"
     # and marks of an Ollama model reference: `hf.co/org/repo:Q4_K_M`.
     CONST_METRIC_LABEL_MAX_LENGTH: Final[int] = 128
     CONST_METRIC_LABEL_UNSAFE_RE: Final[re.Pattern[str]] = re.compile(r"[^A-Za-z0-9._:/-]")
    +# The label value of a name that a caller sets when it is outside the fixed set that a command
    +# allows, so the number of series of a metric stays bounded (#2742).
    +CONST_METRIC_LABEL_OTHER: Final[str] = "other"
     # The `backend_info` of a reply the response cache answered, and the server its spend-ledger row
     # names: no backend served it, so spend reports leave it out of their server counts (#816).
     CONST_RESPONSE_CACHE_SERVER: Final[str] = "cache"
    diff --git a/src/devops_cli/telemetry/instruments.py b/src/devops_cli/telemetry/instruments.py
    index 2db70bc6..afe8dd80 100644
    --- a/src/devops_cli/telemetry/instruments.py
    +++ b/src/devops_cli/telemetry/instruments.py
    @@ -11,11 +11,16 @@ defined here; `tests/test_telemetry_instruments.py` checks each query.
     
     from __future__ import annotations
     
    +from collections.abc import Collection
     from dataclasses import dataclass
     from enum import StrEnum
     from typing import Any
     
    -from devops_cli.config.constants import CONST_METRIC_LABEL_MAX_LENGTH, CONST_METRIC_LABEL_UNSAFE_RE
    +from devops_cli.config.constants import (
    +    CONST_METRIC_LABEL_MAX_LENGTH,
    +    CONST_METRIC_LABEL_OTHER,
    +    CONST_METRIC_LABEL_UNSAFE_RE,
    +)
     
     
     class InstrumentKind(StrEnum):
    @@ -151,7 +156,7 @@ AI_PREWARMS_TOTAL = Instrument(
         InstrumentKind.COUNTER,
         "1",
         "devops ai prewarm runs, by model, evict (true when the run unloaded the model) and outcome: "
    -    "ok or failed",
    +    "ok or failed. A model that no server of the run reports shows as other",
     )
     AI_GATEWAY_PROBE_DURATION = Instrument(
         "devops_cli_ai_gateway_probe_duration_seconds",
    @@ -546,6 +551,16 @@ def bounded_label(value: str) -> str:
         return CONST_METRIC_LABEL_UNSAFE_RE.sub("_", value)[:CONST_METRIC_LABEL_MAX_LENGTH]
     
     
    +def bounded_model_label(value: str, allowed: Collection[str]) -> str:
    +    """A model name that a caller set, bounded to a fixed set of values and to a safe text.
    +
    +    The name keeps its own text, bounded by `bounded_label`, only when it is in `allowed`, the
    +    models that the run found. Any other name becomes `CONST_METRIC_LABEL_OTHER`, so a caller
    +    cannot add a series for each name it sends (#2742).
    +    """
    +    return bounded_label(value) if value in allowed else CONST_METRIC_LABEL_OTHER
    +
    +
     def backend_name(served_by: str | None) -> str:
         """A serving backend's short name: its host's first label, e.g. `ollama-16gib` or `ollama-0`."""
         if not served_by:
    @@ -625,5 +640,6 @@ __all__ = [
         "InstrumentKind",
         "backend_name",
         "bounded_label",
    +    "bounded_model_label",
         "emit",
     ]
    diff --git a/tests/ai/client/test_ai_client_providers_and_embeddings.py b/tests/ai/client/test_ai_client_providers_and_embeddings.py
    index 985ee084..e1fc3bf5 100644
    --- a/tests/ai/client/test_ai_client_providers_and_embeddings.py
    +++ b/tests/ai/client/test_ai_client_providers_and_embeddings.py
    @@ -735,6 +735,29 @@ def test_openai_and_ollama_list_models(monkeypatch: pytest.MonkeyPatch) -> None:
         assert raised.value.error_code == "LLM_INFERENCE_ERROR"
     
     
    +def test_ollama_list_models_asks_only_the_urls_it_is_given(monkeypatch: pytest.MonkeyPatch) -> None:
    +    """`list_models(urls=[...])` asks the servers it names, not the configured ones (#2742)."""
    +    ollama_cfg = AIConfig(
    +        provider="ollama",
    +        model="llama3",
    +        ollama_urls=["http://example.org:11434"],
    +        allow_private_network=True,
    +    )
    +    client = LLMClient(ollama_cfg)
    +
    +    def listing(request: httpx2.Request) -> httpx2.Response:
    +        return httpx2.Response(200, json={"models": [{"name": "llama3:latest"}]})
    +
    +    sent = route_client(client, monkeypatch, listing)
    +
    +    models = client.list_models(urls=["http://example.com:11434"])
    +
    +    assert (models, [str(request.url) for request in sent]) == (
    +        ["llama3:latest"],
    +        ["http://example.com:11434/api/tags"],
    +    )
    +
    +
     def test_chat_cache_and_starting_point(monkeypatch: pytest.MonkeyPatch) -> None:
         ollama_cfg = AIConfig(
             provider="ollama",
    diff --git a/tests/ai/mcp/test_ai_prewarm.py b/tests/ai/mcp/test_ai_prewarm.py
    index 38f41802..49a9dc9f 100644
    --- a/tests/ai/mcp/test_ai_prewarm.py
    +++ b/tests/ai/mcp/test_ai_prewarm.py
    @@ -14,13 +14,20 @@ if TYPE_CHECKING:
     import httpx2
     import pytest
     
    +from devops_cli.ai.client import AIClientError
     from devops_cli.ai.client.ollama import OllamaProviderMixin
     from devops_cli.ai.endpoints import resolve_prewarm_urls
     from devops_cli.commands.ai import render_prewarm_results
     from devops_cli.config.settings import AIConfig
    -from devops_cli.exceptions import ValidationError
    +from devops_cli.exceptions import ConfigurationError, ValidationError
     from devops_cli.telemetry.instruments import AI_PREWARMS_TOTAL
    -from tests.web_fakes import PUBLIC_ADDRESS, http_response, record_connects, scripted_resolver
    +from tests.web_fakes import (
    +    PUBLIC_ADDRESS,
    +    ConnectRecorder,
    +    http_response,
    +    record_connects,
    +    scripted_resolver,
    +)
     
     
     class DummyOllamaProvider(OllamaProviderMixin):
    @@ -348,6 +355,7 @@ class TestCLIPrewarmCommand:
             outcome: str,
         ) -> None:
             """Verify devops ai prewarm counts its run one time, by model, evict and outcome."""
    +        model_fake.set_available_models(["gemma4:26b"])
             model_fake.set_preload_results({"http://localhost:11434": node_ok})
     
             result = cli("ai", "prewarm", "--model", "gemma4:26b", "--single-node")
    @@ -397,6 +405,28 @@ PREWARM_TOOL_PARAMETERS = [
     """The parameters that the MCP tool of `devops ai prewarm` publishes: no URL."""
     
     _PREWARM_REQUEST_LINE = b"POST /api/generate HTTP/1.1"
    +_CLOSE_CONNECTION = {"Connection": "close"}
    +"""A reply that closes its connection, so the next request of the run dials and takes the next
    +scripted answer: the fake stream serves one response on each connection."""
    +
    +
    +def _requests(recorder: ConnectRecorder, request_line: bytes) -> list[bytes]:
    +    """The requests that the recorder received with `request_line`, in dial order."""
    +    return [bytes(written) for written in recorder.written if bytes(written).startswith(request_line)]
    +
    +
    +def _request_host(request: bytes) -> str:
    +    """The `Host` header of one recorded request."""
    +    return next(
    +        line.removeprefix(b"Host: ").decode()
    +        for line in request.split(b"\r\n")
    +        if line.startswith(b"Host: ")
    +    )
    +
    +
    +def _request_json(request: bytes) -> Any:
    +    """The JSON body of one recorded request."""
    +    return json.loads(request.partition(b"\r\n\r\n")[2])
     
     
     async def _call_prewarm_tool(arguments: dict[str, object]) -> tuple[bool, str]:
    @@ -469,20 +499,21 @@ class TestPrewarmToolTakesNoUrlFromTheModel:
                 monkeypatch,
                 {"example.com": [[PUBLIC_ADDRESS]], "example.org": [[PUBLIC_ADDRESS]]},
             )
    -        recorder = record_connects(monkeypatch, [http_response(200, "{}")] * 2)
    +        recorder = record_connects(
    +            monkeypatch, [http_response(200, "{}", headers=_CLOSE_CONNECTION)] * 4
    +        )
     
             failed, reply = await _call_prewarm_tool({"keep_alive": "24h"})
    +        posts = _requests(recorder, _PREWARM_REQUEST_LINE)
     
             assert (
                 failed,
    -            sorted(recorder.requested_hosts),
    -            [bytes(written).split(b"\r\n")[0] for written in recorder.written],
    -            [json.loads(bytes(written).partition(b"\r\n\r\n")[2]) for written in recorder.written],
    +            sorted(_request_host(post) for post in posts),
    +            [_request_json(post) for post in posts],
                 reply.count("confirmed HTTP 200 (keep_alive=24h)"),
             ) == (
                 False,
                 ["example.com:11434", "example.org:11434"],
    -            [_PREWARM_REQUEST_LINE] * 2,
                 [{"model": "gemma4:26b", "prompt": "", "keep_alive": "24h"}] * 2,
                 2,
             )
    @@ -511,12 +542,16 @@ class TestPrewarmToolTakesNoUrlFromTheModel:
             """
             monkeypatch.setenv("DEVOPS_CLI_AI_ALLOW_PRIVATE_NETWORK", str(flag).lower())
             config(ai={"provider": "ollama", "ollama_urls": [f"http://{address}:11434"]})
    -        recorder = record_connects(monkeypatch, [http_response(200, "{}")] * 2)
    +        recorder = record_connects(
    +            monkeypatch, [http_response(200, "{}", headers=_CLOSE_CONNECTION)] * 4
    +        )
     
             await _call_prewarm_tool({})
     
    -        assert [dial for dial in recorder.dialled if dial[0] == address] == (
    -            [(address, 11434)] if dialled else []
    +        dials = [dial for dial in recorder.dialled if dial[0] == address]
    +        assert (dials, len(_requests(recorder, _PREWARM_REQUEST_LINE))) == (
    +            [(address, 11434)] * 2 if dialled else [],
    +            1 if dialled else 0,
             )
     
         def test_the_url_option_of_the_command_prewarms_the_host_that_a_person_types(
    @@ -531,11 +566,17 @@ class TestPrewarmToolTakesNoUrlFromTheModel:
                 monkeypatch,
                 {"example.com": [[PUBLIC_ADDRESS]], "example.org": [[PUBLIC_ADDRESS]]},
             )
    -        recorder = record_connects(monkeypatch, [http_response(200, "{}")] * 2)
    +        recorder = record_connects(
    +            monkeypatch, [http_response(200, "{}", headers=_CLOSE_CONNECTION)] * 2
    +        )
     
             result = cli("ai", "prewarm", "--url", "http://example.com:11434")
     
    -        assert (result.exit_code, recorder.requested_hosts) == (0, ["example.com:11434"])
    +        assert (
    +            result.exit_code,
    +            sorted(set(recorder.requested_hosts)),
    +            [_request_host(post) for post in _requests(recorder, _PREWARM_REQUEST_LINE)],
    +        ) == (0, ["example.com:11434"], ["example.com:11434"])
     
     
     _SERVER_URL_WITH_SECRETS = "http://FAKE-2676-user@example.com:11434/?x=FAKE-2676-query"
    @@ -551,7 +592,7 @@ class TestPrewarmNamesEachServerByHostAndPort:
             """One configured server whose URL holds a user name and a query value, and a 200 reply."""
             config(ai={"provider": "ollama", "ollama_urls": [_SERVER_URL_WITH_SECRETS]})
             scripted_resolver(monkeypatch, {"example.com": [[PUBLIC_ADDRESS]]})
    -        record_connects(monkeypatch, [http_response(200, "{}")] * 2)
    +        record_connects(monkeypatch, [http_response(200, "{}", headers=_CLOSE_CONNECTION)] * 2)
     
         @pytest.mark.usefixtures("served")
         @pytest.mark.parametrize("json_output", [False, True], ids=["table", "json"])
    @@ -636,9 +677,165 @@ class TestPrewarmCounterModelLabel:
             label: str,
         ) -> None:
             """The counter holds the model as a label of safe characters and at most 128 of them."""
    +        model_fake.set_available_models([model])
             result = cli("ai", "prewarm", "--model", model, "--single-node")
     
             assert (result.exit_code, [a["model"] for a, _ in otlp.points(AI_PREWARMS_TOTAL.name)]) == (
                 0,
                 [label],
             )
    +
    +
    +def _prewarm_counter_models(otlp: FakeCollector) -> list[Any]:
    +    """The `model` label of each point of the prewarm counter."""
    +    return [attributes["model"] for attributes, _ in otlp.points(AI_PREWARMS_TOTAL.name)]
    +
    +
    +def _prewarm_span_models(otlp: FakeCollector) -> list[Any]:
    +    """The `ai.model` attribute of each exported `ai.prewarm` span, in export order."""
    +    return [span.attributes.get("ai.model") for span in otlp.spans if span.name == "ai.prewarm"]
    +
    +
    +class TestPrewarmAsksTheServersOfTheRun:
    +    """The run asks each server that it prewarms for its models, and no other server (#2742)."""
    +
    +    def test_the_run_asks_the_server_that_the_url_option_names(
    +        self, cli: Callable[..., Any], model_fake: ModelFake, config: Callable[..., Any]
    +    ) -> None:
    +        """`--url` asks that server only, never a configured server that the person did not name."""
    +        config(ai={"provider": "ollama", "ollama_urls": ["http://example.org:11434"]})
    +
    +        result = cli("ai", "prewarm", "--url", "http://example.com:11434")
    +
    +        assert (result.exit_code, model_fake.list_models_calls) == (
    +            0,
    +            [{"urls": ["http://example.com:11434"]}],
    +        )
    +
    +    def test_the_run_asks_each_configured_server(
    +        self, cli: Callable[..., Any], model_fake: ModelFake, config: Callable[..., Any]
    +    ) -> None:
    +        """With no URL, the run asks every configured server, one request for each."""
    +        config(
    +            ai={
    +                "provider": "ollama",
    +                "ollama_urls": ["http://example.com:11434", "http://example.org:11434"],
    +            }
    +        )
    +
    +        result = cli("ai", "prewarm")
    +
    +        assert (result.exit_code, model_fake.list_models_calls) == (
    +            0,
    +            [
    +                {"urls": ["http://example.com:11434"]},
    +                {"urls": ["http://example.org:11434"]},
    +            ],
    +        )
    +
    +    def test_a_provider_that_is_not_ollama_asks_no_server(
    +        self, cli: Callable[..., Any], model_fake: ModelFake, config: Callable[..., Any]
    +    ) -> None:
    +        """A provider whose prewarm does nothing sends no request for a list of models."""
    +        config(ai={"provider": "openai", "model": "gpt-4o"})
    +
    +        result = cli("ai", "prewarm")
    +
    +        assert (result.exit_code, model_fake.list_models_calls) == (0, [])
    +
    +
    +class TestPrewarmSpanModelAttribute:
    +    """The attribute `ai.model` of the span `ai.prewarm` holds the same text as the label `model`
    +    of the counter of that run (#2742)."""
    +
    +    def test_a_model_that_no_server_reports_is_other(
    +        self, cli: Callable[..., Any], model_fake: ModelFake, otlp: FakeCollector
    +    ) -> None:
    +        """A model that no server of the run reports shows as `other` in both records."""
    +        model_fake.set_available_models(["qwen3.8:27b"])
    +
    +        result = cli("ai", "prewarm", "--model", "not-on-any-node:1b", "--single-node")
    +
    +        assert (
    + 

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

  11. added
    status/blocked
    and removed
    status/in-progress
    on Nov 5, 2026
  12. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261105-130558-7412 ended: succeeded.
    Image digest: sha256:6bc82a08499f4a63a392c2f90b69b446ca4fa74684edc72a401fa5f91ab1fc56

    The last lines of its log:

    Tool call: edit_file, ok.
    Tool call: read_file, ok.
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Tool call: grep, ok.
    Tool call: edit_file, ok.
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: grep, ok.
    Tool call: read_file, ok.
    Tool call: grep, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: grep, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: uv run devops ci test tests/ai/mcp/test_ai_prewarm.py ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run ruff check src/devops_cli/config/constants.py src/devops_cli/telemetry/instruments.py ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run mypy --strict src/devops_cli/config/constants.py src/devops_cli/telemetry/instruments.py ...
    Tool call: shell, program uv, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: uv run ast-grep scan --error=<masked> --error=<masked> ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci --only test-tree
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci --only openspec
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci --only constructs,startup-imports,swallowed-failures
    Tool call: shell, program uv, ok.
    Tool call: grep, ok.
    Tool call: shell, started: uv run devops ci test tests/commands/test_ai_model_gateway_dry_run.py ...
    Tool call: shell, program uv, ok.
    Failure class limit_reached. Action left: raise_limit.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 15m 59s
    
  13. removed
    owner/service
    on Nov 5, 2026
  14. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/blocked
    status/in-progress
    on Nov 19, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 19, 2026
  16. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor
  17. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-19 11:42 UTC

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/aisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions