Repository navigation
feat: Add option to fold reasoning tokens into output - #142
Merged
Merged
Conversation
OpenCode V2 reports output with reasoning subtracted, while Claude Code includes thinking in output. OPENCODE_COMBINE_REASONING_TOKENS (or the combineReasoningTokens option) restores Claude Code semantics for the token.usage metric, api_request log, and LLM span completion count.
dialupdisaster
pushed a commit
that referenced
this pull request
Nov 10, 2026
🤖 I have created a release *beep* *boop* --- ## [2.1.0](v2.0.1...v2.1.0) (2026-11-10) ### Features * Add option to fold reasoning tokens into output ([#142](#142)) ([cb97f31](cb97f31)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Description
OpenCode V2 reports
tokens.outputwith reasoning subtracted (Usage.visibleOutputTokens = outputTokens - reasoningTokens), whereas Claude Code reports thinking tokens insideoutput. Dashboards and cost pipelines built for Claude Code telemetry therefore undercount OpenCode output, and anything summing every token type sees an unfamiliarreasoningtype.This adds an opt-in
combineReasoningTokensoption /OPENCODE_COMBINE_REASONING_TOKENSenv var. When enabled:token.usageemitstype=outputasoutput + reasoningand no longer emitstype=reasoning(so sums never double-count)api_requestlogoutput_tokensincludes reasoning;reasoning_tokensis omittedllm.token_count.completionincludes reasoning;llm.token_count.completion_details.reasoningstill carries the subset, per OpenInference semanticsllm.token_count.totalare unchanged (they already include reasoning once)Default behaviour is unchanged.
Type of change
Checklist
bun run lintpasses with no errorsbun run check:jsdoc-coveragepasses with no errorsbun run typecheckpasses with no errorsbun testpasses with no errorsRelated issues
None.
Additional context
Found while comparing OpenCode and Claude Code usage of the same Bedrock model in Datadog: OpenCode users had a
reasoningtoken type and loweroutputcounts than Claude Code users.