mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4502] [CLOSED] [GUI] The engine reports its reasoning tokens, and the row shows them exactly #5070
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5070
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4502
Author: @xvcezrqpbxtpzblrt
Created: 10/28/2026
Status: ❌ Closed
Base:
main← Head:gui/reasoning-exact-027📝 Commits (2)
fec4741[GUI] The thinking row shows live time and tokens, and counts only the thinkingc19c886[GUI] Report the engine's reasoning tokens and show them exactly when they arrive📊 Changes
17 files changed (+140 additions, -26 deletions)
View changed files
📝
apps/host/server/agent/events.mjs(+5 -1)📝
apps/host/src/components/ReasoningBlock.tsx(+32 -9)📝
apps/host/src/lib/reasoning.ts(+33 -0)📝
apps/host/src/lib/store.ts(+10 -6)📝
apps/host/src/lib/types.ts(+2 -0)📝
apps/host/src/locales/de.json(+2 -1)📝
apps/host/src/locales/en.json(+2 -1)📝
apps/host/src/locales/es.json(+2 -1)📝
apps/host/src/locales/fr.json(+2 -1)📝
apps/host/src/locales/ja.json(+2 -1)📝
apps/host/src/locales/ko.json(+2 -1)📝
apps/host/src/locales/pt.json(+2 -1)📝
apps/host/src/locales/ru.json(+2 -1)📝
apps/host/src/locales/zh.json(+2 -1)📝
apps/host/tests/agent-events.test.mjs(+19 -0)📝
apps/host/tests/live-chat.test.mjs(+17 -0)📝
serve/server.py(+4 -1)📄 Description
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.