Repository navigation
Description
Problem or Motivation
The Jev calls (#4289) pass through the gateway as a LiteLLM pass-through (POST /v1/systemone). LiteLLM records no spend for a pass-through that has no cost_per_request, so the spend ledger and the gateway metrics do not count these calls. OpenRouter returns the cost of each call in usage.cost of the answer body. The calls cost about 0.00002 USD each, but the volume can grow when #4282 and #4284 call Jev at each stage run.
Expected
The cost of a Jev call appears in the spend report. Either the client records usage.cost of the answer in the spend ledger, or the pass-through sets a cost for each request. A person or an agent first checks which of the two is the smaller change.
Acceptance criteria
- A test with the HTTP fake shows that one Jev call adds its cost to the spend ledger.
devops ai costlists the Jev model with a non-zero token count after a call.
Existing tool considered
LiteLLM cost_per_request on pass_through_endpoints (docs: https://docs.litellm.ai/docs/proxy/pass_through) covers a fixed cost; the answer header x-litellm-response-cost covers a variable cost. Not yet checked against the pinned image v1.103.0.
Related
Proposed design
Problem statement
Jev calls reach OpenRouter through the gateway pass-through POST /v1/systemone. LiteLLM records no spend for a pass-through that has no cost_per_request. The code of this repository records none either: ask_jev, route_with_jev, the intake and the completeness check call DecisionModel.decide directly, which is not an Agent run, so the build_agent spend hook never sees these calls. So the spend ledger (spend.db), devops ai cost and the metrics do not count Jev calls. The volume can grow when #4282 and #4284 call Jev at each stage run.
Acceptance criteria
Requirement: Jev call recorded in the spend ledger
The system SHALL record each Jev decision call in the spend ledger with the model typesafe/jev-1.14, the input and output tokens of the answer, and a cost that is above 0 and priced from the Jev price.
Scenario: One Jev call through the JevFake
- WHEN a test runs one Jev decision call (for example
ask_jev) against theJevFaketransport, which answers with 64 input tokens, with a temporary spend ledger and the Jev price set - THEN the ledger holds one row for
typesafe/jev-1.14with 64 prompt tokens and a cost equal to 64 input tokens at the Jev price
Requirement: Jev model in the cost report
The command devops ai cost report MUST list the Jev model with a non-zero token count after a Jev call.
Scenario: Cost report after one Jev call
- WHEN one Jev call has been recorded in a temporary ledger and
devops ai cost report --by modelruns - THEN the report lists
typesafe/jev-1.14with a non-zero token count
Requirement: Failed or unpriced Jev call does not break the call
A Jev call MUST NOT fail or lose its answer when the spend record cannot be written or the answer has no usage.
Scenario: Ledger write fails
- WHEN the ledger raises while the Jev call is recorded
- THEN the call returns its typed answer and no exception reaches the caller
Existing Tool Considered
LiteLLM cost_per_request on pass_through_endpoints (https://docs.litellm.ai/docs/proxy/pass_through) covers a fixed cost for each request only. It cannot follow the input-token billing of Jev and it gives no token count, so it cannot meet the acceptance criterion on a token count. The header x-litellm-response-cost was not checked against the pinned image v1.103.0. The repository already has the tools for the client side: track_request_spend (src/devops_cli/ai/spend/ledger.py:926), the PricingRegistry with ai.price_overrides (src/devops_cli/ai/spend/pricing.py:599) and the library pydantic_ai SystemOneModel, which returns the token usage in DecisionResponse.usage. The change builds a thin wrapper around model.decide that calls track_request_spend, plus one price entry (0.042 USD per million input tokens, 0 for output, from k8s/README.md:130). Cost: a small number of tokens to write and test it, and less than one day of elapsed time. No new dependency.
Key questions
- Which option is the smaller change: the client records the cost of the answer, or the pass-through sets a cost for each request?: The client records the call. Its
track_request_spendalready writes the ledger and the metrics and prices the call from the tokens. A fixedcost_per_requeston the gateway is a config change, but it gives a wrong cost, since Jev bills by input tokens, and no token count. The gateway ledger is also not the ledger thatdevops ai costreads. Readingusage.costneeds a custom parse of the HTTP body, becauseSystemOneModelkeeps only the token usage and ignores the extra OpenRouter fields (archived proposal of fix(ai): the gateway has no route for the Jev Decisions API #4289). Pricing the recorded tokens at the known Jev price (0.042 USD per million input tokens, 0 for output) gives the same cost with the existing pricing registry. (best practice) [sources: src/devops_cli/ai/spend/ledger.py:926, src/devops_cli/ai/spend/pricing.py:599, src/devops_cli/ai/jev_ask.py:253, k8s/README.md:130, openspec/changes/archive/2026-11-10-4289-the-gateway-has-no-route-for/proposal.md:30]- Chosen: Client records tokens through track_request_spend, priced by the Jev price. It reuses the spend writer, the pricing registry and the report. It gives the token count that the acceptance criteria need. The change is small.
- Rejected: cost_per_request on the pass-through. It gives a fixed cost that does not follow the input tokens, no token count, and the gateway spend is not the local ledger of
devops ai cost. - Rejected: Read usage.cost from the answer body. pydantic-ai drops the field, so a custom HTTP parse would replace the library path. The cost is already known from the tokens and the price.
- Rejected: Read the header x-litellm-response-cost. It is not confirmed for pass-through routes in v1.103.0, and the client path through
SystemOneModeldoes not expose headers.
- Where does a Jev call reach the spend ledger, and which code holds the Jev calls?: The ledger is written by
track_request_spend, which callsSpendLedger.record_requestand prices the call withPricingRegistry.calculate_request_cost. The Agent hook inbuild_agentcalls it, but the Jev calls do not run through an Agent:DecisionModel.decideis called directly insrc/devops_cli/ai/jev.py(_run_decide),src/devops_cli/ai/jev_ask.py(ask_jev),src/devops_cli/roadmap/intake/intake_jev.pyandsrc/devops_cli/roadmap/jev_completeness.py. So the wrapper goes at these four calls, as one shared function. The model is built by_jev_decision_modelinsrc/devops_cli/ai/pydantic_ai_bridge.py, which setsserved_byfor a gateway. [sources: src/devops_cli/ai/spend/ledger.py:926, src/devops_cli/ai/spend/ledger.py:468, src/devops_cli/ai/client/factory.py:213, src/devops_cli/ai/jev.py:172, src/devops_cli/ai/jev_ask.py:240, src/devops_cli/roadmap/jev_completeness.py:148, src/devops_cli/roadmap/intake/intake_jev.py:236, src/devops_cli/ai/pydantic_ai_bridge.py:135] - How does the Jev call get a non-zero cost, when
typesafe/jev-1.14is no gateway group?: The wrapper passesserved_model="typesafe/jev-1.14"with providergateway, so the ledger treats the call as hosted. Today the rule that does this needs the model to be inCONST_AI_GATEWAY_HOSTED_MODELS, which no longer lists Jev after fix(ai): the gateway has no route for the Jev Decisions API #4289. The price comes from an entry fortypesafe/jev-1.14inai.price_overrides(0.042 prompt, 0 completion USD per million), whichcalculate_request_costreads for a served model. The change sets the entry ink8s/devops/configmap.example.yamland gives the registry a built-in default, so a workstation also prices it. Whether genai-prices knows this model was not checked; the override makes the price independent of it. (best practice) [sources: src/devops_cli/ai/spend/ledger.py:974, src/devops_cli/ai/spend/pricing.py:621, k8s/devops/configmap.example.yaml:39, k8s/README.md:130, docs/CONFIGURATION.md:206]- Chosen: Price override for typesafe/jev-1.14 plus served_model in the wrapper. It uses the existing override mechanism (feat(ai): a setting holds the price of a reference model #4242) and needs no change to the pricing code.
- Rejected: Add Jev back to CONST_AI_GATEWAY_HOSTED_MODELS. The constant lists the groups of the gateway, and Jev is not a group (fix(ai): the gateway has no route for the Jev Decisions API #4289); a test fails when they differ.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-11: partly.
Tool: BerriAI/litellm (https://github.com/BerriAI/litellm), NOASSERTION, last activity 2026-11-11, maintained.
Activity
dan-petty commentedon Nov 9, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(ai)scope of the title gives the scope.Cost tracking is incomplete for a growing call volume, but individual calls are cheap and no user is blocked.Financial visibility for Jev calls improves, but each call costs about 0.00002 USD.The fix is either reading usage.cost into the ledger or setting cost_per_request on the pass-through, both small changes.Both address the spend ledger not capturing cost for a class of gateway calls, but #3656 fixes misclassification of hosted calls as local, while the candidate adds a missing cost value for pass-through calls.devops-cli-service commentedon Nov 10, 2026
Status set to Ready at 4f377e1 (see proposed design in issue body).
devops-cli-service commentedon Nov 11, 2026
Alternatives check: partly
Reason: LiteLLM, the gateway the Jev calls already pass through, can record spend for a pass-through route through a flat
cost_per_request, and its current pass-through docs also describe a target reporting its own cost and usage, so it covers the gateway side of the need. It does not cover the rest: a flat cost gives no token count, and LiteLLM writes its own spend store, not the repository'sspend.dbthatdevops ai cost reportreads, so the Jev model row and the token count still need the client-side record.Tool: BerriAI/litellm (https://github.com/BerriAI/litellm)
Covers:
pass_through_endpointsroute can set a flatcost_per_request, so LiteLLM's gateway spend tracking and budgets count the pass-through callLacks:
cost_per_requestgives no token count, so the acceptance criterion of a non-zero Jev token count is not metspend.db, sodevops ai cost reportwould not listtypesafe/jev-1.14v1.103.0SystemOneModelexposes no response headers, sox-litellm-response-costis not readable thereTools considered:
Searches run:
Sources:
Checked on 2026-11-11. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 12, 2026
A blocker for any net gain of Jev (2026-11-12)
The decision-model study found that no decision point can show a net gain until this item is built. ADR 0020 section 8 measures the benefit of each point, and the cost is one half of that measure.
litellm_spend_metric_total{model="typesafe/jev-1.14"}is 0 on every series, and the token counters of the model are 0 (21 days)./v1/systemone, with 0 failures and p95 0.40 s. So the calls occur, but they have no cost record.devops ai ask-jevand the MCP toolai_ask_jevwrite no metric, no log line and no cost record.The study ranks this item as step 5 of 9: medium gain. Jev calls are fast and cheap, and the value is in the work that they let a job skip. Without the cost, that value cannot be shown.
dan-petty commentedon Nov 12, 2026
Scope note from the decision-model docs review of 2026-11-12. The owner approved it on 2026-11-12. One cause gives this item and #5209.
The documents say:
The shared cause:
SystemOneModelreports the providersystem-one, which genai-prices 0.2.3 does not know. So the price lookup fails (LookupError), and the window lookup of #5209 givesNone. With provideropenrouter, genai-prices gives 0.042 USD for 1M input tokens and a window of 32000.SystemOneModelalso dropsusage.costand the responseidthat OpenRouter returns in every response (pydantic_ai/models/system_one.py:242-246in 2.59.0). It keeps onlyinput_tokensandoutput_tokens.Change to this item:
DecisionResponse.usagefor each call, and price it withgenai_prices.calc_price(provider_id='openrouter')throughsrc/devops_cli/ai/spend/pricing.py. This gives the same 0.042 USD price with no hand-written override.src/devops_cli/config/constants.py:2874,3821). Only two eval modules read them.SystemOneModelkeepsusage.costand the response id.RunUsageand the spend hook ofbuild_agentsees it.fix(ai): catch the ledger errors, not every exception (#4296)
feat(ai): record the cost of each Jev decision call (#4296)
fix(ai): catch the ledger errors, not every exception (#4296)
devops-cli-service commentedon Nov 15, 2026
Released in v0.159.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.159.0
devops-cli-service commentedon Nov 15, 2026
Live since 2026-11-15 23:51 UTC