mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:00:44 +00:00
feat(openrouter): add opt-in response caching
Adds opt-in OpenRouter response caching params, preserves alias precedence across config scopes, and documents the behavior.\n\nVerification:\n- pnpm test:serial src/agents/pi-embedded-runner/proxy-stream-wrappers.test.ts src/agents/pi-embedded-runner-extraparams-openrouter.test.ts -- --reporter=verbose\n- pnpm exec oxfmt --check --threads=1 src/agents/pi-embedded-runner/proxy-stream-wrappers.ts src/plugin-sdk/provider-stream.ts src/agents/pi-embedded-runner/proxy-stream-wrappers.test.ts src/agents/pi-embedded-runner-extraparams-openrouter.test.ts docs/providers/openrouter.md CHANGELOG.md\n- git diff --check\n- Testbox tbx_01kqr4dakpsk9rswz9pem49nz0: pnpm check:changed (https://github.com/openclaw/openclaw/actions/runs/25294515012)
This commit is contained in:
@@ -153,6 +153,39 @@ does **not** inject those OpenRouter-specific headers or Anthropic cache markers
|
||||
## Advanced configuration
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="Response caching">
|
||||
OpenRouter response caching is opt-in. Enable it per OpenRouter model with
|
||||
model params:
|
||||
|
||||
```json5
|
||||
{
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
"openrouter/auto": {
|
||||
params: {
|
||||
responseCache: true,
|
||||
responseCacheTtlSeconds: 300,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
OpenClaw sends `X-OpenRouter-Cache: true` and, when configured,
|
||||
`X-OpenRouter-Cache-TTL`. `responseCacheClear: true` forces a refresh for
|
||||
the current request and stores the replacement response. Snake_case aliases
|
||||
(`response_cache`, `response_cache_ttl_seconds`, and
|
||||
`response_cache_clear`) are also accepted.
|
||||
|
||||
This is separate from provider prompt caching and from OpenRouter's
|
||||
Anthropic `cache_control` markers. It is only applied on verified
|
||||
`openrouter.ai` routes, not custom proxy base URLs.
|
||||
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Anthropic cache markers">
|
||||
On verified OpenRouter routes, Anthropic model refs keep the
|
||||
OpenRouter-specific Anthropic `cache_control` markers that OpenClaw uses for
|
||||
|
||||
Reference in New Issue
Block a user