Skip to content

test(openai): Stop directly calling _calculate_*_token_usage() - #7875

Merged
alexander-alderman-webb merged 8 commits into
masterfrom
webb/openai/chat-completions-tokens
Oct 6, 2026
Merged

alexander-alderman-webb merged 8 commits into
masterfrom
webb/openai/chat-completions-tokens

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Exercise _calculate_completions_token_usage() and _calculate_responses_token_usage() by calling appropriate openai-python functions instead of reaching into SDK-internal functions.

Re-use model response fixtures, except for test_completions_token_usage_manual_output_counting_choices(), where a multi-choice output is provided inline.

Remove test_completions_token_usage_from_response(), whose token assertions are already in test_nonstreaming_chat_completion_no_prompts().

Remove test_responses_token_usage_from_response(), whose token assertions are already in test_ai_client_span_responses_api_no_pii().

Issues

Reminders

@alexander-alderman-webb
alexander-alderman-webb force-pushed the webb/openai/chat-completions-tokens branch from 1c01a08 to 414fcff Compare October 6, 2026 08:18
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ 133417 passed | ⏭️ 7276 skipped | Total: 140693 | Pass Rate: 94.83% | Execution Time: 438m 42s

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2557 uncovered lines.


Generated by Codecov Action

@alexander-alderman-webb
alexander-alderman-webb force-pushed the webb/openai/chat-completions-tokens branch 12 times, most recently from 727687d to 9740739 Compare October 6, 2026 09:29
@alexander-alderman-webb
alexander-alderman-webb force-pushed the webb/openai/chat-completions-tokens branch from 9740739 to a810175 Compare October 6, 2026 09:35
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review October 6, 2026 09:45
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner October 6, 2026 09:45
@alexander-alderman-webb alexander-alderman-webb changed the title test(openai): Stop directly calling _calculate_completions_token_usage() test(openai): Stop directly calling _calculate_*_token_usage() Oct 6, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 584e80d. Configure here.

Comment thread tests/integrations/litellm/test_litellm.py
@alexander-alderman-webb
alexander-alderman-webb merged commit b5737a0 into master Oct 6, 2026
166 checks passed
@alexander-alderman-webb
alexander-alderman-webb deleted the webb/openai/chat-completions-tokens branch October 6, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants