Repository navigation
Description
Problem
The disagreement pair spend of the project review (src/devops_cli/roadmap/project_review/catalog.yaml) compares prometheus.cli_spend, sum(increase(devops_cli_ai_spend_usd_total[{range}])), with prometheus.gateway_spend, sum(increase(litellm_spend_metric_total[{range}])). Its definition says "devops-cli and the gateway count the same model calls through the gateway". The two counters do not count the same calls, so the pair gives a disagreement in each window and tells nothing.
Read-only queries of the live Prometheus, windows of one day:
| Window end | cli_spend | gateway_spend | Difference |
|---|---|---|---|
| 2026-11-07T00:00Z | 0.32 USD | 1.85 USD (anthropic 0.21, openrouter 1.64) | 83% |
| 2026-11-17T12:00Z | 7.55 USD (refine 3.41, stage 3.06, implement 0.75, alternatives 0.34) | 5.61 USD (openrouter 5.59, health check 0.02) | 26% |
- Every series of
devops_cli_ai_spend_usd_totalin the second window hasprovider="gateway", so each call that devops-cli counted went through the gateway. litellm_spend_metric_totalgivesapi_key_alias="None"andteam_alias="None"for every client call. The gateway counter thus has no label that selects the calls of devops-cli. In the first window, other clients of the gateway (not devops-cli) spent most of the 1.85 USD.- In the second window, devops-cli counted 35% more than the gateway counted for all clients together. fix(llm): Pass the OpenRouter cost of a streamed call through #6165 (the gateway under-counts a streamed OpenRouter call by about 15%) explains only a part. fix(ai): Price each gateway call at the deployment that answered #6002 makes the client price lower, not higher.
The difference changes direction between the windows, so a fix of #6165 or #6002 alone does not make the pair agree.
Expected
The pair compares the same set of calls, or the review does not show it:
- Give each gateway client its own virtual key with an alias (LiteLLM virtual keys,
api_key_aliaslabel), and readlitellm_spend_metric_total{api_key_alias="<alias of devops-cli>"}on the gateway side. Or - Remove the pair, and keep the two facts as separate values.
Then find the cause of the remaining gap of the second window (client price of a cached or streamed call against the gateway price), and comment it on #6165 or #6002, or file it.
Acceptance criteria
- The definition of the pair names the set of calls that both sides count.
- A live read-only review of one day after the change shows the pair within its tolerance, or the PR names the cause that remains, with its issue.
Dependencies
None. Related: #6165, #6002, #6612.
Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: BerriAI/litellm (https://github.com/BerriAI/litellm), NOASSERTION, last activity 2026-11-21, maintained.
Reason: Searches found LiteLLM, the gateway the review already reads; its virtual keys with an api_key_alias give the gateway side the same call set, but the client counter and the streamed-call and price gaps remain.
Covers:
- A virtual key and alias for each gateway client
- Spend metric labelled by
api_key_aliasto select one client - Per-key spend and budget records in the gateway database
Lacks:
- No alias today, so every client call reads
None - Streamed OpenRouter calls under-counted on the gateway (fix(llm): Pass the OpenRouter cost of a streamed call through #6165)
- Client price still differs from gateway price (fix(ai): Price each gateway call at the deployment that answered #6002)
Proposed design
Problem statement
The spend disagreement pair in the project review compares prometheus.cli_spend with prometheus.gateway_spend. The gateway spend counter counts every caller, while the stage Job, the runner Jobs and the CLI send the gateway master key, so api_key_alias is None for their calls and no label selects the same call set as devops_cli_ai_spend_usd_total. The pair therefore disagrees in each window and tells nothing. Remove the pair and keep both spend facts as separate values, and record the cause that remains on #6165 or #6002, or file it.
Acceptance criteria
Requirement: No spend disagreement pair
The project review catalog SHALL define no disagreement pair named spend.
Scenario: Live review omits the spend pair
- WHEN I run the live read-only review with
uv run devops roadmap review run --since 2026-11-16T12:00Z --until 2026-11-17T12:00Z. - THEN The review lists no
spenddisagreement.
Requirement: Both spend facts stay separate
The project review catalog MUST keep prometheus.cli_spend and prometheus.gateway_spend as separate facts.
Scenario: Dry run lists both spend facts
- WHEN I run
uv run devops roadmap review run --dry-run --since 2026-11-16T12:00Z --until 2026-11-17T12:00Z. - THEN The command exits 0 and prints a line for
prometheus.cli_spendand a line forprometheus.gateway_spend.
Existing Tool Considered
LiteLLM (BerriAI/litellm) is in use. The alternatives block of the issue body records what it lacks. This proposal does not add a virtual-key alias path: it removes the spend disagreement pair and keeps prometheus.cli_spend and prometheus.gateway_spend as separate facts, so the review compares no different call sets and the open gaps stay on their issues.
Key questions
- What does the
spenddisagreement pair compare today?: It comparesprometheus.cli_spend,sum(increase(devops_cli_ai_spend_usd_total[{range}])), withprometheus.gateway_spend,sum(increase(litellm_spend_metric_total[{range}])). [sources: src/devops_cli/roadmap/project_review/catalog.yaml:891, src/devops_cli/roadmap/project_review/catalog.yaml:899, src/devops_cli/roadmap/project_review/catalog.yaml:922] - Should the project review use a LiteLLM virtual-key alias for the
spendpair or remove the pair?: Remove thespenddisagreement pair fromsrc/devops_cli/roadmap/project_review/catalog.yamland keepprometheus.cli_spendandprometheus.gateway_spendas separate facts. (best practice) [sources: src/devops_cli/roadmap/project_review/catalog.yaml:922, k8s/devops/cronjob-stage.yaml:110, k8s/devops/cronjob-runner.yaml:167, k8s/devops/roadmap-service/deployment.yaml:89, src/devops_cli/commands/k8s/roadmap_key_bootstrap.py:58]- Rejected: Add a virtual key and alias for each gateway client and filter
litellm_spend_metric_totalbyapi_key_alias. The stage Job, the runner Jobs and the CLI send the master key, so their calls readapi_key_alias=None; only the roadmap Service Deployment uses a virtual key with the aliasroadmap-service. Giving every client its own key and wiring it through the Jobs, the CLI and the secrets is a larger change, and the streamed-call and price gaps remain. - Chosen: Remove the
spenddisagreement pair and keep the two spend facts separate. The review stops comparing different call sets. The two facts stay visible, and the open gaps stay on their issues.
- Rejected: Add a virtual key and alias for each gateway client and filter
- Which label selects devops-cli calls in
litellm_spend_metric_totaltoday?: None selects all devops-cli calls. The gateway spend counter counts every caller (k8s/README.md:364). The stage Job and the runner Jobs readDEVOPS_CLI_AI_API_KEYfrom Secretdevops-cli, which holds the gateway master key (k8s/devops/cronjob-stage.yaml:110,k8s/devops/cronjob-runner.yaml:167,k8s/README.md:777), so their calls readapi_key_alias=None. The roadmap Service Deployment is the only workload that reads its own virtual key (k8s/devops/roadmap-service/deployment.yaml:89), anddevops k8s bootstrap-roadmap-keymints that key with the aliasroadmap-service(src/devops_cli/commands/k8s/roadmap_key_bootstrap.py:58), soapi_key_aliasselects that pod's calls alone. The gateway'send_userlabel names callers on the request and token series, not on the spend series (k8s/llm/gateway/config.yaml:301). [sources: k8s/README.md:364, k8s/README.md:777, k8s/devops/cronjob-stage.yaml:110, k8s/devops/cronjob-runner.yaml:167, k8s/devops/roadmap-service/deployment.yaml:89, src/devops_cli/commands/k8s/roadmap_key_bootstrap.py:58, k8s/llm/gateway/config.yaml:301]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 21, 2026
Both address the spend gap between devops-cli and the gateway, but #4734 changes what cost devops-cli records while this candidate fixes the pair to compare the same call set.devops-cli-service commentedon Nov 21, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 22, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 25, 2026
Released in v0.218.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.218.2
devops-cli-service commentedon Nov 25, 2026
Live since 2026-11-25 08:43 UTC