Skip to content

fix: report the latest step tokens instead of accumulating across steps - #151

Open
enternal111 wants to merge 2 commits into
DEVtheOPS:mainfrom
enternal111:fix/session-tokens-not-accumulative
Open

enternal111 wants to merge 2 commits into
DEVtheOPS:mainfrom
enternal111:fix/session-tokens-not-accumulative

Conversation

@enternal111

Copy link
Copy Markdown

Fixes #150

Which problem is this PR solving?

session.total_tokens reports the arithmetic sum of every LLM step's full-context token count instead of the conversation's current context size. A session with 10 calls averaging 12M tokens each reports ~120M instead of ~12M.

Short description of the changes

In accumulateTotals (src/handlers/step.ts), replace the running sum with the latest step's value. Each step's d.tokens represents the full conversation context for that call, not an incremental delta. handleUsageUpdated in session.ts already provides the authoritative cumulative replacement via session.usage.updated events.

How Has This Been Tested?

  • bun run typecheck
  • bun run lint
  • bun test

@enternal111

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T12:37:52.228090Z
We couldn’t complete this review. Comment @codex review to try again.
233d567 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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.

Reviewed commit: 7b7293ca26

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/handlers/step.ts Resolved
Comment thread src/handlers/step.ts Resolved
@enternal111

Copy link
Copy Markdown
Author

@codex review

@enternal111

Copy link
Copy Markdown
Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 233d567d8d

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@enternal111

Copy link
Copy Markdown
Author

@codex review

@enternal111

Copy link
Copy Markdown
Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

[Bug]: session.total_tokens accumulates full-context tokens across steps, producing inflated values

1 participant