anomalyco / anomalyco/opencode
Hidden LLM calls (session title / message summaries) are billed by the provider but absent from session cost
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Reviving #7175 (auto-closed as not planned after 90 days of inactivity) with billing-level evidence, since the gap is still live and measurable.
What happens: title generation, summary titles, and body summaries make real LLM calls through LLM.stream() but never persist token usage or cost on any message (confirmed empirically in #7175 by @fedealliani and still the case on current versions).
Billing-level confirmation. Reconciling one day of usage against the provider's invoice export (SQLite walk over root + subagent sessions vs billed tokens):
- Billed requests: 204. Sessions account for 203 (root + 3 subagents,
cache_readmatched to the exact token). - The 204th request is the session-title generation call: 752 input / 498 output tokens, billed, present in no session — it ran at session creation (
agent=title, small=truein the logs), before the first user message.
Individually tiny (~$0.003 on a deepseek-v4-pro session), but it's a systematic understatement: every session pays it, and it compounds with the subagent rollup gap (#45417) — for cost analytics on top of opencode data (our use case, and fedealliani's multi-tenant one) any unrecorded call breaks reconciliation.
Suggested direction (happy to send a PR): persist usage/cost for hidden LLM calls — either as a synthetic session-scoped record or accumulated into session.cost with the message count untouched. The usage numbers are already available at the call site since LLM.stream() receives the provider's usage payload.
Related: #45417 (subagent cost rollup — same reconciliation turned up both gaps).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the hidden title and summary call sites into LLM.stream(), where provider usage is already available, and inspect how session.cost and message usage are persisted. Compare the session-title request with the billing evidence and related issue #45417; done means every hidden LLM call is represented in session cost or a synthetic session-scoped record without changing message counts, with reconciliation covering billed tokens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100