Skip to content

馃巵 feat(session): emit usage_update notification after turns and model - #75

Open
frostime wants to merge 1 commit into
svkozak:mainfrom
frostime:feat/session-usage-updates
Open

馃巵 feat(session): emit usage_update notification after turns and model#75
frostime wants to merge 1 commit into
svkozak:mainfrom
frostime:feat/session-usage-updates

Conversation

@frostime

Copy link
Copy Markdown

PR: Emit ACP usage updates

Summary

  • Emit ACP usage_update notifications with current context usage and cumulative USD cost.
  • Refresh usage after session creation or restoration, completed agent turns, and model changes.
  • Ignore unavailable or malformed Pi session statistics instead of reporting zero usage.

Rationale

Pi already exposes get_session_stats. Forwarding its context and cost fields lets ACP clients present current usage without parsing agent messages or maintaining a separate estimate.

Implementation notes

  • PiAcpSession.refreshUsage() owns Pi statistics normalization and ACP notification emission.
  • The refresh counter makes the latest completed request authoritative.
  • Existing ACP update serialization is retained.

Validation

  • npm run typecheck passed.
  • npm run build passed.
  • The added usage-update tests passed.
  • On the upstream baseline, npm test completed with 89 passing and 2 pre-existing Windows path-separator assertion failures in session-events.test.ts and session-list-and-load.test.ts; neither failure exercises usage updates.

Effect on Zed

鍥剧墖

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