fix(opencode): add session-level token fallback for OpenCode 1.16.0+ - #88
Merged
Conversation
OpenCode 1.16.0 introduced session-level token tracking (tokens_input, tokens_output, etc. on the session table) for GitHub Copilot token-based billing. The tool previously only read per-message data JSON, missing sessions where token data lives only at the session level. - Query the session table as a fallback when per-message tokens sum to zero - Filter sessions by model.providerID matching github-copilot - Replace zero-token message records with a single session-level aggregate record - Add 7 tests covering the fallback behavior - Update test fixtures to include the session table
PanAchy
force-pushed
the
fix/opencode-session-level-tokens
branch
from
June 6, 2026 15:53
bc5633e to
46582cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
sessiontable as a fallback when per-message tokens sum to zerojson_extract(model, '$.providerID') = 'github-copilot'sinceMsfiltering, compaction detectionsessiontable andtime_createdcolumn onmessageContext
OpenCode 1.16.0 introduced session-level token tracking for GitHub Copilot (token-based billing). For some Copilot sessions, token data may only exist on the
sessiontable (tokens_input, tokens_output, etc.) rather than in per-messagedataJSON. The tool previously only queriedFROM message, returning zero usage for these sessions.Resolves #87
Test plan
npx vitest run— all 144 tests passnpx tsc --noEmit— clean