Skip to content

Input tokens inconsistent with circle context #34712

Closed as not planned
Closed as not planned

Description

@promptcombos

Description

Image

At version 1.17.12, count input token was wrong. Input tokens was increase wrong. I also try to compact but Input token still do not decrease while Usage show less.

Plugins

NA

OpenCode version

1.17.12

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Jul 1, 2026

    @github-actions
    Contributor

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

  2. wickedits commented on Jul 8, 2026

    @wickedits

    Weird that nobody has addressed this critical visual bug already

  3. royruho commented on Jul 8, 2026

    @royruho

    This is a very critical issue I also experience.
    at least for v 1.17.12 - v.1.17.14
    The token count is inflated - /compact does not reduce it and worst of all
    this means that we can't track context size, therefore when to /compact the session

    Issue exist both for web and desktop

    TUI works fine

  4. yochaym22 commented on Jul 8, 2026

    @yochaym22

    Seeing the same thing.

    Environment
    OpenCode version: 1.17.14 (also reproduced on 1.17.12 per the original report)
    Last known good: 1.17.11 — the inflated count does not occur there
    Interface: Desktop / Web (TUI is unaffected — see below)
    OS: [your OS + version]
    Provider/model: [e.g. Anthropic / Claude Sonnet 4.5]

    Summary
    The input/context token count is inflated in Web/Desktop and /compact does not bring it down, even though the Usage view reports a smaller number. The TUI, in the same session, shows the correct (much lower) count.
    Steps to reproduce

    Start a session and run enough turns to accumulate history (tool calls / file reads help).
    Compare the token count shown in the TUI vs. Web/Desktop for the same session — Web/Desktop is several times higher.
    Run /compact. The TUI count drops as expected; the Web/Desktop input-token figure stays high and can keep climbing.

    TUI vs Web/Desktop
    This looks like the long-standing display discrepancy from #3322: the TUI reports the current context (last message), while Web/Desktop aggregates across the whole session, so its number is cumulative rather than the actual prompt size.
    Likely root cause
    I think this is the accumulation bug described in #30649: session token fields (including tokens_cache_read) are summed additively every turn in projector.ts, so the session total is a lifetime counter, not the current context. That explains why /compact can't reduce it — pruning messages doesn't decrement a cumulative counter — and why it keeps increasing. When overflow/compaction logic reads that inflated cumulative value, sessions also hit context_length_exceeded errors even when the true context would fit (related: #17746, #29857).
    Regression window
    Clean on 1.17.11, present on 1.17.12 and 1.17.14.

  5. github-actions commented on Sep 7, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

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