Repository navigation
feat(core): record title and compaction usage in session totals - #37441
Merged
Merged
Conversation
rekram1-node
force-pushed
the
side-inference-usage
branch
from
July 17, 2026 04:34
fb9915d to
5c9a90e
Compare
rekram1-node
force-pushed
the
side-inference-usage
branch
from
July 17, 2026 05:08
5c9a90e to
0c9352d
Compare
This was referenced Jul 19, 2026
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
1 task done
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.
Problem
Title generation and compaction make billable LLM requests, but their reported tokens and cost were discarded. Session totals only included normal assistant steps. (V1 counted compaction usage through step-finish parts but silently dropped title usage; V2 dropped both.)
Implementation
session/usage.ts(SessionUsage.tokens,calculateCost,record,add), deduplicating the copies inrunner/llm.tsandpublish-llm-event.ts.session.usage.recordedevent for side inferences, mirroring howsession.step.endedcarries usage for normal steps. Durability is required: session totals are a projection of the durable log and are rebuilt through replay/sync, so a direct write would be lost.applyUsagefold and wired it into the aggregatesession.usage.updatedbroadcast.SessionEvent.DurableDefinitions(replay/sync manifest and the experimental durable session log contract) but excluded fromSessionEvent.Definitions, so it never reaches the public event stream or manifest. Clients observe usage only through the aggregatesession.usage.updated.SessionUsageRecordedis absent fromV2Eventand present only in the durable-logSessionEventDurableunion.Testing
EventManifest.Durable, absent fromDefinitions/ServerDefinitions/Latest.