feat: refine token usage display modes (#2329)

* feat: refine token usage display modes

* docs: clarify token usage accounting semantics

* fix: avoid duplicate subtask debug keys

* style: format token usage tests

* chore: address token attribution review feedback

* Update test_token_usage_middleware.py

* Update test_token_usage_middleware.py

* chore: simplify token attribution fallback

* fix token usage metadata follow-up handling

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
YuJitang
2026-05-04 09:56:16 +08:00
committed by GitHub
parent 82e7936d36
commit d02f762ab0
20 changed files with 2346 additions and 222 deletions
+22
View File
@@ -292,9 +292,31 @@ export const zhCN: Translations = {
input: "输入",
output: "输出",
total: "总计",
view: "显示方式",
unavailable:
"暂无 Token 用量。只有模型成功返回且供应商提供 usage_metadata 时才会显示。",
unavailableShort: "未返回用量",
note: "基于供应商返回的 usage_metadata 展示。当前总量是 best-effort 的会话参考值,可能与平台账单页不完全一致。",
presets: {
off: "关闭",
summary: "总览",
perTurn: "每轮",
debug: "调试",
},
presetDescriptions: {
off: "隐藏顶部和会话内的 token 展示。",
summary: "只在顶部显示当前对话累计 token。",
perTurn: "显示顶部累计,并为每轮 assistant 回复显示一条汇总 token。",
debug: "显示顶部累计,并展示按步骤归类的 token 调试信息。",
},
finalAnswer: "最终回复",
stepTotal: "步骤总计",
sharedAttribution: "该 token 由此步骤中的多个动作共同消耗",
subagent: (description: string) => `子任务:${description}`,
startTodo: (content: string) => `开始 To-do${content}`,
completeTodo: (content: string) => `完成 To-do${content}`,
updateTodo: (content: string) => `更新 To-do${content}`,
removeTodo: (content: string) => `移除 To-do${content}`,
},
// Shortcuts