Skip to content

Commit b79c7d3

Browse files
committed
Fix pricing
1 parent 6f5eaed commit b79c7d3

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/cooperbench/agents/pricing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ def compute_fallback_cost(
4747
pass # Model not in litellm's pricing DB
4848

4949
# Fall back to manual table (substring match handles prefixes like "anthropic/MiniMax-M2.5")
50+
# Note: prompt_tokens typically INCLUDES cache_read_tokens as a subset,
51+
# so we must subtract them to avoid double-counting.
5052
for pattern, (inp_price, out_price, cr_price, cw_price) in _PRICING.items():
5153
if pattern in model:
54+
non_cached_input = max(input_tokens - cache_read_tokens - cache_write_tokens, 0)
5255
cost = (
53-
input_tokens * inp_price
56+
non_cached_input * inp_price
5457
+ output_tokens * out_price
5558
+ cache_read_tokens * cr_price
5659
+ cache_write_tokens * cw_price

0 commit comments

Comments
 (0)