Repository navigation
Description
Bug: OpenRouter Anthropic cache markers (cacheWrite) stopped advancing after v2026.6.10 upgrade
Summary
After upgrading from v2026.5.3-1 to v2026.6.10, cacheWrite dropped to zero on every turn for openrouter/anthropic/claude-sonnet-4.6 sessions. Prior to the upgrade, the cache checkpoint was actively advancing through conversation history (cacheWrite growing from ~13K → 94K per turn), enabling cacheRead hits of 60–90K per call. After v2026.6.10, cacheWrite is consistently 0 and cacheRead is capped at the system prompt prefix (~32–35K).
Environment
- OpenClaw version: 2026.6.10 (regression), 2026.5.3-1 (working)
- Provider: openrouter
- Model: anthropic/claude-sonnet-4.6
- modelApi: openai-completions
- Config:
cacheRetention: "long",contextPruning: { mode: "cache-ttl", ttl: "1h" }
Observed behavior (v2026.6.10)
Every model.completed trajectory entry shows:
lastCallUsage.cacheWrite = 0
lastCallUsage.cacheRead = 32–35k (system prompt prefix only)
This means the cache checkpoint never advances past the initial system prompt. The conversation history is never cached.
Expected behavior (v2026.5.3-1)
cacheWrite actively grew turn-by-turn as conversation history accumulated:
turn 1: cacheWrite=13k cacheRead=0
turn 2: cacheWrite=0 cacheRead=19k
turn 3: cacheWrite=22k cacheRead=0
...
turn N: cacheWrite=47k cacheRead=0
turn N+1: cacheWrite=0 cacheRead=73k
Peak per-call cacheRead reached 60–94K in active sessions. System prompt alone is ~32–35K, so the delta (25–60K) represents conversation history being cached.
Timeline
| Time (UTC) | Event |
|---|---|
| 2026-06-25 00:30 | v2026.6.10 installed |
| 2026-06-24 13:59 – 2026-06-25 01:56 | First session on v2026.6.10 — cacheWrite working (peak 35K write, 75K read) |
| 2026-06-25 02:04 | First session where cacheWrite = 0 — all subsequent sessions broken |
The regression did not trigger immediately on upgrade. The first 12-hour session on v2026.6.10 had cacheWrite working normally. Starting with the next session at 02:04 UTC, cacheWrite has been zero on every session since.
Data comparison
Last working session (v2026.6.10, session e8f80c5f, ended 2026-06-25T01:56 UTC)
model.completed [selected turns]:
cacheWrite=27k cacheRead=0
cacheWrite=0 cacheRead=27k
cacheWrite=35k cacheRead=0
cacheWrite=0 cacheRead=40k
cacheWrite=9k cacheRead=71k
cacheWrite=0 cacheRead=75k ← peak
First broken session (v2026.6.10, session 408cd396, started 2026-06-25T02:04 UTC)
model.completed [all turns]:
cacheWrite=0 cacheRead=32k
cacheWrite=0 cacheRead=32k
cacheWrite=0 cacheRead=32k
[repeats for all turns]
Both sessions: same version, same model, same config, same provider. Only difference is session start time.
Code investigation
createOpenRouterSystemCacheWrapper in src/llm/providers/stream-wrappers/proxy.ts calls applyAnthropicEphemeralCacheControlMarkers which iterates over messages and applies cache_control to system/developer-role messages. This mechanism was what enabled cacheWrite growth in v2026.5.3-1.
In v2026.6.10, cacheWrite = 0 on every call despite the wrapper being invoked, suggesting either:
- The message structure passed to the wrapper no longer contains
system/developer-role messages (possible change in how messages are serialized for the OpenRouter openai-completions transport), or - A session state migration that ran after the first 6.10 session altered something that affects the wrapper's behavior
PR #85104 (fast-talks auto mode) touched extra-params.ts and the persistent cache schema — may be relevant.
Workaround
None found. Downgrading to v2026.5.3-1 is expected to restore behavior.
Impact
Significant cost regression. Without conversation-level caching, long sessions pay full input price on every turn for all accumulated context above the ~32K system prompt checkpoint.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 26, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 26, 2026, 1:45 AM ET / 05:45 UTC.
Summary
Keep open. The report has detailed production cache telemetry for a fresh v2026.6.10 regression, current main still has the same OpenRouter Anthropic cache-control decision surfaces, and the related open session-affinity/TTL work does not prove this specific cacheWrite regression is fixed.
Reproducibility: no. The reporter provides strong production telemetry, but this review did not run a live OpenRouter Anthropic session or capture the outgoing request payload, so the current-main failing path is not yet reproduced with high confidence.
Ways to help us reproduce this
Next step
Needs maintainer/API investigation and live OpenRouter cache proof before choosing a safe repair path.
Review details
Best possible solution:
Confirm the outgoing v2026.6.10 versus current-main OpenRouter Anthropic payload and usage behavior, then fix the provider-owned OpenRouter/Anthropic cache shaping path with focused regression coverage and live cache proof.
Do we have a high-confidence way to reproduce the issue?
No. The reporter provides strong production telemetry, but this review did not run a live OpenRouter Anthropic session or capture the outgoing request payload, so the current-main failing path is not yet reproduced with high confidence.
Is this the best way to solve the issue?
Unclear. The fix should likely stay in the OpenRouter/provider stream shaping boundary, but maintainers need to determine whether the best repair is cache_control placement, session affinity, TTL handling, or an extra-param/cache interaction.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 4fc504d321b6.
Label changes
Label changes:
P1: This is a newly reported regression in a paid provider path that can materially increase cost for long real sessions after upgrade.impact:auth-provider: The issue centers on OpenRouter provider request shaping, Anthropic model behavior, and cache usage accounting.impact:other: The concrete user impact is a provider-side cost and performance regression, which is meaningful but outside the more specific owned labels.issue-rating: 🦐 gold shrimp: Current issue advisory state selects this label.clawsweeper:needs-info: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.clawsweeper:needs-product-decision: Current issue advisory state selects this label.Label justifications:
P1: This is a newly reported regression in a paid provider path that can materially increase cost for long real sessions after upgrade.impact:auth-provider: The issue centers on OpenRouter provider request shaping, Anthropic model behavior, and cache usage accounting.impact:other: The concrete user impact is a provider-side cost and performance regression, which is meaningful but outside the more specific owned labels.Evidence reviewed
What I checked:
src/llm/providers/stream-wrappers/proxy.ts:134, 4fc504d321b6)src/llm/providers/openai-completions.ts:810, 4fc504d321b6)docs/reference/prompt-caching.md. (docs/reference/prompt-caching.md:126, 4fc504d321b6)src/llm/providers/stream-wrappers/proxy.ts:134, bead84f0ee6e)Likely related people:
src/llm/providers/stream-wrappers/proxy.ts,src/llm/providers/openai-completions.ts,extensions/openrouter/stream.ts)src/llm/providers/stream-wrappers/proxy.ts,src/llm/providers/openai-completions.ts,extensions/openrouter/stream.ts)extensions/openrouter/index.ts,src/agents/pi-embedded-runner/extra-params.ts,src/agents/pi-embedded-runner/proxy-stream-wrappers.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.FriendofTob commentedon Jun 26, 2026
Correction to timeline
After closer inspection of the trajectory data, the regression is immediate upon upgrade, not delayed.
The session spans both before and after the upgrade:
Every turn from onward: . The regression is immediate and correlated directly with the gateway restart after the install.
The original issue's claim that the first 6.10 session worked is incorrect — the earlier turns (13:59–16:24) were still running on the pre-upgrade gateway. The break happens the moment the upgraded gateway serves its first request.
FriendofTob commentedon Jun 26, 2026
Correction: metric clarification + accurate timeline + cost impact
Apologies for the earlier inaccurate comment. Here is the verified picture.
What the 140K actually was
The pre-upgrade cache state was captured from the OpenClaw
/statuscard at Jun 25 00:20 UTC:This is the session-level accumulated cached token count shown in
/status— not a per-calllastCallUsage.cacheReadvalue. At 99.7% cache hit rate, the full conversation history was being cached and served on every call.Accurate timeline
/statusshows Cached=140,175 (99.7%) — working correctlyCached~32–35K regardless of session lengthWhat changed
Before upgrade: Conversation history was being added to the prompt cache incrementally. Session cached tokens grew as the conversation grew, reaching 140K+ at 99.7% hit rate.
After upgrade (immediate):
cacheWrite = 0on every call. Only the static system prompt (~32–35K) is cached. Conversation history is never written to cache.Cost impact
Using the same 140,537-token session as a baseline (Sonnet input: ~$3/MTok, cached: ~$0.30/MTok):
~7.4x cost increase (~640% more expensive) for an identical session. This compounds badly on long sessions — the longer the conversation, the more history is paying full uncached price on every turn.
Config (unchanged across upgrade)
Config was not changed. Regression is entirely in v2026.6.10.
openclaw-barnacle commentedon Jul 11, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
openclaw-barnacle commentedon Jul 19, 2026
Closing due to inactivity.
If this is still an issue, please retry on the latest OpenClaw release and share updated details.
If you are absolutely sure it still happens on the latest release, open a new issue with fresh steps to reproduce.