Skip to content

[FEATURE]:Show context usage in OpenCode Desktop, including for local OpenAI-compatible models #34900

Description

@yooo1999

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

Description

I am using OpenCode Desktop with a local model served through an OpenAI-compatible endpoint, and I cannot see how much of the context window is currently used.

My setup:

  • OpenCode version: 1.17.13
  • Client: OpenCode Desktop
  • Provider: custom OpenAI-compatible provider
  • Model backend: local llama-server
  • Models:
    • Qwen 3.6 35B A3B
    • Huihui Qwen 3.6 35B A3B
  • Context window: 262144
  • Endpoint shape:
{
  "provider": {
    "local-qwen": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Local Qwen on Mac",
      "options": {
        "baseURL": "http://127.0.0.1:18080/v1"
      },
      "models": {
        "huihui-qwen36-35b-262k": {
          "name": "Huihui Qwen 3.6 35B A3B via Mac"
        }
      }
    }
  },
  "model": "local-qwen/huihui-qwen36-35b-262k"
}

The local endpoint returns OpenAI-compatible usage fields, for example:

{
  "usage": {
    "prompt_tokens": 8851,
    "completion_tokens": 38,
    "total_tokens": 8889,
    "prompt_tokens_details": {
      "cached_tokens": 8835
    }
  }
}

But in OpenCode Desktop, I do not see any visible context usage indicator, percentage, token count, or /context command.

Why this matters

For local long-context models, context visibility is very important.

In my case, the model supports a large context window of 262144 tokens, but OpenCode can still send a large amount of system prompt, tools, skills, and conversation history. Without a visible context indicator in Desktop, it is hard to know:

  • how much context is currently used
  • when compaction is likely to happen
  • whether tool schemas or skills are consuming too much context
  • whether a local provider is reporting usage correctly
  • whether the session is close to context overflow

This is especially important when comparing OpenCode Desktop with the TUI, Cursor, or other agents.

Related issues / PRs

This seems related to these existing issues and PRs:

Expected behavior

OpenCode Desktop should show context usage for the active session, similar to the TUI.

Ideally, it should show:

  • current context tokens
  • context window size
  • percentage used
  • prompt tokens
  • completion tokens
  • cached tokens, if available
  • estimated non-cached input tokens
  • breakdown by:
    • system prompt
    • messages
    • tools
    • skills
    • MCP / provider metadata, if available

At minimum, Desktop should show something like:

Context: 8.9K / 262K tokens (3.4%)

Actual behavior

In OpenCode Desktop, I only see the chat UI and selected model. I do not see context usage, token usage, context percentage, or a /context command.

Suggested implementation

A minimal implementation could display the same context percentage meter that exists in the TUI inside the Desktop chat header or footer.

A more advanced implementation could add a Desktop panel or command that shows a context breakdown, similar to:

Context usage:
- Total: 8,851 / 262,144 tokens
- System prompt: ...
- Tools: ...
- Skills: ...
- Conversation: ...
- Cached tokens: ...

For OpenAI-compatible local providers, OpenCode could use the usage object from responses when available:

usage.prompt_tokens
usage.completion_tokens
usage.total_tokens
usage.prompt_tokens_details.cached_tokens

If exact provider-side token accounting is unavailable, an estimated tokenizer-based value would still be better than no visibility.

Additional notes

I am using a local model specifically because I want long-context local development workflows. Context visibility is one of the main reasons to use OpenCode over other IDE agents, so having this only in the TUI but not in Desktop makes Desktop much harder to use for serious long-running sessions.

Thanks.

Metadata

Metadata

Assignees

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