Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4fc60ac. Configure here.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR introduces a new feature for token usage reporting, adding new runtime behavior (event emission), session state tracking, and provider API integration. New capabilities introducing user-facing behavior warrant human review. You can add or adjust custom eligibility rules. Learn more. |
|
Note 🤖 GPT-5.6 Sol responding on behalf of Theo We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together. We are keeping OPEN #7072 as the review path for OpenCode context-window usage. The focused adapter test here remains useful reference. If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed. |

OpenCode sessions never report token usage, so the context window meter (used/max + percentage) that the composer shows for Claude and Codex sessions stays hidden for OpenCode threads.
The adapter now normalizes the token usage from each completed assistant message (
message.updated) into athread.token-usage.updatedevent, and the existing ingestion pipeline and meter handle the rest.totalwhen reported, otherwise input + output + cached input/write), capped at the model's context window when known.client.provider.list(), resolved lazily on the first completed message and cached for the session.Generated with Qwen3.8-27B (LM Studio) via opencode.
Note
Low Risk
Additive adapter behavior on the existing event path; failures on provider.list only omit max/cap, and malformed token shapes are handled defensively.
Overview
OpenCode threads can now drive the composer context window meter by emitting
thread.token-usage.updatedwhen assistant messages finish, matching what Claude and Codex adapters already do.On completed assistant
message.updatedevents (time.completedset), the adapter maps OpenCode’stokenspayload into aThreadTokenUsageSnapshotvianormalizeOpenCodeTokenUsage, using the same total formula as OpenCode’s compaction check (totalwhen present, else input + output + cache read/write), capsusedTokensat the model limit when known, and setscompactsAutomatically: true.provider.listis called once per session (best-effort) to cache each model’s context window; emissions are one per message id, partial in-flight updates are ignored, andmessage.removedclears the dedupe set. Missing or zero token data is skipped without breaking the event pump.Reviewed by Cursor Bugbot for commit 7592599. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Emit
thread.token-usage.updatedfor completed OpenCode assistant messagesnormalizeOpenCodeTokenUsageandopenCodeMessageTokensTotalhelpers in OpenCodeAdapter.ts to compute token totals and build aThreadTokenUsageSnapshotfromAssistantMessage.tokensclient.provider.list(cached per session inmodelContextWindowById), normalizes usage, and emits athread.token-usage.updatedevent once per message usingtokenUsageEmittedMessageIdsmessage.removedclears the emission guard for that messageresolveModelContextWindowcallsclient.provider.listonce per session on first need; if that call fails or returns unexpected data,maxTokenswill be absent from the emitted snapshotMacroscope summarized 7592599.