What do you want to change?
Add ctx.ui.setUsage(key, usage) so extensions can report cost from LLM work that happens outside the parent session. The built-in footer folds it into its cost display, e.g. $2.000 (+$1.500 ext).
Why?
Extensions that spawn child pi processes (subagents) or run other out-of-session LLM work have no way to surface that spend. The footer only folds parent-session assistant messages, so heavy subagent use makes the displayed cost undercount the real total significantly. Replacing the whole footer via setFooter is too invasive and drifts as the built-in footer improves.
How? (optional)
Same pattern as setStatus: per-key map on FooterDataProvider, exposed through ReadonlyFooterDataProvider so custom footers get it too, cleared on session switch, fire-and-forget in RPC mode, no-op in print/json. ~40 lines of core code plus tests and docs.
I maintain a subagent extension and want to implement this myself. Branch is ready with tests and docs passing npm run check: https://github.com/LukasParke/pi/tree/feat/extension-usage-footer
Note: I used an agent to help write the code and this issue; I have reviewed both and can explain every line.
What do you want to change?
Add
ctx.ui.setUsage(key, usage)so extensions can report cost from LLM work that happens outside the parent session. The built-in footer folds it into its cost display, e.g.$2.000 (+$1.500 ext).Why?
Extensions that spawn child pi processes (subagents) or run other out-of-session LLM work have no way to surface that spend. The footer only folds parent-session assistant messages, so heavy subagent use makes the displayed cost undercount the real total significantly. Replacing the whole footer via
setFooteris too invasive and drifts as the built-in footer improves.How? (optional)
Same pattern as
setStatus: per-key map onFooterDataProvider, exposed throughReadonlyFooterDataProviderso custom footers get it too, cleared on session switch, fire-and-forget in RPC mode, no-op in print/json. ~40 lines of core code plus tests and docs.I maintain a subagent extension and want to implement this myself. Branch is ready with tests and docs passing
npm run check: https://github.com/LukasParke/pi/tree/feat/extension-usage-footerNote: I used an agent to help write the code and this issue; I have reviewed both and can explain every line.