Skip to content

fix(client-runtime): goal token counts no longer read 1000k - #21594

Open
MarMarLabs wants to merge 1 commit into
pingdotgg:mainfrom
MarMarLabs:fix/goal-tokens-1000k
Open

MarMarLabs wants to merge 1 commit into
pingdotgg:mainfrom
MarMarLabs:fix/goal-tokens-1000k

Conversation

@MarMarLabs

Copy link
Copy Markdown
Contributor

Problem

The goal banner above the composer reads 1000k when a goal has used 999,500 to 999,999 tokens, for example Goal set · 1000k / 2m tokens. It should read 1m, the same as at 1,000,000. formatGoalTokens picks the k unit from the raw count and rounds afterwards, so those counts round up to 1000 inside the wrong unit. The token budget goes through the same helper, so a budget in that range reads 1000k too. While a turn is running the title reads Pursuing goal and the usage text is the same.

Change

formatGoalTokens now rounds to thousands first and picks the unit from the rounded value, so 999,500 and up fall through to the m branch and read 1m. Every other count prints exactly as before.

Scope and approval

This is a very small, focused fix for an obvious bug. One display helper prints 1000k where 1m is meant, and the change is that helper plus a test. No issue exists for it. I searched open and closed issues and PRs for the helper and the banner text and found no other work on it.

#17539 fixed the same rollover in the context meter, and open #15599 fixes it in formatTokens. They change different helpers in different files, and neither touches this one. presentProviderGoal is shared client-runtime code. Mobile calls it but uses only the goal title and objective, so the visible change is the web goal banner.

Verification

  • vp test run packages/client-runtime/src/state/threadExecution.test.ts passes, 45 of 45, on three runs.
  • With threadExecution.ts reverted to main and the new test kept, the test fails. At 999,500 the helper returns 1000k / 2m tokens.
  • The new test expects 999k at 999,499, and 1m at 999,500, 999,999 and 1,000,000, each with a 2,000,000 budget. It also fails if the helper truncates with Math.floor, moves the boundary to <= 999_500, or moves it down to < 999_000.
  • I ran the old and new helper over every integer from 0 to 2,000,000 and about 2.5 million larger values. Only 999,500 to 999,999 differ, from 1000k to 1m.
  • vp lint --report-unused-disable-directives and vp fmt --check are clean on both files, and vp run --filter @t3tools/client-runtime typecheck passes.
  • I ran the web app from a fresh dev server on main at 1451e7c and on this branch. Each used a new temporary state directory with an active goal written straight into its database, 999,600 tokens used and a 2,000,000 budget. No provider ran, so no turn was running and the title reads Goal set in both. On main the banner reads Goal set · 1000k / 2m tokens. On this branch it reads Goal set · 1m / 2m tokens.

Goal banner on main, reading 1000k

Goal banner on this branch, reading 1m

I did not check a live goal turn or the packaged desktop app.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T08:46:01.303940Z 394dab8 PR opened
ℹ️ 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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Oct 19, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 394dab8

Macroscope's review found this PR approvable — This narrowly scoped fix corrects a token display boundary where values near one million were shown as 1000k instead of 1m. It changes only existing presentation formatting and adds targeted regression coverage, without affecting schemas, workflows, defaults, or production configuration.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fc89c7bf-c294-41f9-96e5-53580f529655
📥 Commits

Reviewing files that changed from the base of the PR and between 1451e7c and 394dab8.

📒 Files selected for processing: 2
  • packages/client-runtime/src/state/threadExecution.test.ts
  • packages/client-runtime/src/state/threadExecution.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

formatGoalTokens now selects the k or m unit based on rounded thousands. Tests cover token counts around the 1,000k rounding boundary.

Changes: Token usage formatting

Layer / File(s) Summary
Rounded token display
packages/client-runtime/src/state/threadExecution.ts, packages/client-runtime/src/state/threadExecution.test.ts
formatGoalTokens selects the unit using rounded thousands. Tests expect 999,499 tokens to display as 999k, and 999,500 through 1,000,000 tokens to display as 1m.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: t3dotgg

Merge Risk: ⚪ Minimal · up to 394da

Goal values that previously displayed as 1000k now display as 1m at the intended boundary; other million-formatted values retain their prior behavior. No actionable merge risk remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title is concise, uses the repository’s conventional commit format, and clearly identifies the client-runtime fix for incorrect goal token formatting.
Description check Passed The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the bug, implementation, approval rationale, focused tests, observed results, screensh…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the bug, implementation, approval rationale, focused tests, observed results, screenshots, and remaining verification limits.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@MarMarLabs MarMarLabs closed this Oct 19, 2026
@MarMarLabs MarMarLabs reopened this Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant