Skip to content

[FEATURE]: Warn users before large potentially uncached requests, not only through debug logs #60945

Open

Description

@mihaellenic

Feature hasn't been suggested before.

  • I searched existing issues. Related issues are linked below; this request specifically concerns user-facing warnings and confirmation before potentially expensive uncached requests.

Describe the enhancement you want to request

Problem

A large session can silently lose prompt-cache reuse after changes to instructions, tools, model settings, or provider-side cache expiry/eviction. The next request may process the entire context as uncached input, causing unexpected cost or subscription-quota consumption.

PR #58801 proposes debug logging for cache-miss causes. This helps diagnose spending afterward, but does not give users an opportunity to avoid it.

Observed example

In OpenCode 2.2.5, using openai/gpt-6.1-sol:

  1. A long session had approximately 283k tokens of context, mostly served from cache.
  2. Disabling a plugin updated the available skill instructions.
  3. The next request recorded 282,498 uncached input tokens and zero cache-read tokens.
  4. There was no user-facing warning before that request.

The timing is consistent with instruction changes invalidating the cached prefix; the precise provider-side cause was not independently confirmed. These figures were obtained from local session records. They do not establish a conversion from token counts to ChatGPT quota percentage.

Proposed behavior

Surface cache-loss risk in the UI rather than requiring debug logs.

Before sending, when OpenCode detects a likely prefix-breaking change and the affected context exceeds a configurable threshold:

Prompt-cache reuse may be lost

Instructions changed. The next request may process approximately 283k input tokens without cache reuse, increasing cost or quota consumption.

Continue · Review options · Cancel

Review options could include:

  • Start a fresh session with a short, user-approved handoff.
  • Compact the current session, explicitly warning that compaction itself may send the full context and incur uncached input usage.
  • Inspect the triggering change.

For cache misses only discoverable after the provider responds, show a visible notice with uncached tokens, cached tokens, and the suspected cause.

Acceptance criteria

  • Known prefix-changing events can trigger a warning before the affected request, including automatic agent continuations.
  • Warnings distinguish observed changes, suspected expiry, and confirmed cache misses; they do not promise knowledge of provider cache state.
  • Show estimated affected input tokens; display monetary estimates only when reliable pricing is available.
  • Never infer a ChatGPT quota percentage from token counts.
  • Compaction is not described as free or guaranteed to avoid the immediate cost. OpenCode's compaction documentation says summary compaction sends the full conversation and can reuse its prompt cache; once that cache is cold, summarizing can itself incur the large input cost plus summary output.
  • Warning thresholds and confirmation behavior are configurable; repeated warnings are deduplicated.
  • Initial cold requests are distinguished from unexpected loss of an established cache.

Related

This issue was drafted with AI assistance using local session evidence and reviewed by the requesting user.

Activity

  1. opencodejr commented on Oct 31, 2026

    @opencodejr

    Thanks for the detailed write-up, @mihaellenic! To restate the request: when OpenCode spots a change that will likely break the cached prompt prefix (changed instructions, tools or model settings, or a suspected cache expiry) on a large context, it would warn you before sending. You could then continue, compact, start a fresh session or cancel. It would also show a visible notice when the provider reports an unexpected cache miss. The threshold and confirmation behaviour would be configurable.

    At the moment there's no user-facing warning for this; #58801 only adds debug logging about why a cache miss happened. This also can't be done fully as a plugin today. Plugin hooks around model requests can't pause or cancel a request to ask you first. A TUI plugin could only show a notice after the fact.

    Related issues:

    Maintainers will consider this request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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