Skip to content

fix(usage): handle OpenAI snake_case usage fields (#298) #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vrtnis
Copy link
Contributor

@vrtnis vrtnis commented Aug 6, 2025

Restores OpenAI token usage counts in RunContext.usage by teaching the Usage class to consume the existing snake_case fields from API responses. Previously, Usage only looked for camelCase props and silently dropped all prompt_tokens, completion_tokens, and total_tokens.

RunContext.usage will now accurately reflect both request counts and aggregated token usage across single or multi-step agent runs.

Resolves #298

Copy link

changeset-bot bot commented Aug 6, 2025

🦋 Changeset detected

Latest commit: 3982e84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@openai/agents-openai Patch
@openai/agents-core Patch
@openai/agents Patch
@openai/agents-realtime Patch
@openai/agents-extensions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vrtnis vrtnis marked this pull request as ready for review August 6, 2025 18:50
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.

Usage request not containing token amounts but contains number of requests
1 participant