openclaw - 💡(How to fix) Fix [Feature]: Forward session_id to OpenRouter for sticky routing & prompt caching

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…

Add a config option to automatically forward OpenClaw's internal session ID as session_id to the OpenRouter API, enabling sticky routing and prompt cache optimization.

Root Cause

Add a config option to automatically forward OpenClaw's internal session ID as session_id to the OpenRouter API, enabling sticky routing and prompt cache optimization.

RAW_BUFFERClick to expand / collapse

Summary

Add a config option to automatically forward OpenClaw's internal session ID as session_id to the OpenRouter API, enabling sticky routing and prompt cache optimization.

Problem to solve

OpenRouter supports session_id for sticky routing (routing all requests in a session to the same provider, maximizing prompt cache hits). OpenClaw already tracks session IDs internally but has no mechanism to forward them. The extra_body config only supports static values. This means every request misses prompt caching benefits.

Proposed solution

With a ~10-line change in resolveExtraParams() to read the active session ID and merge it into extra_body. Follows existing params precedence (global → provider → agent).

Alternatives considered

Static extra_body (defeats purpose), plugin hooks (no existing hook), custom proxy (over-engineered).

Impact

Affected: All OpenClaw operators using OpenRouter Severity: Blocks workflow optimization — missed prompt caches mean higher latency, higher cost, inconsistent provider behavior Frequency: Always — every request affected, 6-8 missed cache opportunities per typical conversation Consequence: 2-5x more input tokens than necessary; compounds across sub-agent pipelines

Evidence/examples

No response

Additional information

No response

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]: Forward session_id to OpenRouter for sticky routing & prompt caching