openclaw - 💡(How to fix) Fix Session telemetry: cacheWrite field always 0 across all sessions despite active cacheRead

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

For our purposes:

  • Cache hit ratio calculations that include cacheWrite in the denominator are equivalent to ratios that exclude it (because cacheWrite=0 always).
  • Cost analysis based on "how much was written to fill the cache" is not derivable from this source.
  • Future per-agent cost dashboards or alerts based on cache-write activity would need an alternative source.

Code Example

Fleet totals:
  cacheRead:    16,237,952 tokens
  cacheWrite:   0 tokens (fleet-wide)
  inputTokens:  2,580,583 tokens
  outputTokens: 129,256 tokens

Cache hit ratio: 86.3% (cacheRead / (input + cacheRead + cacheWrite))

Per-agent (sample):
  mason-vale: 8 sessions, cacheRead=4,958,720, cacheWrite=0
  victor-kane: 11 sessions, cacheRead=4,028,800, cacheWrite=0
  trent: 7 sessions, cacheRead=3,325,440, cacheWrite=0
  sierra-knox: 3 sessions, cacheRead=3,324,416, cacheWrite=0
  evelyn-cross: 1 session, cacheRead=534,016, cacheWrite=0

---

{
  "modelProvider": "openai-codex",
  "model": "gpt-5.5",
  "cacheRead": 118272,
  "cacheWrite": 0,
  "inputTokens": 1234,
  "outputTokens": 567,
  "totalTokensFresh": ...,
  ...
}

---

# Across any active OpenClaw fleet:
python3 -c '
import json, glob
for sess_file in glob.glob("/home/openclawops/.openclaw/agents/*/sessions/sessions.json"):
    d = json.load(open(sess_file))
    for k, sess in d.items():
        if isinstance(sess, dict) and (sess.get("cacheRead", 0) or 0) > 0:
            print(sess_file.split("/agents/")[1].split("/")[0], k, "cacheRead=", sess.get("cacheRead"), "cacheWrite=", sess.get("cacheWrite"))
'
RAW_BUFFERClick to expand / collapse

Observation

Across a 28-agent fleet running OpenClaw 2026.5.7, every session entry in ~/.openclaw/agents/<agent>/sessions/sessions.json reports cacheWrite: 0 while cacheRead is populated normally.

Probe results from a 34-session snapshot (2026-05-12):

Fleet totals:
  cacheRead:    16,237,952 tokens
  cacheWrite:   0 tokens (fleet-wide)
  inputTokens:  2,580,583 tokens
  outputTokens: 129,256 tokens

Cache hit ratio: 86.3% (cacheRead / (input + cacheRead + cacheWrite))

Per-agent (sample):
  mason-vale: 8 sessions, cacheRead=4,958,720, cacheWrite=0
  victor-kane: 11 sessions, cacheRead=4,028,800, cacheWrite=0
  trent: 7 sessions, cacheRead=3,325,440, cacheWrite=0
  sierra-knox: 3 sessions, cacheRead=3,324,416, cacheWrite=0
  evelyn-cross: 1 session, cacheRead=534,016, cacheWrite=0

Every single one of 34 active sessions across providers openai-codex/gpt-5.5, ollama/*, etc. reports cacheWrite=0. This is suspicious — if cacheRead is meaningful, something has to write to cache at session boundaries.

Sessions schema (per session entry)

{
  "modelProvider": "openai-codex",
  "model": "gpt-5.5",
  "cacheRead": 118272,
  "cacheWrite": 0,
  "inputTokens": 1234,
  "outputTokens": 567,
  "totalTokensFresh": ...,
  ...
}

The cacheWrite field exists in the schema but is never populated to a non-zero value.

Hypotheses

Several explanations are possible — filing this issue to ask which is the intended behavior:

  1. Runtime non-emission bug: gateway never populates this field at all. Sessions inherit cache from prior sessions but the write-side accounting is omitted.
  2. Provider-specific suppression: openai-codex / ollama / openrouter providers don't report cacheWrite back to the gateway, so the gateway can't set it.
  3. Schema field deprecated: the field is left in the schema for compatibility but no code path updates it.
  4. All cache writes happen via a separate code path: maybe cacheWrite is tracked in a different telemetry store and sessions.json mirrors only the read-side.

Operational impact

For our purposes:

  • Cache hit ratio calculations that include cacheWrite in the denominator are equivalent to ratios that exclude it (because cacheWrite=0 always).
  • Cost analysis based on "how much was written to fill the cache" is not derivable from this source.
  • Future per-agent cost dashboards or alerts based on cache-write activity would need an alternative source.

Related

  • #56523 — Set cacheRead & cacheWrite to default to zero instead of not reporting — different layer (otel plugin cost metrics, not session telemetry).
  • #62475 — feat: prompt cache keep-warm pings to prevent TTL expiry between turns — related cache lifecycle concern.

Repro

# Across any active OpenClaw fleet:
python3 -c '
import json, glob
for sess_file in glob.glob("/home/openclawops/.openclaw/agents/*/sessions/sessions.json"):
    d = json.load(open(sess_file))
    for k, sess in d.items():
        if isinstance(sess, dict) and (sess.get("cacheRead", 0) or 0) > 0:
            print(sess_file.split("/agents/")[1].split("/")[0], k, "cacheRead=", sess.get("cacheRead"), "cacheWrite=", sess.get("cacheWrite"))
'

Expect: every output line shows cacheWrite=0 despite cacheRead>0.

Version

OpenClaw 2026.5.7 (eeef486), 2026-05-07 release. 34 active sessions, mixed providers (openai-codex/gpt-5.5 dominant, ollama/kimi-k2.6, ollama/qwen3-coder-next, openrouter/xiaomi-mimo-v2-pro, others).

Ask

Confirm: is cacheWrite=0 the intended runtime behavior, or is this a non-emission bug? If the former, document the field as informational-only. If the latter, point to the code path that should populate it.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING