Skip to content

[Bug]: Ollama native usage parser ignores prompt_eval_cached_count (cache shows 0) #8101

Closed

Description

@imranshaiedi-byte

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):

  1. Open src/adapters/ollama-native.ts on the current default branch and locate usageFromNative().

  2. 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
    }
  3. The function reads prompt_eval_count and eval_count, then returns only { inputTokens: 2000, outputTokens: 100 }. There is no cached-token field in the returned OcxUsage object.

  4. 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:

  1. Configure ollama-cloud in OCX using the ollama-native adapter.
  2. Select ollama-cloud/deepseek-v4.1-flash in Kilo Code through OCX.
  3. Make repeated coding turns within the same session.
  4. 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_count when 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

  1. github-actions commented on Nov 2, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  2. github-actions commented on Nov 2, 2026

    @github-actions
    Contributor

    Issue reopened

    The report now contains the information required by the automated check. Thanks for updating it.

  3. lidge-jun commented on Nov 3, 2026

    @lidge-jun
    Owner

    Fixed on dev by #8124 (9c25b49): Ollama native usage ignored prompt_eval_cached_count. It ships in the next release; please reopen if it still reproduces after updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions