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
+23
View File
@@ -306,9 +306,32 @@ export const enUS: Translations = {
input: "Input",
output: "Output",
total: "Total",
view: "Display",
unavailable:
"No token usage yet. Usage appears only after a successful model response when the provider returns usage_metadata.",
unavailableShort: "No usage returned",
note: "Shown from provider-returned usage_metadata. Totals are best-effort conversation totals and may differ from provider billing pages.",
presets: {
off: "Off",
summary: "Summary",
perTurn: "Per turn",
debug: "Debug",
},
presetDescriptions: {
off: "Hide token usage in the header and conversation.",
summary: "Show only the current conversation total in the header.",
perTurn:
"Show the header total and one token summary per assistant turn.",
debug: "Show the header total and step-level token debugging details.",
},
finalAnswer: "Final answer",
stepTotal: "Step total",
sharedAttribution: "Shared across multiple actions in this step",
subagent: (description: string) => `Subagent: ${description}`,
startTodo: (content: string) => `Start To-do: ${content}`,
completeTodo: (content: string) => `Complete To-do: ${content}`,
updateTodo: (content: string) => `Update To-do: ${content}`,
removeTodo: (content: string) => `Remove To-do: ${content}`,
},
// Shortcuts