#1658

fix(report): avoid provider authentication during cost estimates

Opensamirhvbrwants to merge intofrom

Fixes #1656.

Cost estimation can start an interactive subscription-provider login. The locked LiteLLM cost calculator infers a provider when custom_llm_provider is omitted; for GitHub Copilot, that lookup can enter a synchronous device-authorization loop. A Linux reproduction on unchanged upstream 09536cf1 stalled in litellm_cost_callback during the fake provider tool-call matrix, with faulthandler pointing to Copilot's _poll_for_access_token. The upstream main CI also reaches its six-hour timeout, independently of #1654.

Both cost estimators already resolve a provider-qualified catalog name. Pass that name's provider explicitly to completion_cost so it need not rediscover/authenticate the route. This applies to response callbacks and the SDK usage ledger; it preserves catalog resolution, price consensus, usage payloads and provider-reported-cost precedence.

Six synthetic-catalog regressions cover both paths with GitHub Copilot, ChatGPT subscription and OpenAI model names. They run the real LiteLLM cost calculator, assert the resulting token price, and reject provider inference. All six fail against unchanged production code and pass with the fix. No authentication credentials or paid model requests are needed.

Validation on macOS, Python 3.12.14, frozen lockfile and isolated HOME/configuration:

  • Pricing, cost tracking, usage subscriptions, hooks and telemetry resume: 119 passed.
  • Repository Ruff lint/format, Mypy and Bandit: passed.
  • make check-all stops at existing Pyright errors: 941, with complete normalized diagnostic output identical to unchanged upstream.
  • git diff --check: passed.

Linux evidence and remaining CI work are recorded in #1656. A separate fork diagnostic matrix combines this patch, #1654, the fixture fix #1657 and existing #1577 to check the interaction; that is separate from this PR's own upstream CI. The missing-argument and telemetry fixtures are not bundled here. A full passing upstream CI has not yet been established.

Prepared with Codex assistance.

Combined Linux validation

The complete diagnostic matrix at c0651c343e3d7a58391214a2d6b133b14f363bbe combines #1654, #1657, #1658, #1660 and existing #1577 on current upstream 09536cf1. Python 3.12, 3.13 and 3.14 each pass with 2,534 passed / 3 expected xfails, using the frozen lockfile and normal catalog loading. No tests are skipped.

This validates the fixes together. Each independent PR's own upstream run still inherits the other unresolved base defects; the combined diagnostic does not turn those checks green.

Activity

2
greptile-apps[bot]3d ago

Confidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Both cost estimators now pass the resolved model’s provider to completion_cost, avoiding the need to infer it.

  • Cost estimates use known providers instead of starting a login.

Reviews (1) · Last reviewed commit: "fix(report): avoid provider authenticati..." · Reviewed by Greptile