opencode
opencode copied to clipboard
[FEATURE]: Session context usage (similar to /context in Claude)
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I would like to implement a simple tool - TUI dialog - that displays a breakdown of the current session's context window usage, answering the question "what is eating my context window". A feature similar to /context command in Claude Code, but leveraging TUI dialog to avoid obstructing the chat log.
Its purpose is to optimize the context usage by understanding what exactly is consuming it.
I build a quick PoC, and while the real token usage is difficult to get, the estimations seem good enough to be useful.
Would you be interested in having such feature in the core?
Here's the PoC implement as a dialog:
How does it work?
- It exposes new server endpoint -
/session/:sessionID/contextthat it then loaded in TUI when<leader>ikey combo is pressed. - Token usage is estimated (4 characters per token) and then "calibrated" against the the actual total token usage reported by LLM provider. This is probably over-complicated, so I will play around with the methodology if this gets accepted.
It could be placed in the sidebar: