Repository navigation
fix(core): fold title usage into session stats and record generate usage (fixes #46371) - #46544
greedyivan wants to merge 1 commit into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #46371
Type of change
What does this PR do?
Two classes of LLM calls are billed by the provider but absent from session cost:
UsageRecordedwithsource: "title"(feat(cli): add shareable stats command #43653), but the stats aggregation only foldssource = 'compaction', so these events are recorded and never aggregated. In the billing reconciliation behind Hidden LLM calls (session title / message summaries) are billed by the provider but absent from session cost #46371 (204 billed requests vs 203 accounted), the one unaccounted request was the title call./generate— documented behavior (session.generate: solidify contract and capabilities #38558, "Durability: no … usage", non-goals "unless we explicitly promote them"). This PR proposes that promotion: the call is billed, so cost reconciliation built on session data can't see it. Only aUsageRecordedevent is added; the session transcript stays untouched.Changes: stats filter
'compaction' | 'title' | 'generate';"generate"added to theUsageRecordedsource literals (additive, internal event, not in the public manifest); the generate node emits the event afterllm.generatereturns, via the same bus the title generator uses.The sidebar and
/api/session/statsneed no changes: the projector already applies allUsageRecordedevents unfiltered, and the stats response shape is unchanged.The stats-side diagnosis is @argszero's (see the issue). Contract-wise this answers part of open question 4 in #38558 in the direction of "recorded, not returned".
How did you verify your code works?
source: "generate"event is recorded and folded into totals and projection; encode roundtrip of the new literalpackages/coresuite green locally (4100 tests; the only failures are two known environment-dependent Worktree tests unrelated to this change)Screenshots / recordings
n/a (no UI change)
Checklist