Skip to content

fix(proxy/cost): dedupe pricing-lookup warning per unresolvable model#2505

Open
Parideboy wants to merge 1 commit into
headroomlabs-ai:mainfrom
Parideboy:fix/dedupe-pricing-warning
Open

fix(proxy/cost): dedupe pricing-lookup warning per unresolvable model#2505
Parideboy wants to merge 1 commit into
headroomlabs-ai:mainfrom
Parideboy:fix/dedupe-pricing-warning

Conversation

@Parideboy

Copy link
Copy Markdown
Contributor

Description

Custom/unknown models routed through the proxy (e.g. glm-5.2 via an OpenAI-compatible backend) fail litellm pricing resolution on every single request. This logs an identical WARNING - Failed to get pricing for model X: ... line per API call, flooding proxy.log in long-running sessions.

Type of Change

  • Bug fix

Changes Made

  • Added module-level _pricing_warned_models: set[str] in headroom/proxy/cost.py.
  • The pricing-lookup exception handler now warns once per unique model name per process lifetime instead of on every call.
  • Added regression test tests/test_pricing_warning_dedup.py asserting a single warning is emitted across 5 repeated estimate_cost calls for the same unresolvable model.

Testing

  • Added/updated tests
  • Ran full test suite locally
tests/test_pricing_warning_dedup.py::test_pricing_warning_logged_once_per_model PASSED [100%]
1 passed in 7.72s

Real Behavior Proof

  • Environment: Windows 11, Python 3.13.11, headroom repo at G:\Programmi Aggiuntivi\headroom, branch fix/dedupe-pricing-warning off upstream/main
  • Exact command / steps: python -m pytest tests/test_pricing_warning_dedup.py -v
  • Observed result: 1 passed — 5 calls to CostTracker.estimate_cost() for an unresolvable model produced exactly 1 WARNING log line instead of 5
  • Not tested: live proxy session against a real OpenAI-compatible backend with a custom model (covered instead by a targeted unit test on the pricing warning path)

Review Readiness

  • I have performed a self-review
  • This PR is ready for human review

Fixes #2504

Custom/unknown models routed through litellm fail pricing resolution on
every request, flooding proxy.log with an identical WARNING per call.
Track warned models in a module-level set and log once per model per
process lifetime.

Fixes headroomlabs-ai#2504

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR governance

This PR follows the template and is marked ready for human review.

@github-actions github-actions Bot added the status: ready for review Pull request body is complete and the author marked it ready for human review label Jul 23, 2026
@codecov-commenter

codecov-commenter commented Jul 23, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready for review Pull request body is complete and the author marked it ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduplicate pricing lookup warnings for custom/unknown models

2 participants