fix(caching): honor prompt_caching.cache_ttl disable in config (salvage #33555) - #76015
Merged
kshitijk4poor merged 1 commit intoAug 1, 2026
Conversation
kshitijk4poor
enabled auto-merge (rebase)
August 1, 2026 08:12
Setting prompt_caching.cache_ttl to a falsy value (false, null, off, disabled, no, none) now fully disables prompt caching instead of being silently ignored. The disable propagates through anthropic_prompt_cache_policy() (early return when _cache_disabled flag is set) and restore_primary_runtime() (override after snapshot restore), so it survives /model switches and fallback re-derivation — the gap that caused NousResearch#56105 to be reverted in NousResearch#56126. Salvage of NousResearch#33555 by @BB-light, with model-switch/fallback survival gap fixed on top. Co-authored-by: BB-light <BB-light@users.noreply.github.com>
kshitijk4poor
force-pushed
the
salvage/33555-cache-ttl-disable
branch
from
August 1, 2026 08:38
d0a114d to
3fad25f
Compare
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.
Summary
Setting
prompt_caching.cache_ttlto a falsy value (false,null,"off","disabled","no","none") now fully disables prompt caching instead of being silently ignored.Changes
agent/agent_init.py: Addedelifbranch after existing"5m"/"1h"check that catches falsy values, sets_use_prompt_caching = False,_cache_ttl = None, and_cache_disabled = Trueagent/agent_runtime_helpers.py:anthropic_prompt_cache_policy()early-returns(False, False)when_cache_disabledis set — ensures disable survives/modelswitch and fallback re-derivationagent/agent_runtime_helpers.py:restore_primary_runtime()overrides cached_use_prompt_cachingwhen_cache_disabledis set — ensures disable survives runtime snapshot restorationhermes_cli/config_defaults.py: Updated inline commenttests/run_agent/test_run_agent.py: 8 new tests (7 parametrized falsy variants + 1 policy re-derivation survival test)The gap in the original PR (#33555)
The contributor's fix only set
_use_prompt_caching = Falseininit_agent. Three other code paths re-derive_use_prompt_cachingfromanthropic_prompt_cache_policy()after init:restore_primary_runtime(),_switch_to_provider(), and fallback activation. All would override the disable. This was the same gap that caused #56105 to be reverted in #56126. This salvage fixes it by gating the policy function itself on the_cache_disabledflag.Validation
cache_ttl: falseat init/modelswitch after disableSalvage of #33555 by @BB-light. Closes #33555.