feat(tui): show subagent cost rollup in sidebar and task history#25712
feat(tui): show subagent cost rollup in sidebar and task history#25712maxkomarychev wants to merge 2 commits into
Conversation
Subagent (Task tool) calls run in separate child sessions, so their LLM spend was previously invisible from the parent. The sidebar showed only the parent session's own cost, and the history task block had no cost line at all. Add `Session.cost(sessionID)` that BFS-walks descendants and sums assistant message cost across the subtree, exposed via a new `GET /session/:id/cost` route (Hono + HttpApi parity). The TUI sync caches the rollup and invalidates it on `message.updated` for any completed assistant message, so subagent completions propagate to ancestor sidebars without tracking parent_id chains client-side. Sidebar now renders `$X.XX ($Y.YY subagents) spent` when subagents exist, and the completed Task tool footer in the message stream gains a `· $X.XX` suffix showing that subagent task's total spend (its own plus its own descendants).
|
The following comment was made by an LLM, it may be inaccurate: ResultsPotentially Related PR:
This PR (25712) appears to be the only one specifically addressing subagent cost rollup display in the sidebar and task history. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Subagent (Task tool) calls run in separate child sessions, so their LLM spend was previously invisible from the parent. The sidebar showed only the parent session's own cost, and the history task block had no cost line at all.
Add
Session.cost(sessionID)that BFS-walks descendants and sums assistant message cost across the subtree, exposed via a newGET /session/:id/costroute (Hono + HttpApi parity). The TUI sync caches the rollup and invalidates it onmessage.updatedfor any completed assistant message, so subagent completions propagate to ancestor sidebars without tracking parent_id chains client-side.Sidebar now renders
$X.XX ($Y.YY subagents) spentwhen subagents exist, and the completed Task tool footer in the message stream gains a· $X.XXsuffix showing that subagent task's total spend (its own plus its own descendants).Issue for this PR
Type of change
What does this PR do?
Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
I ran the prompt "I want to test subagent cost feature. use @explore to in parallel for @src/ and @specs/ and explain their contents to me"
Screenshots / recordings
Checklist
If you do not follow this template your PR will be automatically rejected.