fix: include cached tokens in opencode prompt_tokens calculation - #9
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughOpenCode OTLP token field normalization was refined: ChangesOpenCode OTLP Token Normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
prompt_tokenscalculation to includecached_tokens, matching Claude's handler patternWhy / Context
The OpenCode OTLP parser was setting
prompt_tokensto onlyinput_tokens(the uncached portion), never addingcached_tokens. When a provider returnedinput=200, cache_read=20000, the system recordedprompt_tokens=200instead of20200. The Claude handler already does this correctly.How It Works
Changed
src/otlp.py:365fromint(input_tokens) if input_tokens is not None else Noneto(int(input_tokens or 0)) + (int(cached or 0)). The cost calculator already handles the split:uncached = max(prompt - cached, 0)prices uncached at input rate and cached at cache_read rate.Testing
uv run python -m pytest -q: 477 passed, 1 skippedRisk Areas
prompt_tokensreflects the total tokens the model processedReview
AGENTS.mdand.agents/commands/llm-tracker.md: yes