From 4d6bd506238096791ebab4880a960354540c2afe Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 24 Nov 2026 10:43:57 -0800 Subject: [PATCH 1/4] feat(pricing): a model named with a trailing tag such as [1m] is priced as its base model The live GitHub test site's ready check loads github.com rather than its API, whose 60 unauthenticated calls an hour CI's shared addresses spend. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 3 ++- src/agent_env/config/model_pricing.py | 22 +++++++++++++++++----- tst/data/live_github_website/server.py | 9 ++++++--- tst/unit/config/test_model_pricing.py | 13 +++++++++++++ tst/unit/task_step/usage_models_test.py | 10 ++++++++++ 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1175a0da6..52cd1afa3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,7 +86,8 @@ or one of them only where it is used. unit-test verifier. On `sail_vm` with `inject_model_key`, Sail sets them at egress like the key. - Usage is priced from the price map the installed LiteLLM bundles (`config/model_pricing.py`), read without importing LiteLLM, which would fetch a newer map from the network; there is no price config. A model is found by its - name as called or without its routing prefix, wherever its calls went. A prompt step prices each role's usage entry as + name as called or without its routing prefix, and either again without a trailing bracketed tag such as Claude Code's + `[1m]`, wherever its calls went. A prompt step prices each role's usage entry as it records it: `cost_usd` with its `cost_status` (`priced`, `reported`, `unpriced`) and `cost_source` (`litellm@`, `harness` or `provider`), the `uncached_input_tokens` and `unit_prices` it was charged at, any `cost_assumed` that makes it an upper bound, and the agent's own figure, always, in `reported_cost_usd`. A turn diff --git a/src/agent_env/config/model_pricing.py b/src/agent_env/config/model_pricing.py index 5c66e5d09..0d55151c0 100644 --- a/src/agent_env/config/model_pricing.py +++ b/src/agent_env/config/model_pricing.py @@ -9,6 +9,7 @@ import json import logging import math +import re from dataclasses import dataclass, field from enum import StrEnum from pathlib import Path @@ -22,6 +23,8 @@ _MAP_FILE = "litellm/model_prices_and_context_window_backup.json" _MAP_KEYS = {"input": "input_cost_per_token", "output": "output_cost_per_token", "cache_read": "cache_read_input_token_cost", "cache_write": "cache_creation_input_token_cost"} +# A tag a harness adds to a model's name, such as Claude Code's context-window pick ``[1m]``. +_TRAILING_TAG = re.compile(r"\[[^\[\]]*\]$") class CostStatus(StrEnum): @@ -88,11 +91,20 @@ def from_cost_map(cls, cost_map: Mapping[str, Any], source: str) -> PriceTable: def lookup(self, model: str) -> Optional[ModelPrice]: """``model``'s prices: the entry named as called, else the one named without its first ``/`` segment, so - ``openai/gpt-4o-mini`` finds ``gpt-4o-mini``; None, never a zero price, when there's neither.""" - if model in self.entries: - return self.entries[model] - _, slash, name = model.partition("/") - return self.entries.get(name) if slash else None + ``openai/gpt-4o-mini`` finds ``gpt-4o-mini``, and each of those again without a trailing bracketed tag, so a + context-window pick such as ``claude-opus-5-5[1m]`` finds ``claude-opus-5-5``; None, never a zero price, when + there's none. No name in the map carries a bracket, so the tag never hides an entry.""" + untagged = _TRAILING_TAG.sub("", model) + for name in (model, _unrouted(model), untagged, _unrouted(untagged)): + if name in self.entries: + return self.entries[name] + return None + + +def _unrouted(model: str) -> str: + """``model`` without its first ``/`` segment, the route a gateway reads; itself when it has none.""" + _, slash, name = model.partition("/") + return name if slash else model @functools.cache diff --git a/tst/data/live_github_website/server.py b/tst/data/live_github_website/server.py index b9923dd49..d1c94dcc8 100644 --- a/tst/data/live_github_website/server.py +++ b/tst/data/live_github_website/server.py @@ -1,5 +1,7 @@ """A live site for integration tests: github.com, whose pages its server serves none of. Its data plane reads a public -repository through api.github.com and keeps what a task loads; its session is a test cookie, which GitHub ignores.""" +repository through api.github.com and keeps what a task loads; its session is a test cookie, which GitHub ignores. It's +ready when github.com answers: the API allows an unauthenticated caller 60 calls an hour, which CI's shared addresses +spend, so only a read of its state calls it.""" import json import urllib.request from typing import Optional @@ -31,8 +33,9 @@ def repository(self) -> dict: return self._repository @ready_check - def api_answers(self) -> bool: - return self.repository()["full_name"] == self.settings.repository + def site_answers(self) -> bool: + with urllib.request.urlopen(urllib.request.Request("https://github.com/", method="HEAD"), timeout=10) as response: + return response.status == 200 @session_state def account(self, user: Optional[str]) -> dict: diff --git a/tst/unit/config/test_model_pricing.py b/tst/unit/config/test_model_pricing.py index 16905e22c..86ca8fcf0 100644 --- a/tst/unit/config/test_model_pricing.py +++ b/tst/unit/config/test_model_pricing.py @@ -90,6 +90,19 @@ def test_a_routing_prefix_is_stripped_to_find_a_model(): assert TABLE.lookup("meta-llama/Llama-3-70b") is TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b") is not None +def test_a_trailing_bracketed_tag_such_as_a_context_window_pick_is_stripped_to_find_a_model(): + assert TABLE.lookup("gpt-4o-mini[1m]") is TABLE.lookup("openai/gpt-4o-mini[1m]") is TABLE.lookup("gpt-4o-mini") + assert TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b[1m]") is TABLE.lookup("meta-llama/Llama-3-70b") + assert _agent(USAGE, "gpt-4o-mini[1m]").usd == _agent(USAGE).usd is not None + assert _judge(USAGE, "openai/gpt-4o-mini[1m]").usd == _judge(USAGE).usd + + +def test_a_tagged_name_is_unpriced_for_what_its_base_model_lacks(): + assert TABLE.lookup("someprovider/model-x[1m]") is None + assert _agent(USAGE, "someprovider/model-x[1m]").unpriced is Unpriced.NO_PRICE + assert _agent({**USAGE, "input_tokens": None}, "gpt-4o-mini[1m]").unpriced is Unpriced.NO_TOKENS + + @pytest.mark.parametrize("model", ["gpt-4o", "openai/gpt-4o", "Llama-3-70b", "dall-e-3", "broken", "half", ""]) def test_a_model_the_map_cant_price_has_no_price_never_a_zero_one(model): assert TABLE.lookup(model) is None diff --git a/tst/unit/task_step/usage_models_test.py b/tst/unit/task_step/usage_models_test.py index a8ae41d83..2b714acbb 100644 --- a/tst/unit/task_step/usage_models_test.py +++ b/tst/unit/task_step/usage_models_test.py @@ -47,6 +47,16 @@ def test_a_turns_models_are_each_priced_at_their_own_rate(monkeypatch): assert (entry["model"], entry["input_tokens"], entry["output_tokens"]) == (SONNET, 12000, 490) +def test_a_row_named_with_a_context_window_tag_is_priced_at_its_base_model_and_keeps_its_name(monkeypatch): + tagged = Usage(input_tokens=3000, output_tokens=90, input_includes_cache=True, + models=(ModelUsage(model=f"{HAIKU}[1m]", calls=1, input_tokens=3000, output_tokens=90, + input_includes_cache=True),)) + + [row] = _entry(monkeypatch, tagged)["models"] + + assert (row["model"], row["cost_status"], row["cost_usd"]) == (f"{HAIKU}[1m]", "priced", pytest.approx(0.00345)) + + def test_a_turn_without_models_beside_one_with_them_counts_as_the_roles_model(monkeypatch): plain = Usage(input_tokens=1000, output_tokens=10, input_includes_cache=True) From 63c3d3f293e8c6c8f959720831a804498be2abff Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 24 Nov 2026 12:53:50 -0800 Subject: [PATCH 2/4] feat(pricing): drop a model name's leading route segments one at a time to find its price The lookup dropped only the first "/" segment, so a route of several segments stayed unpriced though its model is in the map: the Gemini agent's documented vertex_ai/global/, LiteLLM's openrouter// and bedrock/converse/. The nearest route with an entry wins. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 4 ++-- src/agent_env/config/model_pricing.py | 18 ++++++++---------- tst/unit/config/test_model_pricing.py | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 52cd1afa3..87081ac81 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,8 +86,8 @@ or one of them only where it is used. unit-test verifier. On `sail_vm` with `inject_model_key`, Sail sets them at egress like the key. - Usage is priced from the price map the installed LiteLLM bundles (`config/model_pricing.py`), read without importing LiteLLM, which would fetch a newer map from the network; there is no price config. A model is found by its - name as called or without its routing prefix, and either again without a trailing bracketed tag such as Claude Code's - `[1m]`, wherever its calls went. A prompt step prices each role's usage entry as + name as called or without its leading route segments, dropped one at a time (`vertex_ai/global/`), and each + again without a trailing bracketed tag such as Claude Code's `[1m]`, wherever its calls went. A prompt step prices each role's usage entry as it records it: `cost_usd` with its `cost_status` (`priced`, `reported`, `unpriced`) and `cost_source` (`litellm@`, `harness` or `provider`), the `uncached_input_tokens` and `unit_prices` it was charged at, any `cost_assumed` that makes it an upper bound, and the agent's own figure, always, in `reported_cost_usd`. A turn diff --git a/src/agent_env/config/model_pricing.py b/src/agent_env/config/model_pricing.py index 0d55151c0..a48fcae1e 100644 --- a/src/agent_env/config/model_pricing.py +++ b/src/agent_env/config/model_pricing.py @@ -90,21 +90,19 @@ def from_cost_map(cls, cost_map: Mapping[str, Any], source: str) -> PriceTable: return cls(entries, source) def lookup(self, model: str) -> Optional[ModelPrice]: - """``model``'s prices: the entry named as called, else the one named without its first ``/`` segment, so - ``openai/gpt-4o-mini`` finds ``gpt-4o-mini``, and each of those again without a trailing bracketed tag, so a - context-window pick such as ``claude-opus-5-5[1m]`` finds ``claude-opus-5-5``; None, never a zero price, when - there's none. No name in the map carries a bracket, so the tag never hides an entry.""" - untagged = _TRAILING_TAG.sub("", model) - for name in (model, _unrouted(model), untagged, _unrouted(untagged)): + """``model``'s prices: the entry named as called, else without its leading ``/`` segments, dropped one at a time + (``vertex_ai/global/``), then each again without a trailing bracketed tag (``claude-opus-5-5[1m]``); None, + never a zero price, when there's none. No name in the map carries a bracket, so a tag never hides an entry.""" + for name in (*_unrouted(model), *_unrouted(_TRAILING_TAG.sub("", model))): if name in self.entries: return self.entries[name] return None -def _unrouted(model: str) -> str: - """``model`` without its first ``/`` segment, the route a gateway reads; itself when it has none.""" - _, slash, name = model.partition("/") - return name if slash else model +def _unrouted(model: str) -> list[str]: + """``model``, then it without each of its leading ``/`` segments in turn, the routes gateways read.""" + parts = model.split("/") + return ["/".join(parts[i:]) for i in range(len(parts))] @functools.cache diff --git a/tst/unit/config/test_model_pricing.py b/tst/unit/config/test_model_pricing.py index 86ca8fcf0..aad6beaff 100644 --- a/tst/unit/config/test_model_pricing.py +++ b/tst/unit/config/test_model_pricing.py @@ -90,6 +90,20 @@ def test_a_routing_prefix_is_stripped_to_find_a_model(): assert TABLE.lookup("meta-llama/Llama-3-70b") is TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b") is not None +def test_each_leading_route_segment_is_dropped_in_turn_to_find_a_model(): + assert TABLE.lookup("vertex_ai/global/gpt-4o-mini") is TABLE.lookup("openrouter/openai/gpt-4o-mini") is not None + assert TABLE.lookup("openrouter/openai/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") + assert TABLE.lookup("bedrock/converse/meta-llama/Llama-3-70b") is TABLE.lookup("meta-llama/Llama-3-70b") + assert _judge(USAGE, "vertex_ai/global/gpt-4o-mini").usd == _judge(USAGE).usd is not None + + +def test_the_nearest_route_with_an_entry_wins(): + table = PriceTable.from_cost_map({"org/model": COST_MAP["gpt-4o-mini"], "model": COST_MAP["my-finetune"]}, "t") + + assert table.lookup("gateway/org/model") is table.entries["org/model"] + assert table.lookup("gateway/other/model") is table.entries["model"] + + def test_a_trailing_bracketed_tag_such_as_a_context_window_pick_is_stripped_to_find_a_model(): assert TABLE.lookup("gpt-4o-mini[1m]") is TABLE.lookup("openai/gpt-4o-mini[1m]") is TABLE.lookup("gpt-4o-mini") assert TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b[1m]") is TABLE.lookup("meta-llama/Llama-3-70b") From 1261a3fa91b8db91bf836143ddc2a2fb79709692 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 24 Nov 2026 13:01:58 -0800 Subject: [PATCH 3/4] refactor(pricing): name the route helper for the list it returns, and keep one test for the route rule Co-Authored-By: Claude Opus 5.5 --- src/agent_env/config/model_pricing.py | 4 ++-- tst/unit/config/test_model_pricing.py | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/agent_env/config/model_pricing.py b/src/agent_env/config/model_pricing.py index a48fcae1e..3eaad1978 100644 --- a/src/agent_env/config/model_pricing.py +++ b/src/agent_env/config/model_pricing.py @@ -93,13 +93,13 @@ def lookup(self, model: str) -> Optional[ModelPrice]: """``model``'s prices: the entry named as called, else without its leading ``/`` segments, dropped one at a time (``vertex_ai/global/``), then each again without a trailing bracketed tag (``claude-opus-5-5[1m]``); None, never a zero price, when there's none. No name in the map carries a bracket, so a tag never hides an entry.""" - for name in (*_unrouted(model), *_unrouted(_TRAILING_TAG.sub("", model))): + for name in (*_route_drops(model), *_route_drops(_TRAILING_TAG.sub("", model))): if name in self.entries: return self.entries[name] return None -def _unrouted(model: str) -> list[str]: +def _route_drops(model: str) -> list[str]: """``model``, then it without each of its leading ``/`` segments in turn, the routes gateways read.""" parts = model.split("/") return ["/".join(parts[i:]) for i in range(len(parts))] diff --git a/tst/unit/config/test_model_pricing.py b/tst/unit/config/test_model_pricing.py index aad6beaff..5f0e16217 100644 --- a/tst/unit/config/test_model_pricing.py +++ b/tst/unit/config/test_model_pricing.py @@ -85,14 +85,11 @@ def missing(name): assert "Usage stays unpriced, since LiteLLM's price map can't be read" in caplog.text -def test_a_routing_prefix_is_stripped_to_find_a_model(): - assert TABLE.lookup("openai/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") is not None - assert TABLE.lookup("meta-llama/Llama-3-70b") is TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b") is not None - - def test_each_leading_route_segment_is_dropped_in_turn_to_find_a_model(): - assert TABLE.lookup("vertex_ai/global/gpt-4o-mini") is TABLE.lookup("openrouter/openai/gpt-4o-mini") is not None + assert TABLE.lookup("openai/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") is not None + assert TABLE.lookup("vertex_ai/global/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") assert TABLE.lookup("openrouter/openai/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") + assert TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b") is TABLE.lookup("meta-llama/Llama-3-70b") is not None assert TABLE.lookup("bedrock/converse/meta-llama/Llama-3-70b") is TABLE.lookup("meta-llama/Llama-3-70b") assert _judge(USAGE, "vertex_ai/global/gpt-4o-mini").usd == _judge(USAGE).usd is not None From 997323beb2b14bb1af00d61d74fbb29acaf03e5d Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 24 Nov 2026 13:16:46 -0800 Subject: [PATCH 4/4] chore(pricing): take the price lookup changes out of this pull request Main already prices a [1m] entry from its per-model rows, or from Claude Code's own figure when the rows are tagged, so the tag rule helped only a turn with no rows and no cost, and the route rule guessed which segments name the model. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 3 +-- src/agent_env/config/model_pricing.py | 22 ++++++------------- tst/unit/config/test_model_pricing.py | 28 ++----------------------- tst/unit/task_step/usage_models_test.py | 10 --------- 4 files changed, 9 insertions(+), 54 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 87081ac81..1175a0da6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,8 +86,7 @@ or one of them only where it is used. unit-test verifier. On `sail_vm` with `inject_model_key`, Sail sets them at egress like the key. - Usage is priced from the price map the installed LiteLLM bundles (`config/model_pricing.py`), read without importing LiteLLM, which would fetch a newer map from the network; there is no price config. A model is found by its - name as called or without its leading route segments, dropped one at a time (`vertex_ai/global/`), and each - again without a trailing bracketed tag such as Claude Code's `[1m]`, wherever its calls went. A prompt step prices each role's usage entry as + name as called or without its routing prefix, wherever its calls went. A prompt step prices each role's usage entry as it records it: `cost_usd` with its `cost_status` (`priced`, `reported`, `unpriced`) and `cost_source` (`litellm@`, `harness` or `provider`), the `uncached_input_tokens` and `unit_prices` it was charged at, any `cost_assumed` that makes it an upper bound, and the agent's own figure, always, in `reported_cost_usd`. A turn diff --git a/src/agent_env/config/model_pricing.py b/src/agent_env/config/model_pricing.py index 3eaad1978..5c66e5d09 100644 --- a/src/agent_env/config/model_pricing.py +++ b/src/agent_env/config/model_pricing.py @@ -9,7 +9,6 @@ import json import logging import math -import re from dataclasses import dataclass, field from enum import StrEnum from pathlib import Path @@ -23,8 +22,6 @@ _MAP_FILE = "litellm/model_prices_and_context_window_backup.json" _MAP_KEYS = {"input": "input_cost_per_token", "output": "output_cost_per_token", "cache_read": "cache_read_input_token_cost", "cache_write": "cache_creation_input_token_cost"} -# A tag a harness adds to a model's name, such as Claude Code's context-window pick ``[1m]``. -_TRAILING_TAG = re.compile(r"\[[^\[\]]*\]$") class CostStatus(StrEnum): @@ -90,19 +87,12 @@ def from_cost_map(cls, cost_map: Mapping[str, Any], source: str) -> PriceTable: return cls(entries, source) def lookup(self, model: str) -> Optional[ModelPrice]: - """``model``'s prices: the entry named as called, else without its leading ``/`` segments, dropped one at a time - (``vertex_ai/global/``), then each again without a trailing bracketed tag (``claude-opus-5-5[1m]``); None, - never a zero price, when there's none. No name in the map carries a bracket, so a tag never hides an entry.""" - for name in (*_route_drops(model), *_route_drops(_TRAILING_TAG.sub("", model))): - if name in self.entries: - return self.entries[name] - return None - - -def _route_drops(model: str) -> list[str]: - """``model``, then it without each of its leading ``/`` segments in turn, the routes gateways read.""" - parts = model.split("/") - return ["/".join(parts[i:]) for i in range(len(parts))] + """``model``'s prices: the entry named as called, else the one named without its first ``/`` segment, so + ``openai/gpt-4o-mini`` finds ``gpt-4o-mini``; None, never a zero price, when there's neither.""" + if model in self.entries: + return self.entries[model] + _, slash, name = model.partition("/") + return self.entries.get(name) if slash else None @functools.cache diff --git a/tst/unit/config/test_model_pricing.py b/tst/unit/config/test_model_pricing.py index 5f0e16217..16905e22c 100644 --- a/tst/unit/config/test_model_pricing.py +++ b/tst/unit/config/test_model_pricing.py @@ -85,33 +85,9 @@ def missing(name): assert "Usage stays unpriced, since LiteLLM's price map can't be read" in caplog.text -def test_each_leading_route_segment_is_dropped_in_turn_to_find_a_model(): +def test_a_routing_prefix_is_stripped_to_find_a_model(): assert TABLE.lookup("openai/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") is not None - assert TABLE.lookup("vertex_ai/global/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") - assert TABLE.lookup("openrouter/openai/gpt-4o-mini") is TABLE.lookup("gpt-4o-mini") - assert TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b") is TABLE.lookup("meta-llama/Llama-3-70b") is not None - assert TABLE.lookup("bedrock/converse/meta-llama/Llama-3-70b") is TABLE.lookup("meta-llama/Llama-3-70b") - assert _judge(USAGE, "vertex_ai/global/gpt-4o-mini").usd == _judge(USAGE).usd is not None - - -def test_the_nearest_route_with_an_entry_wins(): - table = PriceTable.from_cost_map({"org/model": COST_MAP["gpt-4o-mini"], "model": COST_MAP["my-finetune"]}, "t") - - assert table.lookup("gateway/org/model") is table.entries["org/model"] - assert table.lookup("gateway/other/model") is table.entries["model"] - - -def test_a_trailing_bracketed_tag_such_as_a_context_window_pick_is_stripped_to_find_a_model(): - assert TABLE.lookup("gpt-4o-mini[1m]") is TABLE.lookup("openai/gpt-4o-mini[1m]") is TABLE.lookup("gpt-4o-mini") - assert TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b[1m]") is TABLE.lookup("meta-llama/Llama-3-70b") - assert _agent(USAGE, "gpt-4o-mini[1m]").usd == _agent(USAGE).usd is not None - assert _judge(USAGE, "openai/gpt-4o-mini[1m]").usd == _judge(USAGE).usd - - -def test_a_tagged_name_is_unpriced_for_what_its_base_model_lacks(): - assert TABLE.lookup("someprovider/model-x[1m]") is None - assert _agent(USAGE, "someprovider/model-x[1m]").unpriced is Unpriced.NO_PRICE - assert _agent({**USAGE, "input_tokens": None}, "gpt-4o-mini[1m]").unpriced is Unpriced.NO_TOKENS + assert TABLE.lookup("meta-llama/Llama-3-70b") is TABLE.lookup("hosted_vllm/meta-llama/Llama-3-70b") is not None @pytest.mark.parametrize("model", ["gpt-4o", "openai/gpt-4o", "Llama-3-70b", "dall-e-3", "broken", "half", ""]) diff --git a/tst/unit/task_step/usage_models_test.py b/tst/unit/task_step/usage_models_test.py index 2b714acbb..a8ae41d83 100644 --- a/tst/unit/task_step/usage_models_test.py +++ b/tst/unit/task_step/usage_models_test.py @@ -47,16 +47,6 @@ def test_a_turns_models_are_each_priced_at_their_own_rate(monkeypatch): assert (entry["model"], entry["input_tokens"], entry["output_tokens"]) == (SONNET, 12000, 490) -def test_a_row_named_with_a_context_window_tag_is_priced_at_its_base_model_and_keeps_its_name(monkeypatch): - tagged = Usage(input_tokens=3000, output_tokens=90, input_includes_cache=True, - models=(ModelUsage(model=f"{HAIKU}[1m]", calls=1, input_tokens=3000, output_tokens=90, - input_includes_cache=True),)) - - [row] = _entry(monkeypatch, tagged)["models"] - - assert (row["model"], row["cost_status"], row["cost_usd"]) == (f"{HAIKU}[1m]", "priced", pytest.approx(0.00345)) - - def test_a_turn_without_models_beside_one_with_them_counts_as_the_roles_model(monkeypatch): plain = Usage(input_tokens=1000, output_tokens=10, input_includes_cache=True)