Skip to content

Commit dbdb2da

Browse files
declan-scaleclaude
andcommitted
test(harness): num_llm_calls is None (not 0) for no-usage default cases
The shared TurnUsage.num_llm_calls became Optional (None = "not reported") when it landed on next. The openai / pydantic-ai turn tests still asserted == 0 for the default (no-usage / pre-exhaustion) construction path, which now yields None — matching the token fields. Update those three assertions to `is None`; real-zero cases (provider reported 0) are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4ceb1cf commit dbdb2da

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

tests/lib/adk/providers/test_openai_turn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def test_usage_mapping_none_usage():
6565
turn_usage = openai_usage_to_turn_usage(None, model="gpt-4o")
6666

6767
assert turn_usage.model == "gpt-4o"
68-
assert turn_usage.num_llm_calls == 0
68+
# num_llm_calls is None ("not reported") when no usage is present, matching
69+
# the token fields below; a real 0 is only reported when the provider says so.
70+
assert turn_usage.num_llm_calls is None
6971
assert turn_usage.input_tokens is None
7072
assert turn_usage.output_tokens is None
7173
assert turn_usage.total_tokens is None

tests/lib/adk/test_pydantic_ai_turn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async def test_usage_before_exhaustion_returns_default(self):
122122
assert pre_usage.model == "openai:gpt-4o"
123123
assert pre_usage.input_tokens is None
124124
assert pre_usage.output_tokens is None
125-
assert pre_usage.num_llm_calls == 0
125+
assert pre_usage.num_llm_calls is None
126126

127127
async def test_turn_events_and_usage(self):
128128
"""Driving events to exhaustion populates usage from the terminal event."""
@@ -227,7 +227,7 @@ async def test_no_usage_event_leaves_default_usage(self):
227227
usage = turn.usage()
228228
assert usage.model == "openai:gpt-4o"
229229
assert usage.input_tokens is None
230-
assert usage.num_llm_calls == 0
230+
assert usage.num_llm_calls is None
231231

232232

233233
class TestToolRequestStreaming:

0 commit comments

Comments
 (0)