Skip to content

Conversation

@ethanndickson
Copy link
Member

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

@ethanndickson ethanndickson force-pushed the fix-cost-tracking-increment branch from b23d27d to 609fe22 Compare December 1, 2025 04:48
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

@ethanndickson ethanndickson force-pushed the fix-cost-tracking-increment branch from 609fe22 to b4940f6 Compare December 1, 2025 04:54
@ethanndickson
Copy link
Member Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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".

@ethanndickson ethanndickson force-pushed the fix-cost-tracking-increment branch from b4940f6 to b98c08d Compare December 1, 2025 05:30
@ethanndickson
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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_
@ethanndickson ethanndickson force-pushed the fix-cost-tracking-increment branch from b98c08d to 935f071 Compare December 1, 2025 05:46
@ethanndickson
Copy link
Member Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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".

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.

1 participant