GeezerVison is showing github.com — feat(tui): show subagent cost rollup in sidebar and task history by maxkomarychev · Pull Request #25712 · anomalyco/opencode
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).
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
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
malventano, Areiser, Cellule, ivanaguilario, ItsThareesh, egnerfl, vbfox, and bergmark reacted with thumbs up emoji
zsiegel-khealth, ruslan-kurchenko, IlarionHalushka, alrebellato, Areiser, actellim, Cellule, ivanaguilario, and vbfox reacted with rocket emoji
All reactions
-
👍
8 reactions
-
🚀
9 reactions
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:
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍
|
maxkomarychev reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This is a solid PR and much needed as subagent spending is currently effectively invisible.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The status bar (prompt/index.tsx:351) and subagent footer (subagent-footer.tsx:45) still read session.cost directly, showing only the current session's cost instead of the aggregated total. Was this intentional or an oversight? Happy to follow up with a PR if needed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Any progress on this 👀 would love to get that info without having to check my billing section to get the info summarized...
|
Cellule reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.
— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|