Skip to content

[FEATURE]: Near-Real-Time Token and Cost Visibility #10354

@dmoliveira

Description

@dmoliveira

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

Overview

Introduce a near-real-time usage and cost visibility panel in OpenCode that surfaces token consumption and spend while users work. The goal is to prevent unexpected limit hits, reduce frustration, and help users actively manage cost and performance, especially when using expensive reasoning or thinking models.

Problem

Users often discover they have hit daily or weekly limits only after the fact. This breaks flow, interrupts work, and discourages experimentation. The problem becomes more severe with long-running tasks, agents, or high-cost models, where usage can spike quickly without clear feedback.

Proposed Feature

Add a lightweight, always-visible usage indicator that updates near-real-time during task execution.

The feature should provide:

  • Token usage for the current task, split by input and output (input optional)
  • Usage and cost status aligned with the user’s billing model
  • Clear visibility of reset timing for limits
Image

Key Capabilities

1. Live Token Consumption

  • Show incremental token usage while a task is running
  • Split by:
    • Input tokens (optional)
    • Output tokens
  • Display both:
    • Current task usage
    • Session-level totals

2. Plan-Aware Usage Display

  • API key based usage
    • Show estimated cost in USD
    • Currency configurable via settings
  • Subscription or plan based usage
    • Show daily and weekly usage as percentages
    • Clearly indicate remaining allowance
    • Display next reset time for daily and weekly limits

3. Early Warning Signals

  • Soft warnings when usage crosses configurable thresholds (for example 70 percent or 90 percent)
  • Clear visual cues when approaching limits, before hard failures occur

Functional Requirements

  • Usage updates within seconds of token generation
  • Accurate token accounting aligned with provider billing
  • Works consistently across:
    • Single prompts
    • Agents
    • Multi-step workflows
  • Minimal UI footprint, such as a status bar indicator or collapsible panel

Non-Functional Requirements

  • Low overhead with no noticeable latency impact
  • Graceful degradation to last known usage if real-time updates fail
  • Extensible to support new plans, limits, and pricing schemes
  • Clear and consistent visual language

Example UI Behaviour

  • While a task runs, the status bar updates live with token usage
  • API key users see:
    Task cost: USD 0.42 | Session: USD 1.87
  • Plan users see:
    Daily usage: 62% | Weekly usage: 41% | Reset in 3h 12m
  • When nearing limits, the indicator turns amber with a short warning tooltip

Impact

  • Fewer unexpected limit hits
  • Better cost awareness and control
  • Higher confidence when using advanced or expensive models
  • Improved developer experience and trust in OpenCode as a professional-grade AI coding assistant

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussionzenRelates to Zen

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions