Skip to content

feat(tui): show subagent cost rollup in sidebar and task history#25712

Open
maxkomarychev wants to merge 2 commits into
anomalyco:devfrom
maxkomarychev:tui-subagent-cost-rollup
Open

feat(tui): show subagent cost rollup in sidebar and task history#25712
maxkomarychev wants to merge 2 commits into
anomalyco:devfrom
maxkomarychev:tui-subagent-cost-rollup

Conversation

@maxkomarychev
Copy link
Copy Markdown

@maxkomarychev maxkomarychev commented May 4, 2026

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).

Issue for this PR

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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

Screenshot 2026-05-04 at 15 24 59

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

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).
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

The following comment was made by an LLM, it may be inaccurate:

Results

Potentially Related PR:

This PR (25712) appears to be the only one specifically addressing subagent cost rollup display in the sidebar and task history.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant