[FEATURE]: Session context usage (similar to /context in Claude) #3860

Open
opened 2026-02-16 17:41:42 -05:00 by yindo · 6 comments
Owner

Originally created by @mtymek on GitHub (Dec 25, 2025).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • 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:
Image

How does it work?

  • It exposes new server endpoint - /session/:sessionID/context that it then loaded in TUI when <leader>i key 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:
Image

Originally created by @mtymek on GitHub (Dec 25, 2025). Originally assigned to: @thdxr on GitHub. ### 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: <img width="773" height="549" alt="Image" src="https://github.com/user-attachments/assets/26833ca9-a8bb-46fb-b638-60b49164c6bb" /> ### How does it work? - It exposes new server endpoint - `/session/:sessionID/context` that it then loaded in TUI when `<leader>i` key 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: <img width="417" height="505" alt="Image" src="https://github.com/user-attachments/assets/c190bb41-7c53-4893-8bf4-58cd033dec15" />
yindo added the opentuidiscussion labels 2026-02-16 17:41:42 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 25, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1990: Add User Controls for Context Management - Proposes context management commands including a /tokens command to display token usage breakdown
  • #2995: Feature: status command - Requests a /status command similar to Claude that would show used context breakdown
  • #4659: Sliding window context management for long-running sessions - Proposes an extensive context management system with a TUI context viewer that shows token usage breakdown
  • #3759: More Detailed Subagent's Context - Requests ability to see context size, tool calls, token usage, and context size for optimization

Feel free to ignore if your specific case differs from these existing requests.

@github-actions[bot] commented on GitHub (Dec 25, 2025): This issue might be a duplicate of existing issues. Please check: - #1990: Add User Controls for Context Management - Proposes context management commands including a `/tokens` command to display token usage breakdown - #2995: Feature: status command - Requests a `/status` command similar to Claude that would show used context breakdown - #4659: Sliding window context management for long-running sessions - Proposes an extensive context management system with a TUI context viewer that shows token usage breakdown - #3759: More Detailed Subagent's Context - Requests ability to see context size, tool calls, token usage, and context size for optimization Feel free to ignore if your specific case differs from these existing requests.
Author
Owner

@ramarivera commented on GitHub (Dec 25, 2025):

I was just about to raise a feature request for this and found yours, amazing :D

@ramarivera commented on GitHub (Dec 25, 2025): I was just about to raise a feature request for this and found yours, amazing :D
Author
Owner

@mtymek commented on GitHub (Jan 4, 2026):

@thdxr seems there is some interest for this. Would you accept the PR?

@mtymek commented on GitHub (Jan 4, 2026): @thdxr seems there is some interest for this. Would you accept the PR?
Author
Owner

@tebayoso commented on GitHub (Jan 10, 2026):

We need this feature because some times the agent generates chunks of code that just breaks the context, for example taking a screenshot on a model that don't support vision, or reading a whole react site and using it as context. Being able to edit/update/modify context after this happens is a must.

@tebayoso commented on GitHub (Jan 10, 2026): We need this feature because some times the agent generates chunks of code that just breaks the context, for example taking a screenshot on a model that don't support vision, or reading a whole react site and using it as context. Being able to edit/update/modify context after this happens is a must.
Author
Owner

@eparreno commented on GitHub (Jan 12, 2026):

Love this!!!

@eparreno commented on GitHub (Jan 12, 2026): Love this!!!
Author
Owner

@DeveloperJose commented on GitHub (Jan 18, 2026):

I'm working on this, you can see here how it looks like to analyze the context of your last sent message. You can also see what opencode sends and to what models when it wants a title or summary generated.

Image
@DeveloperJose commented on GitHub (Jan 18, 2026): I'm working on this, you can see here how it looks like to analyze the context of your last sent message. You can also see what opencode sends and to what models when it wants a title or summary generated. <img width="2547" height="1388" alt="Image" src="https://github.com/user-attachments/assets/06d4a640-34af-4093-89c0-f650f1309f2f" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3860