Fix: Enhanced OpenAI Usage Logging and Response Metadata Handling - #141
Merged
Conversation
Contributor
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x' artifact from the main CI run. |
mrjeeves
pushed a commit
to mrjeeves/qwen-code
that referenced
this pull request
Jul 31, 2025
…enLM#141) * feat: add support for cached tokens in OpenAI usage logging * fix: enhance response metadata handling in OpenAI content generator * fix: run format
xaelistic
pushed a commit
to xaelistic/qwen-code
that referenced
this pull request
Jun 7, 2026
…enLM#141) * feat: add support for cached tokens in OpenAI usage logging * fix: enhance response metadata handling in OpenAI content generator * fix: run format
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.
Summary
This PR improves the OpenAI content generator by adding support for cached tokens in usage logging and fixing response metadata handling issues.
🚀 Changes Made
✨ Feature: Cached Tokens Support
OpenAIUsageinterface to includeprompt_tokens_details.cached_tokenscachedContentTokenCount🐛 Fix: Response Metadata Handling
responseIdandcreateTimepropagation in responses🔍 Technical Details
Files Modified:
packages/core/src/core/openaiContentGenerator.tsKey Changes:
OpenAIUsageto support OpenAI's cached tokens featureresponseIdandcreateTimeare properly tracked and passed throughcachedContentTokenCountto usage metadata for better cost tracking🧪 Testing
📈 Benefits
🔄 Backward Compatibility
This PR addresses usage logging improvements and ensures proper metadata handling in the OpenAI content generator, making the system more robust and providing better visibility into API usage patterns.