Skip to content

Conversation

@umaannamalai
Copy link
Contributor

This PR updates OpenAI instrumentation and tests to pull token counts directly from the response object. If a customer has an LLM token counting callback function registered, this will still take priority over the response token count values.

It also removes token count calculations from error cases as the agent will consistently stop reporting token counts when a error was met during the creation of an embedding or chat completion.

@github-actions
Copy link

github-actions bot commented Sep 16, 2025

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 1.04s
✅ MARKDOWN markdownlint 7 0 0 0 1.48s
✅ PYTHON ruff 946 0 0 0 1.03s
✅ PYTHON ruff-format 946 1 0 0 0.42s
✅ YAML prettier 15 0 0 0 1.53s
✅ YAML v8r 15 0 0 6.23s
✅ YAML yamllint 15 0 0 0.66s

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security

@mergify mergify bot added the tests-failing Tests failing in CI. label Sep 16, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.61%. Comparing base (b1408de) to head (ddbcb36).

❗ There is a different number of reports uploaded between BASE (b1408de) and HEAD (ddbcb36). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (b1408de) HEAD (ddbcb36)
3 1
Additional details and impacted files
@@                     Coverage Diff                      @@
##           feature-llm-token-counts    #1498      +/-   ##
============================================================
- Coverage                     81.48%   73.61%   -7.87%     
============================================================
  Files                           209      209              
  Lines                         23815    23841      +26     
  Branches                       3753     3757       +4     
============================================================
- Hits                          19406    17551    -1855     
- Misses                         3153     5154    +2001     
+ Partials                       1256     1136     -120     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot removed the tests-failing Tests failing in CI. label Sep 16, 2025
@TimPansino TimPansino assigned lrafeei and TimPansino and unassigned lrafeei Sep 18, 2025
@mergify mergify bot added the tests-failing Tests failing in CI. label Sep 23, 2025
@mergify mergify bot added the merge-conflicts Merge conflicts detected. label Oct 7, 2025
@umaannamalai umaannamalai marked this pull request as ready for review October 7, 2025 19:57
@umaannamalai umaannamalai requested a review from a team as a code owner October 7, 2025 19:57
@mergify mergify bot removed the merge-conflicts Merge conflicts detected. label Oct 7, 2025
@umaannamalai umaannamalai merged commit 7d5adac into feature-llm-token-counts Oct 7, 2025
2 checks passed
@umaannamalai umaannamalai deleted the openai-token-counting branch October 7, 2025 20:14
@mergify mergify bot removed the tests-failing Tests failing in CI. label Oct 7, 2025
umaannamalai added a commit that referenced this pull request Nov 17, 2025
* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* Linting

* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: Tim Pansino <[email protected]>
umaannamalai added a commit that referenced this pull request Dec 11, 2025
* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* Linting

* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: Tim Pansino <[email protected]>
umaannamalai added a commit that referenced this pull request Dec 11, 2025
* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* Linting

* Add OpenAI token counts.

* Add token counts to langchain + openai tests.

* Remove unused expected events.

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: Tim Pansino <[email protected]>
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.

5 participants