Skip to content

feat(ai): a setting holds the price of a reference model #4242

Closed

Description

@dan-petty

Problem

The price of a reference model that genai-prices does not know is a hand-set file. The reference models qwen3.8:27b and qwen/qwen3-embedding-8b (owner decision of 2026-11-09, see #4241) have no genai-prices entry (genai-prices 0.1.13 raises LookupError for both names). The Service holds their prices in /home/devops/.data/ai/pricing_overrides.json on the PVC roadmap-service-home, written with devops ai cost set-price inside the pod. The file is not in git. A new PVC, a new workstation or a new cluster has no price: PricingRegistry.price_reference then logs an unpriced warning, and the savings in devops ai cost show as not priced.

Expected

A price that the repository owns reaches every process that reads the ConfigMap. The smallest way found: a setting under ai (for example ai.price_overrides, a map of model name to prompt and completion USD per million tokens) that PricingRegistry reads in _load_persisted_overrides, with a price in the file on the volume winning over it. The template k8s/devops/configmap.example.yaml then holds the two prices, and no hand step stays.

Acceptance criteria

  • uv run devops ci test tests/ai/spend/test_pricing_registry_overrides.py passes with a new test: a Settings with ai.price_overrides for qwen3.8:27b gives PricingRegistry.get_pricing("qwen3.8:27b", provider="openai") the set prices, with an empty data directory (fails today: the field does not exist).
  • The key-walk test uv run devops ci test tests/k8s/test_k8s_configmap_keys.py passes with the two prices in the template.
  • uv run devops docs generate --sync-readme leaves no diff.

Existing tool considered

  • devops ai cost update-pricing --source <file> takes a genai-prices provider array and saves it as pricing_snapshot.json in the same data directory, so it needs a hand step and a file on the volume too.
  • A second ConfigMap key mounted with subPath over pricing_overrides.json needs no code, but it covers the file of the PVC and makes devops ai cost set-price fail in the pod.
  • genai-prices has no setting for a price of its own.

Cost

About 80,000 tokens to build (setting, registry change, tests, docs) and review; 5 to 10 minutes of CI under the shared lock. Keeping it costs nothing.

Related

#4241, #3665, #3658

Proposed design

Problem statement

The prices of the reference models qwen3.8:27b and qwen/qwen3-embedding-8b live only in a hand-written file, pricing_overrides.json, on the PVC roadmap-service-home. The repository does not own them. A new PVC, workstation or cluster has no price, so PricingRegistry.price_reference logs an unpriced warning and the savings in devops ai cost show as not priced. A setting under ai that the ConfigMap template holds removes the hand step.

Acceptance criteria

Requirement: Setting price overrides

The Settings model SHALL declare ai.price_overrides as a map of model name to prompt and completion USD per million tokens.

Scenario: Settings load a price

  • WHEN a Settings is built with ai.price_overrides for qwen3.8:27b
  • THEN the model validates and holds the prompt and completion prices set for that name

Requirement: Registry reads the setting

PricingRegistry SHALL price a model from ai.price_overrides when the data directory holds no pricing_overrides.json.

Scenario: Empty data directory

  • WHEN PricingRegistry is built from a Settings with ai.price_overrides for qwen3.8:27b and an empty data directory, and get_pricing is called with the provider openai
  • THEN get_pricing returns the prices set in the setting and logs no unpriced warning

Requirement: File on the volume wins

PricingRegistry MUST use the price in pricing_overrides.json instead of the price in ai.price_overrides when both name the same model.

Scenario: Both sources set a price

  • WHEN the setting and the file in the data directory give different prices for the same model
  • THEN get_pricing returns the price from the file

Requirement: Template holds the prices

The template k8s/devops/configmap.example.yaml SHALL set ai.price_overrides for qwen3.8:27b and qwen/qwen3-embedding-8b, and every key SHALL be a declared setting.

Scenario: Key walk of the template

  • WHEN tests/k8s/test_k8s_configmap_keys.py walks the rendered template
  • THEN unknown_setting_keys returns an empty list and Settings validates the whole example

Requirement: Generated documentation stays current

The change SHALL update the generated configuration documentation so that devops docs generate --sync-readme leaves no diff.

Scenario: Docs sync

  • WHEN uv run devops docs generate --sync-readme runs after the change
  • THEN the working tree has no diff

Existing Tool Considered

No open library covers this. genai-prices 0.1.13 has no setting for a price of its own and raises LookupError for both reference models. devops ai cost update-pricing --source needs a hand step and a file on the volume. A ConfigMap key mounted with subPath over pricing_overrides.json needs no code, but it makes devops ai cost set-price fail in the pod. The change builds a small setting and a registry read on top of the existing override path. The cost is about 80,000 tokens to build and review, and 5 to 10 minutes of CI under the shared lock. Keeping it costs nothing.

Key questions

  • Where does PricingRegistry read the persisted overrides today?: The method _load_persisted_overrides in src/devops_cli/ai/spend/pricing.py reads the file in the data directory into self._overrides, keyed by the lower-cased model name, each value validated as ModelPricing. It is called only from _load_local_data in the constructor, so the change extends that method. [sources: src/devops_cli/ai/spend/pricing.py:395, src/devops_cli/ai/spend/pricing.py:456]
  • Which source wins when the setting and the file on the volume price the same model?: The file on the volume wins. The body states this rule, and it keeps devops ai cost set-price working in the pod. The registry loads the setting into self._overrides first and the file after it, so the file overwrites the same key. (best practice) [sources: k8s/devops/configmap.example.yaml, src/devops_cli/ai/spend/pricing.py:456]
    • Chosen: File on the volume wins. The body states it, and a hand price set in the pod stays in force.
    • Rejected: Setting wins. A price set with set-price would silently stop working.
  • What is the shape of the ai.price_overrides value?: A map of model name to an object with prompt_usd_per_million and completion_usd_per_million, the field names and units of ModelPricing and of the override file. The setting validates a non-negative float for each. Keys are lower-cased on load, as the file path does. (best practice) [sources: src/devops_cli/ai/spend/models.py:15, src/devops_cli/ai/spend/pricing.py:465]
    • Chosen: Map of name to prompt and completion prices. It matches the body and the units and field names of ModelPricing and the override file.
    • Rejected: A path to a second price file. It needs a file on the volume and keeps the hand step.
  • How does PricingRegistry receive the setting?: The PricingRegistry constructor takes an optional settings argument and falls back to load_settings(), which it already calls when data_dir is None. get_pricing_registry passes it through, and no caller changes, since the callers in ledger.py, embeddings.py, ai_cost.py and stage_eval_usage.py call get_pricing_registry() with no argument. The new test passes a Settings and a tmp_path data_dir directly. The setting is read in _load_persisted_overrides before the file. (best practice) [sources: src/devops_cli/ai/spend/pricing.py:374, src/devops_cli/ai/spend/pricing.py:378, src/devops_cli/ai/spend/pricing.py:787, src/devops_cli/ai/spend/ledger.py:295]
    • Chosen: Optional settings argument, default load_settings(). It matches how the constructor already loads settings, keeps every caller unchanged and lets a test inject a Settings.
    • Rejected: Change get_pricing_registry callers to pass settings. It touches many call sites for no gain.
    • Rejected: A new module global for the prices. It adds hidden state next to the existing singleton.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/ai
    status/new
    value/medium
    effort/medium
    on Nov 9, 2026
  2. dan-petty commented on Nov 9, 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/feature. The feat prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. Prices are lost on new PVCs or workstations, but a hand-set workaround exists and the impact is limited to cost reporting.
    • Value: Medium. Removes a manual step and prevents silent loss of reference-model prices across environments.
    • Effort: Medium. Requires a new setting field, a PricingRegistry code change, tests, and a template update; body estimates about 80,000 tokens of work.
    • Related: fix(k8s): the ConfigMap template names the reference models #4241, which asks for a different change. Both target the same ConfigMap template and the same two reference models, but #4241 names the models while the candidate stores their prices via a new ai.price_overrides setting.
  3. added
    priority/p2-medium
    on Nov 9, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 9, 2026
  5. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

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

  6. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 9, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 9, 2026
  8. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-09 21:49 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/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions