Repository navigation
[Idea] Expose session context and usage stats to extensions via the SDK #4823
sogeisetsu
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
What are you trying to do, and what gets in your way?
I want to build an OpenChamber extension that shows the current session's context usage: how much of the window is used, the breakdown by system prompt / tools & subagents / conversation messages / MCP & connectors / skills, and the cumulative input, output, reasoning, cache-read and cost numbers.
The SDK blocks this.
host.onReadygives a session only{ id, title, busy, model?, agent? }, and thesessionscapability exposes project, worktree and session listings and live state (activity,outcome) but no token or context numbers. None of the capabilities (prompt,sessions,files,model,shells) reach the usage data the app already has, so the only way today is to read OpenCode's files throughfiles/filesystempatterns and parse an internal format that is not a public contract — fragile, and it asks the user to approve a broad path pattern.What would you like to happen instead?
A read-only call that returns the current session's context and usage stats:
Scoped to the open session, or taking a sessionId. Read-only, no new write path.
The app already computes all of it: the Context rail tooltip shows the used tokens, the limit and the session cost, and the panel shows the category breakdown. This is exposing data on the host bridge, not computing anything new.
This is the extension-side half of #4821, which asks for the same numbers in the built-in panel. Exposing them on the SDK also lets an extension show them where the built-in panel cannot.
Anything that shows what you mean
The Host API docs, "What OpenChamber pushes to you" and the
sessionscapability list: no token or context fields. I abandoned an extension over exactly this gap.Would you want to build it?
I'd like to build it if we agree on the shape. If a narrower first step is easier, the session token total from #4527 would already unblock a useful extension.
All reactions