fix: include cached tokens in context window % calculation#48827
fix: include cached tokens in context window % calculation#48827yydonk wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When a session has a heavily-cached prompt, usage.input only contains the uncached new tokens (e.g. 2k out of a 200k window), causing contextPercent to show 0% even when the context is 76% full. The correct total input token count is: input (uncached) + cacheRead + cacheWrite Use that sum when computing the context % so the indicator reflects actual context window utilisation. Fixes openclaw#48640
Greptile SummaryThis PR fixes a display bug where the context-window percentage indicator showed ~0% during heavily-cached sessions. The Anthropic API only puts uncached tokens in
Confidence Score: 5/5
Last reviewed commit: 8541ed1 |
|
Closing this as implemented after Codex review. Current What I checked:
So I’m closing this as already implemented rather than keeping a duplicate issue open. Review notes: reviewed against 01bc49c88c0c; fix evidence: commit 8fade9df27a9. |
When a session has a heavily-cached prompt, usage.input only contains the uncached new tokens (e.g. 2k out of a 200k window), causing contextPercent to show 0% even when the context is 76% full.
The correct total input token count is:
input (uncached) + cacheRead + cacheWrite
Use that sum when computing the context % so the indicator reflects actual context window utilisation.
Fixes #48640
Summary
Describe the problem and fix in 2–5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write
None.Security Impact (required)
Yes/No)Yes/No)Yes/No)Yes/No)Yes/No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No)Yes/No)Yes/No)Failure Recovery (if this breaks)
Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.