Add optional OpenRouter response caching headers#19112
Closed
Julientalbot wants to merge 1 commit into
Closed
Conversation
Collaborator
|
Likely duplicate of #18921 — same feature (opt-in OpenRouter response caching via headers/env vars). Both add X-OpenRouter-Cache headers behind config/env opt-in. |
Contributor
Author
|
@alt-glitch likely duplicate you are right, sorry ! |
Collaborator
|
Merged via PR #19132 which consolidates all three OpenRouter response caching PRs (#18921, #19112, #19132). Your config.yaml integration approach was the foundation — the final implementation uses config.yaml as the primary surface with env var overrides on top, plus cache status logging. Thanks for the comprehensive work @Julientalbot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
OpenRouter announced beta support for response caching:
https://openrouter.ai/announcements/response-caching
This lets clients opt into caching completed responses for identical OpenRouter requests. Hermes already sends OpenRouter attribution headers; this PR adds a small, explicit opt-in path for the new cache headers without changing default behaviour.
The intent is to make response caching available for workflows where repeat requests are expected and safe, such as retries, test runs, cron/batch jobs, and stable auxiliary tasks. It stays disabled by default because live agent conversations and fresh tool-context workflows should not silently change transport behaviour.
Summary
Config
Default remains disabled:
To enable:
Environment overrides:
Tests
python -m pytest tests/agent/test_openrouter_headers.py tests/agent/test_auxiliary_client.py tests/run_agent/test_run_agent.py -qpython -m pytest tests/hermes_cli/test_config.py tests/hermes_cli/test_config_validation.py tests/hermes_cli/test_config_drift.py -qpython -m py_compile agent/openrouter_headers.py agent/auxiliary_client.py run_agent.py hermes_cli/config.pygit diff --check