Repository navigation
Description
Problem Description
The MCP tool ai_prewarm lets the calling model set model. devops ai prewarm uses that text in two telemetry records:
- The label
modelof the counterdevops_cli_ai_prewarms_total(src/devops_cli/commands/ai.py, theemit(AI_PREWARMS_TOTAL, ...)call). PR fix(ai): name each prewarm server by host and port #2737 (fix(ai): the prewarm output names each Ollama server by its configured URL #2676) bounds the length and the characters of the label withbounded_label. It does not bound the number of values. A calling model that sends 10000 different model names makes 10000 series in the metrics backend. - The span attribute
ai.modelof the spanai.prewarm(src/devops_cli/commands/ai.py, thetrace_span("ai.prewarm", ...)call). It still carries the raw model text, with any length and any characters.
Reproduction Steps
- Use a temporary
HOME, the null keyring,ai.providerset toollamaand a loopback listener. - Call the MCP tool
ai_prewarmmany times with a differentmodelvalue each time, through a FastMCPClient. - Read the exported series of
devops_cli_ai_prewarms_totaland the attributeai.modelof 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
dan-petty commentedon Oct 30, 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.(ai)scope of the title gives the scope.Unbounded cardinality can exhaust the metrics backend but does not break the prewarm function itself.Protects the metrics backend from series explosion but does not change user-facing behaviour.Requires tracking allowed model values and bucketing the rest in both the counter and the span attribute.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.devops-cli-service commentedon Oct 30, 2026
Status set to Ready at 7c931b9 (see proposed design in issue body).
devops-cli-service commentedon Nov 2, 2026
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:
docs(openspec): fix the plan for #2742 after review
docs(openspec): plan #2742 Bound prewarm model label cardinality (#3163)
4 remaining items
devops-cli-service commentedon Nov 5, 2026
Stopped at group 1.
Failure class:
limit_reached.Action taken: none.
Action left:
raise_limit: raise the limit that the run went over.Reason:
Last message of the agent (a claim that no check verified): Now
_ollama_modelsin ollama.py:The job discarded this work. The diff is cut to 20000 characters. Read it before you retry:
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 ofroadmap.implement.digest_clears_per_classandroadmap.implement.digest_clears_per_itemallow it.devops-cli-service commentedon Nov 5, 2026
The runner Job devops-cli-runner-20261105-130558-7412 ended: succeeded.
Image digest: sha256:6bc82a08499f4a63a392c2f90b69b446ca4fa74684edc72a401fa5f91ab1fc56
The last lines of its log:
devops-cli-service commentedon Nov 19, 2026
Released in v0.179.5: https://github.com/dan-petty/devops-cli/releases/tag/v0.179.5
devops-cli-service commentedon Nov 19, 2026
Live since 2026-11-19 11:42 UTC