Replies: 2 comments
|
Checked packages/client/ui-chat/src/client/chat/StatsPills.tsx on current upstream master and this holds exactly. Line 319 is const usage = useProjection('tokenUsage'), a single call for the current session's own projection. There is no descendant walk, no subagent-origin filter, nothing that touches another session's projection anywhere in the file. So the pill genuinely cannot show more than what the current session's own durable log folds, which matches your measured 17.8M vs 41.1M split precisely, since the gap is exactly the five teammate sessions' own totals. Your fix's direction (client-side sum over origin: 'subagent' descendants already served in the session-list summaries, with a cycle guard and an equality check on the derived value to avoid re-render churn from #5205's token-frequency publishing) fits how the data is already shaped rather than requiring a new host aggregate. The known limit you flagged, a cold summary with no retained projection value being invisible until it arrives, is a reasonable place to draw the line for a client-side fix; a host-side lineage aggregate is a bigger, separate decision as you say. Good catch that this is a distinct gap from #1886/#2426 (same projection undercounting compaction and retries within one session) rather than a duplicate. Both are real and worth fixing separately. |
|
结论:#6219 断言成立,master@c291e79 仍如此;方向=聚合,非排除说明. 行号均 src. a. tokenUsage 投影在 llm/token-meter(usage-projection.ts:117-150),只折本会话事件;Web 端唯一消费=ui-chat/StatsPills.tsx:319. 成立. b. 当前会话:apply 无跨会话输入,每会话独立投影存储(projection-store.ts:1-9);teammate 为独立会话,其用量只在 ui-subagent/SubagentHeaderLineage.tsx:307 按行显示,无后代聚合. 成立. c. master 仍存在(HEAD=c291e7961a);侧栏隐藏子代理(ui-workspace/tree.ts:145-149),目录默认折叠(:491). 成立. d. 聚合:客户端对会话列表 subagent 后代求和(环守卫+相等去抖),master 已有 indexSubagentDescendants(subagent-lineage.ts:24);"排除"仅指 README 已知限制(冷摘要无投影值时缺席);fork 分支 e652bf1 已核实(subagent-usage.ts +81). 成立. 【未核实】:17.8M/41.1M 实测. |
Uh oh!
There was an error while loading. Please reload this page.
[Bug] Web GUI 会话 token 计数不含 teammates/子代理 — 一次 Agent Teams 运行实测低估 2.3×
English below; 中文摘要见文末。
Environment
masteratc291e7961a(0.1.5-rc.2 tip), Linux,dsh web.session-7a919d6c-0296-44b6-9743-289d1eaf9776(workspace/home/ztmdsbt/workspaces, title 并行探测各项目代码行数), an Agent Teams run with one lead plus fiveorigin: 'subagent'teammates (4 probers + 1 verifier).conversation.composer.dock→StatsPills), "Token 用量" pill and dialog.Summary
The composer strip's token pill reads only the current Session's durable
tokenUsageprojection, which folds that Session's own log. Teammate Sessions are separate durable Sessions (their owntokenUsageprojections), and nothing adds them to the run's headline, so the counter reports the lead's usage while a team run costs substantially more.Measured, from the durable Session logs
Per-Session
tokenUsagebuckets (uncached input + cache read + cache write + output), i.e. exactly what the pill's headline sums:session-7a919d6c…7abe70c3…5ee26b91…e21275e6…d4cc4642…2a0a0060…The pill shows 17.8M tok; the run consumed 41.1M tok. The verifier teammate alone outspends the lead.
Root cause
packages/llm/token-meter/src/usage-projection.tsregisters thetokenUsageprojection: itsapplyfolds one Session log.TokenMeterkeeps one replay fold per Session (packages/llm/token-meter/src/index.ts,_sync(session)), and child Sessions are separate Sessions.packages/client/ui-chat/src/client/chat/StatsPills.tsxreadsuseProjection('tokenUsage')for the current Session only; no consumer aggregates descendants.packages/client/ui-subagent/src/client/SubagentHeaderLineage.tsxreads each child'sprojectionValues.tokenUsagefrom the Session list). The catalog is collapsed by default, and the ordinary sidebar hides subagent Sessions, so the composer pill is the only total a user sees for the run.Reproduction
subagenttool).projectionValues.tokenUsageover theorigin: 'subagent'descendants; the header's subagent catalog renders that value per child row.Proposed fix
Branch:
stofancy/deepseek-harness@fix/composer-strip-subagent-usage(commite652bf148e), basemaster. Client-side aggregation over data the host already serves:sumSubagentTokenUsageover the Session-list summaries'projectionValues.tokenUsage: transitiveorigin: 'subagent'walk with a cycle guard; an ordinary fork contributes nothing.StatsPillsadds the descendant sum to the current Session's value, so the headline, cache-hit share, and bucket rows all describe the delegation tree; with at least one reporting descendant the dialog namesThis session/Subagentsbefore the combined buckets.useSessionsselector passes a bucket equality: the Session-list store also publishes frames that leave the sum untouched (child timing publishes at token frequency, see Subagent timing 按 token 频率发布导致 Session 列表全量重建和 Web renderer 饥饿 #5205), and an equal re-derived value must not re-render the strip.tsc -b tsconfig.client.json,run-oxlint.ts packages/client/ui-chat,verify-client-ui-i18n, translation pairing / md-links, and doc budgets pass;vitest run packages/client packages/hostshows only the pre-existingui-trajectory/tests/client-bundle.client.spec.tsfailures of an unbuilt checkout.Why there is no pull request
deepseek-ai/deepseek-harnesshas Issues and Pull Requests disabled for this account:GET /repos/.../pullsreturns 404,has_issuesisfalse,gh pr createfails withstofancy does not have the correct permissions to execute CreatePullRequest, and CONTRIBUTING.md states the project cannot accept external pull requests at the moment. Per that guide this post is the report, and the patch is published on the fork branch so maintainers can pull it: https://github.com/stofancy/deepseek-harness/tree/fix/composer-strip-subagent-usage.Related
subagentspawn does not return usage to the orchestrator (adjacent: that is the tool-result channel; this is the Web counter).tokenUsageprojection undercounts (compaction, retries); same projection, different gap.中文摘要:输入框统计条的 token 胶囊只统计当前会话自身的持久日志,teammate(
origin: 'subagent'子会话)各自的tokenUsage投影不会被计入。本次 Agent Teams 运行里,主会话 17,835,441 tok,五个 teammate 合计 23,271,879 tok,团队真实总量 41,107,320 tok,界面因此低估 2.3 倍;子代理用量只在默认折叠的会话头部目录里逐行可见。根因是tokenUsage投影按单个会话折叠,且StatsPills只读当前会话的投影。修复分支见上(客户端按会话列表汇总后代会话用量,并在弹窗中区分"本会话/子代理")。All reactions