The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(compression): only a main-agent recovery names the compression model as broken
Teknium4d4552bae0dc
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.pyindex 37616d40eb5..71c165d71b2 100644--- a/agent/auxiliary_client.py+++ b/agent/auxiliary_client.py@@ -7907,7 +7907,8 @@ def _ladder_provider_fallback(first_err: Exception, route: _LadderRoute):fb_resp = yield _LadderStep("fallback", (fb_client, fb_model, fb_label))if fb_resp is not None:if route.route_info is not None: # tell the caller its own route failed, not only where it landed- route.route_info.update(failed_model=route.final_model or "", failure=f"{reason}: {first_err}")+ route.route_info.update(failed_model=route.final_model or "", failure=f"{reason}: {first_err}",+ fallback_label=fb_label)return fb_respfb_client, fb_model, fb_label = _next_fallback_after_quarantine(task, resolved_provider, is_auto, route, _chain_failed_model, _chain_failure_scope,diff --git a/agent/context_compressor_telemetry.py b/agent/context_compressor_telemetry.pyindex bee7df84ff0..ec826c4c64e 100644--- a/agent/context_compressor_telemetry.py+++ b/agent/context_compressor_telemetry.py@@ -111,7 +111,9 @@ class CompressionTelemetryMixin:if isinstance(telemetry, dict):telemetry["fallback_used"] = Truetelemetry["failure_class"] = telemetry.get("failure_class") or "aux_model_fallback"- if route.get("model") == self.model: # the user warning says "summarised with your main model"+ # The user warning says "summarised with your main model": only the main-agent route earns it, never a+ # fallback_chain entry that happens to share the model name on another provider.+ if str(route.get("fallback_label") or "").startswith("main-agent("):self._last_aux_model_failure_model = failed_modelfailure = route.get("failure") or "unknown error"self._last_aux_model_failure_error = failure if len(failure) <= 220 else failure[:217].rstrip() + "..."diff --git a/tests/agent/test_compression_call_llm_fallback_reported.py b/tests/agent/test_compression_call_llm_fallback_reported.pyindex 2f1b56d74a6..150e905c5c3 100644--- a/tests/agent/test_compression_call_llm_fallback_reported.py+++ b/tests/agent/test_compression_call_llm_fallback_reported.py@@ -112,24 +112,15 @@ def test_summary_recovered_on_the_main_model_by_call_llm_is_reported(tmp_path, massert "connection error" in compressor._last_aux_model_failure_error[email protected]("route, warns", [- ({"provider": "custom", "model": "main-fake", "failed_model": "dead", "failure": "connection error: x"}, True),- ({"provider": "openrouter", "model": "chain-model", "failed_model": "dead", "failure": "rate limit: x"}, False),-])-def test_only_a_main_model_recovery_names_the_broken_compression_model(route, warns):[email protected]("label, warns", [("main-agent(custom)", True), ("fallback_chain[0](openrouter)", False)])+def test_only_a_main_model_recovery_names_the_broken_compression_model(label, warns):compressor = ContextCompressor(model="main-fake", config_context_length=64000, quiet_mode=True)compressor._active_compression_telemetry = telemetry = {}- compressor._note_aux_route_fallback(route)+ # Same model name on both routes: only the route that answered decides the "main model" warning.+ compressor._note_aux_route_fallback(+ {"provider": "custom", "model": "main-fake", "failed_model": "dead", "failure": "connection error: x",+ "fallback_label": label})assert telemetry["fallback_used"] is Trueassert (compressor._last_aux_model_failure_model == "dead") is warns---def test_a_route_that_answered_itself_is_not_a_fallback():- compressor = ContextCompressor(model="main-fake", config_context_length=64000, quiet_mode=True)- compressor._active_compression_telemetry = telemetry = {}-- compressor._note_aux_route_fallback({"provider": "custom", "model": "summarizer"})-- assert telemetry == {} and compressor._last_aux_model_failure_model is None