Repository navigation
[GUI] The engine reports its reasoning tokens, and the row shows them exactly - #4502
Closed
xvcezrqpbxtpzblrt wants to merge 2 commits into
Closed
xvcezrqpbxtpzblrt wants to merge 2 commits into
xvcezrqpbxtpzblrt wants to merge 2 commits into
Conversation
added 2 commits
October 28, 2026 22:05
Contributor
Author
|
Superseded by #4606, which carries this change with the rest of the 0.2.7 branch. Closing so the review has one place. |
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 thinking row had to estimate its token count (marked
≈) because the chat usage the engine returns carries only prompt/completion/total. The engine already counts the thinking tokens internally for the Responses API (reasoning_tokensin its done event) but the OpenAI-compatibleusageobject had nocompletion_tokens_details.reasoning_tokens.Result
"completion_tokens_details": {"reasoning_tokens": N}.≈when it is present; the estimate remains the fallback when a provider does not send it.Validation
"completion_tokens_details": {"reasoning_tokens": 16}next to prompt 54 / completion 16.stream_options.include_usage: the final usage carries"completion_tokens_details": {"reasoning_tokens": 19}.node --test tests/agent-events.test.mjs→ the count is summed over two usage frames (3 + 4 = 7) and the terminal frame has none when the provider sends none.npm run typecheckclean.Limits
≈: the pinned Harness (0.2.1-alpha.3) builds its usage frame indsh-llm-pi-ai'smapUsage, which copies input/output/total/cache only and drops the provider's reasoning count before the app sees it. Its ownTokenUsagetype has the field, but this version never fills it. The engine and app sides are ready; the exact number appears once the Harness forwards it.completion_tokens_details.