The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: address review feedback from #85512
kshitija0939901df65
diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.pyindex 35d9848496c..a9bf1a1d38d 100644--- a/agent/agent_runtime_helpers.py+++ b/agent/agent_runtime_helpers.py@@ -2756,6 +2756,13 @@ def switch_model(agent, new_model, new_provider, api_key='', base_url='', api_mo)# ── Re-evaluate prompt caching ──+ # Refresh the custom-provider snapshot from the config just loaded above+ # so the per-model ``prompt_caching`` capability lookup sees the same+ # live list the context-length resolution used — without this, a flag+ # added to config.yaml after session start is invisible to a /model+ # switch (the policy would read the stale init-time snapshot).+ if _sm_custom_providers is not None:+ agent._custom_providers = _sm_custom_providersagent._use_prompt_caching, agent._use_native_cache_layout = (agent._anthropic_prompt_cache_policy(provider=new_provider,diff --git a/tests/run_agent/test_anthropic_prompt_cache_policy.py b/tests/run_agent/test_anthropic_prompt_cache_policy.pyindex 9fe66cd4c36..018c6edc79e 100644--- a/tests/run_agent/test_anthropic_prompt_cache_policy.py+++ b/tests/run_agent/test_anthropic_prompt_cache_policy.py@@ -231,6 +231,68 @@ class TestThirdPartyAnthropicGateway:assert agent._anthropic_prompt_cache_policy() == (False, False)+ def test_operator_cache_disable_beats_explicit_capability_true(self):+ """prompt_caching.cache_ttl disable (agent._cache_disabled) is a+ global operator kill-switch — it must win over a per-model+ prompt_caching: true declaration (#33555 semantics)."""+ agent = _make_agent(+ provider="custom:anthropic-proxy",+ base_url="https://gateway.example.com/anthropic",+ api_mode="anthropic_messages",+ model="fable",+ )+ agent._custom_providers = [+ {+ "name": "anthropic-proxy",+ "base_url": "https://gateway.example.com/anthropic",+ "models": {"fable": {"prompt_caching": True}},+ }+ ]+ agent._cache_disabled = True++ assert agent._anthropic_prompt_cache_policy() == (False, False)++ def test_modern_providers_yaml_through_real_loader(self, tmp_path, monkeypatch):+ """Production path: a real config.yaml in the modern ``providers:``+ dict shape, loaded through the real normalizer chain — including the+ init-order fallback where ``_custom_providers`` is NOT yet set on the+ agent and the policy loads config itself."""+ import textwrap++ hermes_home = tmp_path / ".hermes"+ hermes_home.mkdir()+ (hermes_home / "config.yaml").write_text(+ textwrap.dedent(+ """+ providers:+ anthropic-proxy:+ api: https://gateway.example.com/anthropic+ transport: anthropic_messages+ models:+ fable:+ context_length: 1000000+ prompt_caching: true+ opus:+ prompt_caching: false+ """+ )+ )+ monkeypatch.setenv("HERMES_HOME", str(hermes_home))+ # load_config's cache is keyed by resolved config path, so pointing+ # HERMES_HOME at a fresh tempdir needs no cache invalidation.+ agent = _make_agent(+ provider="custom:anthropic-proxy",+ base_url="https://gateway.example.com/anthropic",+ api_mode="anthropic_messages",+ model="fable",+ )+ # No agent._custom_providers — exercises the config fallback the+ # init-time call (agent_init before the snapshot assignment) hits.+ assert agent._anthropic_prompt_cache_policy() == (True, True)++ agent.model = "opus"+ assert agent._anthropic_prompt_cache_policy() == (False, False)+class TestMiniMaxAnthropicWire:"""MiniMax's own model family on its Anthropic-compatible endpoint.