Repository navigation
fix(client-runtime): goal token counts no longer read 1000k - #21594
Open
MarMarLabs wants to merge 1 commit into
Open
MarMarLabs wants to merge 1 commit into
MarMarLabs wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This narrowly scoped fix corrects a token display boundary where values near one million were shown as You can add or adjust custom eligibility rules. Learn more. |
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The goal banner above the composer reads
1000kwhen a goal has used 999,500 to 999,999 tokens, for exampleGoal set · 1000k / 2m tokens. It should read1m, the same as at 1,000,000.formatGoalTokenspicks thekunit 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 reads1000ktoo. While a turn is running the title readsPursuing goaland the usage text is the same.Change
formatGoalTokensnow rounds to thousands first and picks the unit from the rounded value, so 999,500 and up fall through to thembranch and read1m. 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
1000kwhere1mis 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.presentProviderGoalis 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.tspasses, 45 of 45, on three runs.threadExecution.tsreverted tomainand the new test kept, the test fails. At 999,500 the helper returns1000k / 2m tokens.999kat 999,499, and1mat 999,500, 999,999 and 1,000,000, each with a 2,000,000 budget. It also fails if the helper truncates withMath.floor, moves the boundary to<= 999_500, or moves it down to< 999_000.1000kto1m.vp lint --report-unused-disable-directivesandvp fmt --checkare clean on both files, andvp run --filter @t3tools/client-runtime typecheckpasses.mainat 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 readsGoal setin both. Onmainthe banner readsGoal set · 1000k / 2m tokens. On this branch it readsGoal set · 1m / 2m tokens.I did not check a live goal turn or the packaged desktop app.