GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: Session context usage (similar to /context in Claude) · Issue #6152 · anomalyco/opencode

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

New issue
Copy link
New issue
Copy link
Closed
Closed
[FEATURE]: Session context usage (similar to /context in Claude)#6152
Copy link
Assignees
thdxr

Description

@mtymek
mtymek
opened on Dec 25, 2025
Issue body actions

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

Reacted by Paul Martin, Eric Schmid, shekohex, David Brouwer, Ramiro, pennyfx, Mani Sundararajan, Christian Kreiling, Andrii Semenkov, Justin and 132 more
Reacted by mikhailfur, Raphael Caldas, Brecht Carlier, Rahman Adianto, Lucas Charles, Ismael, Vitaly X, qk8 and Alex
Reacted by Lotusland-Kioea, Vitaly X and qk8

Activity

Next
  1. mtymek
    added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Dec 25, 2025
  2. github-actions
    assigned
    thdxr
    on Dec 25, 2025
  3. github-actions
    added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 25, 2025
  4. github-actions commented on Dec 25, 2025

    @github-actions
    github-actionsBot
    on Dec 25, 2025 – with GitHub Actions
    Contributor
    More actions

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

    • [Feature Request] Add User Controls for Context Management #1990: Add User Controls for Context Management - Proposes context management commands including a /tokens command to display token usage breakdown
    • Feature: status command #2995: Feature: status command - Requests a /status command similar to Claude that would show used context breakdown
    • [FEATURE] Sliding window context management for long-running sessions #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
    • [FEATURE]: More Detailed Subagent's Context #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.

  5. ramarivera commented on Dec 25, 2025

    @ramarivera
    ramarivera
    on Dec 25, 2025
    More actions

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

    Reacted by Mateusz Tymek, Matias Käkelä, Jorge de los Santos, Ruitong Liu, Christian Paniagua, Yash Malviya and Yizhou Jiang
  6. mtymek commented on Jan 4, 2026

    @mtymek
    mtymek
    on Jan 4, 2026
    ContributorAuthor
    More actions

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

    Reacted by Xi Xiao, Fucker, B E C H and Yizhou Jiang
  7. tebayoso commented on Jan 10, 2026

    @tebayoso
    tebayoso
    on Jan 10, 2026
    More actions

    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.

  8. eparreno commented on Jan 12, 2026

    @eparreno
    eparreno
    on Jan 12, 2026
    More actions

    Love this!!!

  9. DeveloperJose commented on Jan 18, 2026

    @DeveloperJose
    DeveloperJose
    on Jan 18, 2026
    More actions

    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
    Reacted by Jari Pennanen
    Reacted by João Reberti, Michele Cantelli, Thomas Williamson, Rico, VolkumDev, Dozer, Vitaly X and Jakob Drachmann Havtorn
  10. nesk commented on Feb 17, 2026

    @nesk
    nesk
    on Feb 17, 2026
    More actions

    I would be really interested to have this feature. It's not always easy to understand how much enabling or disabling an MCP server can impact the context.

  11. 0xGurg commented on Mar 11, 2026

    @0xGurg
    0xGurg
    on Mar 11, 2026
    More actions

    +1 to this feature request.

  12. AvatarGanymede commented on Mar 11, 2026

    @AvatarGanymede
    AvatarGanymede
    on Mar 11, 2026
    More actions

    I really need this feature to judge my skill and mcp costs

    Reacted by Dozer
  13. jonathan5p commented on Mar 13, 2026

    @jonathan5p
    jonathan5p
    on Mar 13, 2026
    More actions

    Already waiting for this feature to be included 🙏🏼

  14. Ciantic commented on Mar 16, 2026

    @Ciantic
    Ciantic
    on Mar 16, 2026
    More actions

    I would also like to see what the context was, not just the costs and usages. E.g. I want to drill down exact conversation, so I can see context bloat.

  15. AvatarGanymede commented on Mar 16, 2026

    @AvatarGanymede
    AvatarGanymede
    on Mar 16, 2026
    More actions

    Is anyone working on this issue? I plan to develop this feature 'cause I really really need it

    Reacted by Frito
  16. 1 remaining item

  17. alxark commented on Mar 27, 2026

    @alxark
    alxark
    on Mar 27, 2026
    More actions

    Would like to see this feature in OpenCode (especially side bar stat).

  18. Djordje-Stojanovic commented on Apr 13, 2026

    @Djordje-Stojanovic
    Djordje-Stojanovic
    on Apr 13, 2026
    More actions

    This would be a truly useful feature that would make me switch to Opencode from claude directly. I would love to see the usage per file.

  19. Alezander9 commented on Apr 13, 2026

    @Alezander9
    Alezander9
    on Apr 13, 2026
    More actions

    Hello, I am bumping this issue and voicing my support for this feature request

    Reacted by Oscar Morante, Paul Szymanski, Luis Romero, johannesrave, Florin Andrei, WaldoPepper, Denis Riazantsev, janorga, Bram Musters, Brandon Tull and 1 more
  20. thdxr
    removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on May 3, 2026
  21. mikhailfur commented on May 31, 2026

    @mikhailfur
    mikhailfur
    on May 31, 2026
    More actions

    This feature is important not only for context management, but also for cost control with OpenRouter / token-billed providers.

    Right now OpenCode users cannot clearly see whether context is consumed by chat history, file attachments, tool results, MCP schemas, or system/provider metadata. For models like Kimi via OpenRouter, this can directly turn one task into a $1+ request.

    Even an estimated context breakdown would be very useful:

    • model context limit
    • estimated context used
    • remaining context
    • chat/history tokens
    • attached file tokens
    • tool result tokens
    • MCP/tool schema tokens
    • compaction status
    • last provider-reported token usage

    A TUI panel/sidebar would be ideal, but even a /context command would already solve a big part of the problem.

  22. rhmndnt commented on Jun 12, 2026

    @rhmndnt
    rhmndnt
    on Jun 12, 2026
    More actions

    What make us delay this feature? So much needed for my context anxiety. Please.

    Reacted by 372046933 and Vitaly X
  23. theabecaster commented on Jun 20, 2026

    @theabecaster
    theabecaster
    on Jun 20, 2026
    More actions

    There've been a few takes on this already (#24210 most recently) that got auto-closed without ever being reviewed. Before I redo that work, is this something you'd actually accept, and is there a shape you want?

    I went digging through the code first and a decent chunk already exists: GET /api/session/:sessionID/context gives you the messages after the last compaction, and every assistant message already stores the provider's real token counts (input/output/cache). So the accurate total and the % used are basically free.

    The part that has to be estimated is the per-category split: system, tools, chat history, tool results, file reads. I'd estimate those roughly (chars/4) and then get the system+tools overhead by subtracting the estimated history from the real input total the provider already reported. That way the overhead number stays grounded and I don't have to rebuild the whole system prompt to measure it.

    Shape I had in mind: compute it in core (new context-usage.ts), put it on a sibling endpoint, TUI dialog on /context plus a leader keybind, and the desktop sidebar can reuse the same endpoint later.

    One thing I'd want your call on: is an estimate (chars/4) fine for v1, or do you want a real tokenizer? I'd rather not pull tiktoken in just for this.

    Happy to put up a small PR if the shape sounds right.

    Reacted by Shengyu Zhang, Dmitry, 372046933, Vlad Goldman and Jakob Drachmann Havtorn
  24. simonklee
    marked [FEATURE]: Expose context/token usage to the user (e.g. /context command or status bar indicator) #33324 as a duplicate of this issue on Jun 23, 2026
  25. enesgur commented on Aug 2, 2026

    @enesgur
    enesgur
    on Aug 2, 2026
    More actions

    +1 to this feature.

  26. JakobHavtorn commented on Aug 6, 2026

    @JakobHavtorn
    JakobHavtorn
    on Aug 6, 2026
    More actions

    Any activity on this issue? It would be a very welcomed feature.

  27. ZackarySantana commented on Aug 7, 2026

    @ZackarySantana
    ZackarySantana
    on Aug 7, 2026
    More actions

    I really liked context menus in other harnesses, so I built this extension in the meantime for opencode.

    Reacted by Rahman Adianto and Yanick Bélanger
  28. tuan2linh commented on Oct 4, 2026

    @tuan2linh
    tuan2linh
    on Oct 4, 2026
    More actions

    Real-world case for why context visibility + management matters

    @tebayoso's comment above already nails this:

    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.

    Hit basically that exact scenario on opencode v2.0.18 (Desktop app, Windows),
    confirmed by pulling raw message history via
    opencode api get /api/session/{id}/message:

    1. Agent's own tool-result screenshot persists and gets reused silently.
      The agent called browser.screenshot (via Code Mode execute) to inspect
      a running Electron desktop app. That screenshot is a tool-result file part,
      rendered in the Desktop app transcript only inside a collapsible tool-call
      row -- not as a visible chat image like a user-pasted attachment. Many
      turns later, discussing an unrelated topic, the agent reused that stale
      screenshot (combined with a Get-Process timestamp) to make a UI claim,
      worded as if it were current. A later attempt to take a fresh screenshot
      failed ([browser.operation_failed] browser.screenshot failed. Screenshot needs a visible tab...), and the agent fell back to the stale cached
      image without flagging that explicitly.

    2. User-pasted images from earlier turns get referenced in later unrelated
      turns without being resent.
      Several images were pasted across different
      user turns (files: 1 each, confirmed via the message API). On a later
      turn with files: 0, the agent's reply said "latest image" / "the image
      you sent", reusing an earlier turn's image. Technically correct (full
      history is resent every call), but there's no way to tell which earlier
      image is being referenced, and no way to drop a specific stale image once
      it's no longer relevant -- short of a new session or a full /compact
      (lossy for everything else too).

    Without a /context view, there was no way to even confirm that this was
    happening -- I had to query the message API by hand to prove the stale image
    was still being resent. A context viewer (this issue) is the prerequisite for
    any kind of selective cleanup (the related ask in #7712, now closed as
    not-planned/duplicate -- but the underlying need is very much still live, see
    this thread and #3759).

    Environment:

    • opencode version: 2.0.18
    • OS: Windows_NT 10.0.26200 (win32 x64)
    • Client: Desktop app
    • Active plugins: opencode-browser
  29. dppalomar commented on Oct 9, 2026

    @dppalomar
    dppalomar
    on Oct 9, 2026
    More actions

    I totally agree that this /context command is necessary. Why OpenCode core developers don't consider this?

  30. neriousy
    closed this as completedon Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.