-
Notifications
You must be signed in to change notification settings - Fork 32
🤖 fix: accumulate output tokens across steps in cost tracking #811
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
Conversation
b23d27d to
609fe22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
609fe22 to
b4940f6
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
b4940f6 to
b98c08d
Compare
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
In multi-step mode (tool use), the AI SDK emits per-step usage where: - inputTokens: Current context window (grows each step) - outputTokens: Tokens generated in that step only The aggregator was replacing usage on each step, losing earlier output tokens. Now we accumulate output/reasoning tokens while keeping the latest input tokens (which correctly represent the growing context). This fixes the issue where costs appeared to increment by only ~2¢ at a time instead of reflecting cumulative output costs. _Generated with mux_
b98c08d to
935f071
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
In multi-step mode (tool use), the AI SDK emits per-step usage where:
inputTokens: Current context window (grows each step)outputTokens: Tokens generated in that step onlyThe aggregator was replacing usage on each step, losing earlier output tokens. Now we accumulate output/reasoning tokens while keeping the latest input tokens (which correctly represent the growing context).
This fixes the issue where costs appeared to increment by only ~2¢ at a time instead of reflecting cumulative output costs.
Generated with
mux