Repository navigation
Description
Client or integration
Kilo Code through OpenCodex
Area
Provider adapter / usage reporting
Summary
While routing Kilo Code requests to Ollama Cloud's DeepSeek V4.1 Flash through OpenCodex, the Usage dashboard consistently reports 0 cached input tokens. A concrete source-level cause is that the ollama-native adapter's usageFromNative() currently maps prompt_eval_count and eval_count but drops the native prompt_eval_cached_count response field entirely. If upstream returns nonzero cached tokens, those counts cannot reach OpenCodex usage accounting through this function.
This issue concerns missing accounting for a native response field, not a claim that Ollama Cloud necessarily served cached tokens in the observed session. We have not captured a raw Ollama Cloud response proving a nonzero count.
Reproduction
Deterministic source-level reproduction (no account or live API call required):
-
Open
src/adapters/ollama-native.tson the current default branch and locateusageFromNative(). -
Trace its handling of a syntactically valid Ollama native final response usage payload with these fields:
{ "prompt_eval_count": 2000, "prompt_eval_cached_count": 1500, "eval_count": 100 } -
The function reads
prompt_eval_countandeval_count, then returns only{ inputTokens: 2000, outputTokens: 100 }. There is no cached-token field in the returnedOcxUsageobject. -
Thus the native cached-token count of 1500, if supplied upstream, is lost before downstream usage recording and dashboard accounting.
Actual code:
function usageFromNative(value: JsonRecord | undefined): OcxUsage | undefined {
if (!value) return undefined;
const input = isFiniteNonNegativeInteger(value.prompt_eval_count) ? value.prompt_eval_count : undefined;
const output = isFiniteNonNegativeInteger(value.eval_count) ? value.eval_count : undefined;
if (input === undefined && output === undefined) return undefined;
return { inputTokens: input ?? 0, outputTokens: output ?? 0 };
}Observed UI workflow:
- Configure
ollama-cloudin OCX using theollama-nativeadapter. - Select
ollama-cloud/deepseek-v4.1-flashin Kilo Code through OCX. - Make repeated coding turns within the same session.
- Inspect OCX's Usage dashboard; cached input tokens remain 0.
The input above is a synthetic parser testcase, not a captured upstream response. A regression test could feed this payload through the native adapter's streamed or nonstreamed final-response processing and assert that the resulting usage event carries the cache-read token count.
Expected behavior
- Parse
prompt_eval_cached_countwhen present in the Ollama native response. - Map it to OCX's canonical cache-read usage field, retaining correct total input accounting.
- Surface cache-read tokens in the ledger/dashboard (and distinguish unavailable cache information from an explicit zero when possible).
Actual behavior
The parser ignores prompt_eval_cached_count entirely, and a user sees 0 cached tokens for Ollama Cloud sessions.
Version
OpenCodex v2.96.0 (latest stable release as of 2026-11-02, per user confirmation and official release). Source-level reproduction is verified against the default main branch corresponding to this release.
Operating system
Cross-platform source-level defect (pure TypeScript mapping; not dependent on host OS). The host operating system and version for the observed Kilo Code session were not captured.
Provider and model
Ollama Cloud, native /api/chat adapter, DeepSeek V4.1 Flash.
Additional context
Related but potentially distinct upstream Ollama issue: ollama/ollama#15758 (Ollama Cloud sometimes reports zero cached tokens). Even if the upstream service omits this metric for some requests, OCX should not discard it when supplied.
Checks
- Searched existing issues for Ollama cached-token accounting; no exact duplicate found.
- Reproduced the field omission by source inspection (synthetic input; not a live API assertion).
- No credentials, tokens, or private user data included.
Activity
github-actions commentedon Nov 2, 2026
Automated translation bookkeeping — detected language: English.
github-actions commentedon Nov 2, 2026
Issue reopened
The report now contains the information required by the automated check. Thanks for updating it.
fix(ollama): report prompt_eval_cached_count as cache-read input (#8101…
lidge-jun commentedon Nov 3, 2026
Fixed on
devby #8124 (9c25b49): Ollama native usage ignored prompt_eval_cached_count. It ships in the next release; please reopen if it still reproduces after updating.