Skip to content

Extension-reported usage in the footer cost display (ctx.ui.setUsage) #6509

Description

@LukasParke

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions