Repository navigation
test(openai): Stop directly calling _calculate_*_token_usage() - #7875
Merged
alexander-alderman-webb merged 8 commits intoOct 6, 2026
Merged
Conversation
alexander-alderman-webb
force-pushed
the
webb/openai/chat-completions-tokens
branch
from
October 6, 2026 08:18
1c01a08 to
414fcff
Compare
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
force-pushed
the
webb/openai/chat-completions-tokens
branch
12 times, most recently
from
October 6, 2026 09:29
727687d to
9740739
Compare
alexander-alderman-webb
force-pushed
the
webb/openai/chat-completions-tokens
branch
from
October 6, 2026 09:35
9740739 to
a810175
Compare
alexander-alderman-webb
marked this pull request as ready for review
October 6, 2026 09:45
sentrivana
approved these changes
Oct 6, 2026
_calculate_completions_token_usage()_calculate_*_token_usage()
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
alexander-alderman-webb
deleted the
webb/openai/chat-completions-tokens
branch
October 6, 2026 14:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Exercise
_calculate_completions_token_usage()and_calculate_responses_token_usage()by calling appropriateopenai-pythonfunctions 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 intest_nonstreaming_chat_completion_no_prompts().Remove
test_responses_token_usage_from_response(), whose token assertions are already intest_ai_client_span_responses_api_no_pii().Issues
Reminders
uv run ruff.feat:,fix:,ref:,meta:)