Repository navigation
Description
Problem Description
Calls to hosted models like deepseek-v4.1-flash-1017 through PydanticAI (factory.py) are classified as local savings with backend="llm-gateway" and $0 spend. This causes Grafana projected local savings to become excessively high.
In factory.py, _record() passes served_by = getattr(m, "served_by", None) to track_request_spend. Because pydantic_ai_bridge.py sets model_obj.served_by = base_url (the gateway endpoint http://llm-gateway.llm.svc.cluster.local:4000/v1), factory.py passes the gateway proxy URL as the backend. In is_local(), _is_local_api_base(served_by) evaluates llm-gateway.llm.svc.cluster.local as a *.local address and returns True, bypassing model-based checks.
Reproduction Steps
- Run
python -c 'from devops_cli.ai.spend.pricing import is_local; print(is_local(server="llm-gateway.llm.svc.cluster.local:4000", provider="gateway", served_by="http://llm-gateway.llm.svc.cluster.local:4000/v1", model="deepseek-v4.1-flash-1017"))' - Output prints
Trueinstead ofFalse. - Calls in
roadmap-serviceemitdevops_cli_ai_tokens_totalwithlocal="true"andbackend="llm-gateway".
Expected vs Actual Behavior
Expected: The gateway proxy endpoint is not treated as a local serving backend. Hosted models called through the gateway via PydanticAI are classified as spend, not local savings.
Actual: The gateway endpoint matches *.local and is treated as a local serving backend, causing hosted model calls to be marked local="true" with backend="llm-gateway".
Environment Diagnostics
- DevOps CLI Version: 0.157.0
- Python Version: 3.14.10
- OS & Architecture: Linux x86_64
- Execution Environment: DevContainer
Logs, Traces, or Terminal Output
python -c 'from devops_cli.ai.spend.pricing import is_local; print(is_local(server="llm-gateway.llm.svc.cluster.local:4000", provider="gateway", served_by="http://llm-gateway.llm.svc.cluster.local:4000/v1", model="deepseek-v4.1-flash-1017"))'
True
Activity
dan-petty commentedon Nov 15, 2026
Both fix is_local misclassifying hosted gateway calls as local, but #3656 handled a missing served_by while the candidate handles an incorrect served_by set by pydantic_ai_bridge.fix(ai): do not classify gateway endpoint as local serving backend (#…
fix(ai): do not classify gateway endpoint as local serving backend (#…
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 16, 2026
Live since 2026-11-15 23:51 UTC