Skip to content

Inconsistent Session Token Count #1937

Description

@spoons-and-mirrors

Summary

I noticed this issue while working on the footer token counter, but this happens on opencode official releases as well.

After discussing the issue on discord, several users saw a similar behavior.
While some could NOT reproduce it over dozens of tries, others witnessed it at close to a 50% rate.

This issue was seen on multiple providers and models so far:

  • github-copilot/gpt-4.1
  • openai/gpt-4.1
  • google/gemini-2.5-pro

It isn't clear whether opencode sends system prompt etc in duplicate or if the token count mechanism suffers from a counting error.
This is issue likely hits every models and providers, for some users? Could lead to preemptive auto /compact in a session and probably other shenanigans?

Image Image

I also been seeing session token count regress at times for no apparent reason 🤦‍♂️

Activity

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