fix: resolve review budget feedback

This commit is contained in:
Claude
2026-09-01 12:14:18 +00:00
parent 4d51e14a1a
commit 592747d98d
3 changed files with 49 additions and 13 deletions
+11 -11
View File
@@ -163,15 +163,15 @@ def equivalent_cost(usage: dict, model: str, price_target: str = "") -> float:
"""Estimate comparison cost for one completed iteration."""
try:
from cost_model import PRICES, Usage, cost
target = price_target or os.environ.get("PRAGENT_PRICE_TARGET", "claude-sonnet-5")
price = PRICES.get(target)
if price is None:
return 0.0
return cost(Usage(
uncached_input=max(0, int(usage.get("input") or 0) - int(usage.get("cache_read") or 0)),
cached_input=int(usage.get("cache_read") or 0),
cache_writes=int(usage.get("cache_write") or 0),
output=int(usage.get("output") or 0),
), price)
except Exception:
except (ImportError, ModuleNotFoundError):
return 0.0
target = price_target or os.environ.get("PRAGENT_PRICE_TARGET", "claude-sonnet-5")
price = PRICES.get(target)
if price is None:
return 0.0
return cost(Usage(
uncached_input=max(0, int(usage.get("input") or 0) - int(usage.get("cache_read") or 0)),
cached_input=int(usage.get("cache_read") or 0),
cache_writes=int(usage.get("cache_write") or 0),
output=int(usage.get("output") or 0),
), price)