openclaw - 💡(How to fix) Fix [Feature]: Add `supportsPromptCacheKey` to Mistral transport compat patch

Official PRs (…)
ON THIS PAGE

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…

Mistral's API supports prompt caching via a prompt_cache_key request field — cached tokens are billed at 10% of the standard input price. However, OpenClaw's Mistral provider compat layer (MISTRAL_MODEL_TRANSPORT_PATCH) does not include supportsPromptCacheKey: true, so the transport layer never injects prompt_cache_key into Mistral requests, and no caching occurs.

Root Cause

Because supportsPromptCacheKey is absent from the Mistral patch, this branch never fires. Mistral models receive no prompt_cache_key, and usage.prompt_tokens_details.cached_tokens always returns 0.

Fix Action

Fix / Workaround

Mistral's API supports prompt caching via a prompt_cache_key request field — cached tokens are billed at 10% of the standard input price. However, OpenClaw's Mistral provider compat layer (MISTRAL_MODEL_TRANSPORT_PATCH) does not include supportsPromptCacheKey: true, so the transport layer never injects prompt_cache_key into Mistral requests, and no caching occurs.

MISTRAL_MODEL_TRANSPORT_PATCH in extensions/mistral currently contains:

const MISTRAL_MODEL_TRANSPORT_PATCH = {
  supportsStore: false,
  maxTokensField: "max_tokens"
};

Code Example

const MISTRAL_MODEL_TRANSPORT_PATCH = {
  supportsStore: false,
  maxTokensField: "max_tokens"
};

---

if (compat.supportsPromptCacheKey && cacheRetention !== "none" && options?.sessionId)
  params.prompt_cache_key = options.sessionId;

---

const MISTRAL_MODEL_TRANSPORT_PATCH = {
  supportsStore: false,
  maxTokensField: "max_tokens",
  supportsPromptCacheKey: true   // Mistral supports prompt_cache_key; cached tokens billed at 10% of input price
};
RAW_BUFFERClick to expand / collapse

Summary

Mistral's API supports prompt caching via a prompt_cache_key request field — cached tokens are billed at 10% of the standard input price. However, OpenClaw's Mistral provider compat layer (MISTRAL_MODEL_TRANSPORT_PATCH) does not include supportsPromptCacheKey: true, so the transport layer never injects prompt_cache_key into Mistral requests, and no caching occurs.

Current behaviour

MISTRAL_MODEL_TRANSPORT_PATCH in extensions/mistral currently contains:

const MISTRAL_MODEL_TRANSPORT_PATCH = {
  supportsStore: false,
  maxTokensField: "max_tokens"
};

The transport layer in openai-transport-stream gates prompt_cache_key injection on compat.supportsPromptCacheKey === true:

if (compat.supportsPromptCacheKey && cacheRetention !== "none" && options?.sessionId)
  params.prompt_cache_key = options.sessionId;

Because supportsPromptCacheKey is absent from the Mistral patch, this branch never fires. Mistral models receive no prompt_cache_key, and usage.prompt_tokens_details.cached_tokens always returns 0.

This affects all Mistral models routed through the api.mistral.ai endpoint: mistral-medium-latest, mistral-large-latest, mistral-small-latest, etc.

Expected behaviour

When a user sets cacheRetention on a Mistral model (or when a non-none retention default applies), OpenClaw should pass prompt_cache_key with the session ID on Mistral chat completion requests, matching the behaviour already implemented for other providers.

Proposed fix

Add supportsPromptCacheKey: true to MISTRAL_MODEL_TRANSPORT_PATCH:

const MISTRAL_MODEL_TRANSPORT_PATCH = {
  supportsStore: false,
  maxTokensField: "max_tokens",
  supportsPromptCacheKey: true   // Mistral supports prompt_cache_key; cached tokens billed at 10% of input price
};

Mistral's caching docs confirm the field is supported and the billing model: https://docs.mistral.ai/studio-api/conversations/advanced/prompt-caching

Key implementation details from their docs:

  • prompt_cache_key is a top-level field on the chat completion request body
  • Cache blocks are 64 tokens minimum
  • Cached tokens reported in usage.prompt_tokens_details.cached_tokens
  • Cache hits are not guaranteed — they're best-effort on a shared prefix
  • Cached tokens billed at 10% of standard input price

Impact

For agent workloads that resend large, stable context (system prompts, workspace files, conversation history) on every turn — which is the standard OpenClaw heartbeat pattern — the savings are significant. A 1,000-token system prompt resent across 50 turns per day at mistral-medium-latest prices ($0.40/M) costs ~$0.02/day uncached vs ~$0.002/day cached. At scale across multiple agents this adds up.

Verification

Confirmed by inspecting the installed dist on v2026.5.12:

  • MISTRAL_MODEL_TRANSPORT_PATCH in dist/api-CgjdAt3h.js — no supportsPromptCacheKey
  • Transport gate in dist/openai-transport-stream-BWwvx0MZ.js — confirmed gated on compat.supportsPromptCacheKey === true
  • Agent using mistral-medium-2508 as primary — cached_tokens consistently 0 in usage

Happy to test the fix if a build is available.

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

openclaw - 💡(How to fix) Fix [Feature]: Add `supportsPromptCacheKey` to Mistral transport compat patch