Expose real-time context/usage metrics in the Copilot SDK
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Domain
- api, documentation
Research direction
Start by reviewing the SDK documentation for session.usage_info, assistant.usage, session.idle, and compaction or lifecycle events, then compare those surfaces with the CLI’s /context and /usage commands. Done means the SDK documents stable on-demand context and usage APIs, explains event persistence and resume behavior, and defines the relevant lifecycle event schemas.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 10.5k
- Forks
- 1.5k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 133
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/copilot-sdk
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/copilot-sdk#2709 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
github/copilot-sdk#2673 ·
-
bug testing
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
github/copilot-sdk#2628 ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/copilot-sdk#2627 · 1 comment ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
github/copilot-sdk#2493 ·
All issues in github/copilot-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
checkstyle/test-configs#263 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
1.0.0-alpha2 Type/Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#272 ·