The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(compression): a keyless pinned route clears the main credential
Teknium8aea05810b9d
diff --git a/agent/context_compressor_summary.py b/agent/context_compressor_summary.pyindex 877eb3fec2a..0c37ae91a61 100644--- a/agent/context_compressor_summary.py+++ b/agent/context_compressor_summary.py@@ -37,6 +37,9 @@ class SummaryDispatchMixin:main api_key/base_url would ride into the fallback entry's call (to its host, or instead of it)."""if pinned:+ # Clear first: a keyless pin (local server) resolves its own credential, never the main one.+ for key in ("provider", "model", "base_url", "api_key", "api_mode"):+ call_kwargs.pop(key, None)call_kwargs.update(pinned)returnif self.summary_model:diff --git a/tests/agent/test_compression_aux_fallback_route.py b/tests/agent/test_compression_aux_fallback_route.pyindex 7b6f299dccb..4fdd45e3f51 100644--- a/tests/agent/test_compression_aux_fallback_route.py+++ b/tests/agent/test_compression_aux_fallback_route.py@@ -61,7 +61,7 @@ def test_fallen_back_route_names_main_for_micro_and_never_rides_into_a_pin():assert (captured.get("model"), captured.get("provider")) == ("main-model", "main-provider")- # A stall-fallback pin replaces the whole route: the main key never reaches another host.+ # A KEYLESS stall-fallback pin (local server) replaces the whole route: the main key never rides along.pin = {"provider": "custom", "model": "llama3", "base_url": "http://other-host:8080/v1", "api_key": None}with patch("agent.context_compressor.call_llm", side_effect=_capture), pin_summary_route(pin):compressor._call_summary_llm("prompt", 0.0)@@ -69,3 +69,4 @@ def test_fallen_back_route_names_main_for_micro_and_never_rides_into_a_pin():assert {k: captured.get(k) for k in ("provider", "model", "base_url", "api_key")} == {"provider": "custom", "model": "llama3", "base_url": "http://other-host:8080/v1", "api_key": None,}+ assert "sk-MAIN-SECRET" not in repr({k: v for k, v in captured.items() if k != "main_runtime"})