feat: Add opt-in subagent cost reporting - #194
Open
daanzu wants to merge 5 commits into
Open
Conversation
Accumulate Pi-reported usage.cost.total across subagent turns, resumes, and compaction without deriving cost from token totals. Add the opt-in showCost setting and render estimated costs in the live widget, foreground and background results, and get_subagent_result. Keep cost reporting disabled by default and omit aggregate group totals. Verification: npm run lint, npm run typecheck, npm run build, and the focused cost-reporting tests (232 passed).
Add a showGroupSummary setting for grouped background-agent notifications. When enabled, grouped results show aggregate completion and token usage above the individual agent entries, while existing output remains unchanged by default. Include aggregate cost only when showCost is enabled, and cover settings persistence plus summary formatting with focused tests.
Expose the existing opt-in cost setting to FleetList and include each agent's reported lifetime cost in the right-aligned FleetView stats. Reuse retained lifetime usage so finished agents keep their cost, while preserving the existing output when cost display is disabled. Add focused FleetView coverage for enabled and disabled cost display. Verified with the FleetView tests, lint, typecheck, and build.
Read lifetime token and reported cost totals from the completed agent record so turn-limited agents retain their usage counts after live activity state is removed. Keep cost visibility gated by the existing showCost setting. Add regression coverage for steered agents, including the opt-in cost display behavior. Verified with lint, typecheck, and the focused agent-widget tests (14 passed).
Author
|
Rebased onto upstream master and resolved the conflicts. Lint, typecheck, and build pass; 821 tests pass, with 14 known Windows/path failures. |
Pass the existing opt-in cost display setting into conversation viewers opened from FleetView and /agents. Read retained lifetime usage so completed agents keep showing their reported cost, and cover enabled and disabled display paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds opt-in, per-agent model cost reporting to
pi-subagents.usage.cost.totalacross turns, resumes, and compaction.showCost, defaulting tofalse.get_subagent_result, and FleetView.Related to #193. This change adds reporting in subagent surfaces; it does not add a top-level
usagefield to tool results for automatic parent-session footer aggregation.Verification
npm run lintnpm run typechecknpm run buildDisclosure
This change was implemented with the assistance of an AI coding agent.