Expose real-time context/usage metrics in the Copilot SDK
- 主要言語
- Java
- スター
- 10.5k
- フォーク
- 1.5k
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 129
説明
**Summary**
Today the Copilot CLI provides /context and /usage as first-class UX commands, but the SDK docs do not expose an equivalent stable API for apps to fetch the same information directly.
This makes it hard to build a UI that shows live session context pressure, token usage, and compaction status in real time or near-real time. The closest available surfaces appear to be streaming events like session.usage_info, assistant.usage, and compaction/session lifecycle events, but these are event-based and ephemeral rather than a documented queryable API.
**Request**
- Add a documented SDK method or session API for retrieving current context/window usage on demand.
- Add a documented session usage API for current/aggregate token and cost metrics.
- Clarify which usage events are ephemeral vs persisted and what is available after resume.
- Provide a stable event/schema contract for session.idle and related lifecycle events.
Why this matters
- Enables apps to render accurate live context bars and usage dashboards.
- Avoids relying on internal/undocumented event shapes.
- Makes Copilot SDK easier to integrate into production UIs.
Docs gap noted
- The SDK docs mention session.usage_info and assistant.usage, but there is no explicit “fetch current context usage now” API like the CLI’s /context command.
- session.idle appears to have inconsistent payload documentation across pages.
コントリビューションガイド
調査の方向性
まず、session.usage_info、assistant.usage、session.idle、および compaction またはライフサイクルイベントについて SDK のドキュメントを確認し、その後、それらのインターフェースと CLI の /context および /usage コマンドを比較します。SDK がコンテキストと使用状況をオンデマンドで取得するための安定した API をドキュメント化し、イベントの永続化と再開時の動作を説明し、関連するライフサイクルイベントのスキーマを定義できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 領域
- api, documentation
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100